Topic
  • 1 reply
  • Latest Post - ‏2011-06-22T17:45:16Z by SystemAdmin
HowardKushner
HowardKushner
2 Posts

Pinned topic wsadmin jython scripting (set monitoring policy)

‏2011-06-22T16:30:35Z |
Looks like a library problem similar to those which have aplready been reported... however, I am new to Jython, having done all my previous work in JACL. Nonetheless, I am ready to bite the bullet and tackle a new learning curve.

Please let me know if this is truly a syntax error. Thanks!

:/

ERROR:
======

C:\IBM\WebSphere\AppServer\profiles\Dmgr01\bin>wsadmin -user admin -password password -lang jython -javaoption "-Djy
thon.package.path=C:/IBM/WebSphere/AppServer/plugins/com.ibm.ws.wlm.jar" -f setMonitoringPolicyPrevious.py
sys-package-mgr: processing new jar, 'C:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.wlm.jar'
WASX7209I: Connected to process "dmgr" on node 6475HM9R8FDKCMCellManager01 using SOAP connector; The type of proces
s is: DeploymentManager
WASX7017E: Exception received while running file "setMonitoringPolicyPrevious.py"; exception information: com.ibm.bs
f.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 2
outlist = []
^
SyntaxError: invalid syntax

=========
END ERROR

CODE:
=====

def convertToList( inlist ):
outlist = []
if (len(inlist) > 0):
if (inlist[0] == '[' and inlist'):
  1. Special checking when the config name contain space
if (inlist[1] == "\"" and inlistlen(inlist)-2 == "\""):
clist = inlist1:len(inlist) -1.split(")\" ")
else:
clist = inlist1:len(inlist) - 1.split(" ")
#endIf
else:
clist = inlist.split(java.lang.System.getProperty("line.separator"))
#endIf

for elem in clist:
elem = elem.rstrip();
if (len(elem) > 0):
if (elem[0] == "\"" and elemlen(elem) -1 != "\""):
elem = elem+")\""
#endIf
outlist.append(elem)
#endIf
#endFor
#endIf
return outlist
#endDef

nodeRestartState_attr =
attr_list = nodeRestartState_attr
  1. List servers with specified server type
servers = AdminTask.listServers('-serverType APPLICATION_SERVER ')
print servers
  1. Convert Jython string to list
servers = AdminUtilities.convertToList(servers)
print servers

  1. Loop through each server in server list
for aServer in servers:
  1. Obtain server and node names
sname = aServer
print "Server name="sname"\n"
print sname
nname = aServer
print "Node name="nname"\n"
monitoringPolicy = AdminConfig.list("MonitoringPolicy", server )
AdminConfig.modify(monitoringPolicy, attr_list )
AdminConfig.save( )
#endFor

========
END CODE
Updated on 2011-06-22T17:45:16Z at 2011-06-22T17:45:16Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    462 Posts

    Re: wsadmin jython scripting (set monitoring policy)

    ‏2011-06-22T17:45:16Z  
    Your Jython source code does not have indentation. Not sure the indentation was lost during pasting. Jython does not use curly braces so code block must be properly indented.