Sounds simple but I had a bit of bother with this.
I wanted to be able to itterate through all of the JVM's within a Cell (to get heap sizes etc) . This is simpe enough using something like
for jvm in AdminConfig.list('JavaVirtualMachine').splitlines():
print AdminConfig.show(jvm);
Then I wanted to be able to get config information "higher up" such as which Cluster this JVM belonged to and which apps are deployed to it etc etc
To do this I needed to be able to map the JavaVirtualMachine type to the Server type. However, I didn't see an obvious way to do this.... so here's what I did...
import re;
for jvm in AdminConfig.list('JavaVirtualMachine').splitlines():
print "===============================================";
allProps = AdminConfig.showAttribute(jvm, 'systemProperties');
if(re.search('cells', allProps)): # Filter out the null data
serverProp = allProps.split('(')[1].split('#')[0]
print "("+serverProp+")";
a = "("+serverProp+")";
print AdminConfig.show(a);
The key line is serverProp = allProps.split('(')[1].split('#')[0]. This grabs the first element in the System props which will be something like com.ibm.security.jgss.debug(cells/myCell/nodes/node1/servers/server1|server.xml#Property_1349200741174).
The important thing is that this is something to do with the Server (type) running on this JavaVirtualMachine (type). So I thought to myself "if I strip the property name off of the end, surely I'll get an object reference to the whole server".. so this is what the split does, provides a reference to cells/myCell/nodes/node1/servers/server1|server.xml.
Append the brackets and you're now able to get a reference to the Server (type). From here, the world's your oyster :-)
No comments:
Post a Comment