Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get the name of a cluster in WLST

Tags:

python

wlst

Im trying to get the string value name of the first cluster of a datasource in wlst

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

This works fine. If I use a viewMBean command "viewMBean(mytarget)" I can see the Name as the attribute "Name"

If I print the value mytarget I get something like: "com.bea:Name=Cluster-1,Type=Cluster"

But I cannot work out how to get the name ("Cluster-1" in the example above)

At the moment I can't think of anything to do other than getting the cluster name as a substring of the string representation of the object, which doesn't sound like the thing to do

Any help appreciated.

Update:

With no answers so far I'm using this solution, but still hoping for a better one

# 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)))
like image 965
Dunderklumpen Avatar asked Dec 06 '25 00:12

Dunderklumpen


1 Answers

you can just say targets[0].getName() worked for me :)

like image 97
Jinu Mohan Avatar answered Dec 08 '25 14:12

Jinu Mohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!