Is there a method to determine if wsadmin has been invoked using conntype=NONE within the jython shell/script?

StackOverflow https://stackoverflow.com/questions/11772436

  •  24-06-2021
  •  | 
  •  

Question

I am calling a custom script using wsadmin.sh to fetch some server information. I am connecting to a standalone server (not clustered).

When fetching the server information, I also need the server status. If the server is started, I have no issues, but if it is not, then it throws an exception while connecting to it. So I used -conntype=NONE and therefore it opens a wsadmin shell loading the configuration (not connecting to any server process) thereby not allowing me to get the server status.

My requirement is to be able to fetch the connection type dynamically

com.ibm.ws.scripting.connectionType

that was passed during the invocation of wsadmin.sh.

eg :

/opt/WS70/AppServer/profiles/standaloneprofile2/bin/wsadmin.sh -lang jython -conntype none -f /somescriptlocation/PoC/AdminInformation.py standingserver
Était-ce utile?

La solution

AdminControl.getType() returns the connection type. However, from my experience, for CONNTYPE=NONE you will not get "NONE" as a response, but instead you'll get a ScriptingException.

The following code, then, should help:

from com.ibm.ws.scripting import ScriptingException;

...
...

try:
    ct = AdminControl.getType();
except ScriptingException:
    ct = 'NONE';
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top