我試着在WLST試圖讓一個集羣的名稱WLST
cd("/JDBCSystemResources/<datasource name>")
targets = get('Targets')
mytarget = targets[0]
這工作得很好,以獲得數據源的第一個簇的字符串值名稱。如果我使用viewMBean命令「viewMBean(mytarget)」,我可以看到Name爲屬性「Name」
如果我打印mytarget的值,我會得到類似於:「com.bea:Name = Cluster-1,Type =集羣」
但我不能工作,如何獲取名稱(‘集羣1’在上面的例子)
目前,我想不出什麼做除了讓羣集名稱作爲對象的字符串表示的子串,這聽起來不像是要做的事情
任何幫助表示讚賞。
更新:
由於沒有答案爲止我使用這個解決方案,但仍然希望一個更好的
# get the target cluster from the string "com.bea:Name=<clustername>,Type=Cluster"
if len(targets) == 1 :
tstring = str(targets[0])
targetCluster = tstring[13:tstring.find(",Type=Cluster")]
print "targetCluster = "+targetCluster;
else :
raise Exception("Expected single target cluster for datasource. Targets length was "+str(len(targets)))
比從未更好的遲到;-) – Dunderklumpen