【问题标题】:Trying to get the name of a cluster in WLST试图在 WLST 中获取集群的名称
【发布时间】:2013-04-16 05:05:57
【问题描述】:

我试图在 wlst 中获取数据源的第一个集群的字符串值名称

cd("/JDBCSystemResources/<datasource name>")
targets = get('Targets')
mytarget = targets[0]

这很好用。如果我使用 viewMBean 命令“viewMBean(mytarget)”,我可以将名称视为属性“名称”

如果我打印 mytarget 的值,我会得到类似:“com.bea:Name=Cluster-1,Type=Cluster”

但我不知道如何获取名称(上例中的“Cluster-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)))

【问题讨论】:

    标签: python wlst


    【解决方案1】:

    你可以说targets[0].getName()为我工作:)

    【讨论】:

    • 迟到总比不到好;-)
    【解决方案2】:

    问题中的代码似乎是对此的最佳答案。即将集群转换为字符串,然后将其子字符串以获取集群名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 2014-03-27
      • 2021-01-30
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 2016-11-09
      相关资源
      最近更新 更多