Please find the below code
runningServer1 = AdminControl.completeObjectName("type=Server,node=nodename,process=processname,*")
print "server running --->",runningServer1
if len(runningServer1) == 0:
print "Error: Server not running...",process_name
The ouput is that the
"Error : Server not running..."
though my server is running and I am able to launch the application. And also the runningServer1 variable is not printed , why is it that I am unable to get an object for the server?
More information about my question which I posted in IBM forums below
https://www.ibm.com/developerworks/forums/thread.jspa?threadID=374216
bkail is on the right track. You need to make sure your search string is correct. Use:
print AdminControl.queryNames('type=Server,*')
in an interactive wsadmin.sh session to list all of the running servers in your cell. Then use:
'type=Server,name=JVM_NAME,*'
for your search string. Where JVM_NAME is determined from the ouput from the queryNames you just ran.
Also, I'd avoid AdminControl.completeObjectName. I'm not sure of the implications, but this snippet from the doc leads me to think it may not do what you think it does:
Use the completeObjectName command to create a string representation of a complete ObjectName value that is based on a fragment. This command does not communicate with the server to find a matching ObjectName value. If the system finds several MBeans that match the fragment, the command returns the first one.
Here's how IBM does it in WAS_ROOT/scriptLibraries/servers/V70/AdminServerManagement.py (lines 814-815):
runningServer = AdminControl.queryNames("type=Server,node="+nodeName+",name="+serverName+",*")
if (len(runningServer) > 0 and AdminControl.getAttribute(runningServer, "state") == "STARTED"):
...
In my experience, AdminControl.queryNames will only return running servers. So, depending on your needs just checking the return value of len(runningServer) may be sufficient. Also, in true IBM fashion there is nothing in the docs that list the possible return values of AdminControl.getAttribute(runningServer, "state"). I've only been able to find references to 'STARTED'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With