1
votes

Is there a way to call specific functions in a jython script through the wsadmin program?

# BusAndBusMemeber.py

def devCreateBus:
    AdminTask.createSIBus('[-bus intjmsbus -description [SIBus intjmsbus] -busSecurity false]')
    AdminTask.addSIBusMember('[-bus intjmsbus -node ctgNode01 -server MXServer]')
    AdminConfig.save()

def devDeleteBus:
    AdminTask.deleteSIBus('[-bus intjmsbus]')
    AdminConfig.save()

from server cmd prompt:

C:\IBM\WebSphere....\bin> wsadmin -conntype SOAP -user myUsername -password myPassword -lang jython -f BusAndBusMember.py devCreateBus

Or

C:\IBM\WebSphere....\bin> wsadmin -conntype SOAP -user myUsername -password myPassword -lang jython -f BusAndBusMember.py [devCreateBus]

so far the only way I've been able to execute the jython script is by simply scripting out the AdminTasks.

thanks.

2

2 Answers

2
votes

It is a bit of a hack but you can append this to your script:

globals()[sys.argv[0]]()

An alternative is to keep your functions in this file and write a second python script that does the logic of which functions to call:

import sys
execfile("BusAndBusMemeber.py")
if sys.argv[0] == "devCreateBus":
  devCreateBus();
else:
  print("Unknown arg %s" % sys.argv[0])
1
votes

You could also combine the -profile and -c options like:

.wsadmin.sh -profile "functions.py" -c "print devCreateBus()"

It will still run through the whole -profile script so you probably just want functions in there not a "main".