0
votes

I'm trying to access the Admin objects via a Jython script in order to update a Maven app deployed to a WebSphere Application Server without having to march through the Integrated Solutions Console every time I make a change. My question is simple: I know how to invoke the commands once I access the Admin objects, but I'm having difficulty getting that far. Once I'm in the bin folder of my server profile, do I need to assign them to objects, or can I just call them directly? And how, specifically, would I do that? Here's the code I have now:

#!usr/bin/local/python

import sys
import os

try:
    serverPath = 'c:\IBM\WebSphere8\AppServerND\profiles\\WAS8\\bin\\'
    os.chdir(serverPath)
    print AdminApp.listModules('restreportscore-application')
except:
    e = sys.exc_info()[0]
    print( "Error: %s" % e )
    endSelect = raw_input("Press Enter to continue...")

But it's throwing an error of type 'exceptions.NameError.'

1

1 Answers

0
votes

It doesn't work the way it looks like you think it works. The jython interface mirrors the cmd line actions, but isn't the same. You call a jython script like this:

sudo /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh lang jython -f ./trecs-installer.py

So it already knows "where" it is. At that point you execute your commands through the AdminApp, AdminConfig and AdminTask APIs like this:

AdminApp.install(earDir + "trecs.ear", "[" + settings + ' -MapModulesToServers [' + mapModulesToServers + '] -MapRolesToUsers [' + mapRolesToUsers + "]")

or

# Add destinations and queues...
for item in trecsQueues:
    if isNetworkDeploy:
            AdminTask.createSIBDestination("[-bus " + trecsBus + " -name " + item + " -type Queue -reliability ASSURED_PERSISTENT -cluster " + clusterName + ']')
            AdminTask.createSIBJMSQueue(clusterLongName, "[-name " + item + " -jndiName queue/" + item + " -busName " + trecsBus + " -queueName "  + item + ']')
    else:
            AdminTask.createSIBDestination("[-bus " + trecsBus + " -name " + item + " -type Queue -reliability ASSURED_PERSISTENT -node " + nodeName + ' -server ' + serverName + ']')
            AdminTask.createSIBJMSQueue(serverLongName, "[-name " + item + " -jndiName queue/" + item + " -busName " + trecsBus + " -queueName "  + item + ']')