Link to home
Start Free TrialLog in
Avatar of k_satish22
k_satish22

asked on

Jython Script to modify listener ports

Hi,

I am trying to create a jython script to modify listener ports by taking the properties from a properties file. But some how it is not working and I am not sure whether my approach is correct or not. Can someone please help me? Please find the attachment for the script and properties fille.

Thanks
UpdateLP.py
UpdateLP.txt
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

what do you it;s not working? it fails or you dont see the result after successful execution ?
Avatar of k_satish22
k_satish22

ASKER

It is failing with errors. I thinking there is some problem with the logic. The script I am using was created to create listener ports. I am trying to modify it to use for modify listener port properties.
It would help us if you provided the output of a sample execution.

For what are you looking?
- Comments / suggestions about what is failing during the execution of the script?
- Comments / suggestions about programming style?

Hello HonorGod,

I need a script to modify the listner port properties in JACL and jython. Both the script  should take input from a properties file.

here is the output of the script ...
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\
Jython_Scripts\createLP.py C:\ACS\Jython_Scripts\createLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SO
AP connector;  The type of process is: UnManagedProcess
WASX7303I: The following options are passed to the scripting environment and are
 available as arguments that are stored in the argv variable: "[C:\ACS\Jython_Sc
ripts\createLP.txt]"

createLP: INFO --- In main function

createLP: INFO --- Loading the properties to Hash Map => START......

createLP: INFO --- Loading the properties to Hash Map => DONE.


createLP: INFO --- Adding property value to servers START......


createLP: ERROR --- Unable to find server server1.Check the logs for more inform
ation.
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\createLP
.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7077E:
 Incomplete config id: need closing parenthesis in ""

Thank you
Given the input file attached above, I would expect your script to failing within createPropValues() when it makes this call
updateLP(cellName,nodeName,serverName,cfName,rolesList[0],rolesList[1],rolesList[2],rolesList[3],rolesList[4])

because updateLP() would try to:
server = AdminConfig.getid('/Cell:'+cellName+'/Node:'+nodeName+'/Server:'+serverName)

when cellName, nodeName, and serverName are empty strings, which would mean that the call would be like:

server = AdminConfig.getid('/Cell:/Node:/Server:')

which should result in an error like this:

WASX7015E: Exception running command: "AdminConfig.getid('/Cell:/Node:/Server:')"; exception information:
 com.ibm.ws.scripting.ScriptingException: Invalid object name: /Cell:/Node:/Server:

On the other hand, if your "property file" actually contains valid values for

CellName=
NodeName=
ServerName=

Then, the result of the call to AdminConfig.getid() should be a valid configuration ID.
However, we don't know for certain because the script doesn't display the result of the call.

So, where might it be failing?  Well, since we don't see the message that "should" be generated next (i.e., "nupdateLP: INFO --- Checking to see if Listener port..."), the call that is most likely failing is:

mls = AdminConfig.list('MessageListenerService', server)


You are correct I have removed the cell name, node name and server name in the attached properties file. The property file which I am using is having those details.

For so reason when I am using single quote characters wsadmin is throwing the below error so I changed the single quote characters to double quote characters and it worked. I have updated the script with double quote characters.

wsadmin>AdminConfig.getid('Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1')
WASX7015E: Exception running command: "AdminConfig.getid('Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1')"
; exception information:
 com.ibm.ws.scripting.ScriptingException: Invalid object name: Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:serve
r1

Now I  am getting below error when I am executing the script. Please find the attachment for you updated script and properties file.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Update_LP.py C:\ACS\Jython_Scripts\Upd
ate_LP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Update_LP.txt]"

updateLP: INFO --- In main function

updateLP: INFO --- Loading the properties to Hash Map => START......

updateLP: INFO --- Loading the properties to Hash Map => DONE.


updateLP: INFO --- Adding property value to servers START......

WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Update_LP.py"; exception information: com.ibm.bsf.BSFExceptio
n: exception from Jython:
Traceback (innermost last):
  File "<string>", line 130, in ?
  File "<string>", line 123, in main
  File "<string>", line 59, in createPropValues
  File "<string>", line 64, in updateLP
TypeError: __add__ nor __radd__ defined for these operands

Update-LP.py
Update-LP.txt
> You are correct I have removed the cell name, node name and server name in the attached properties file. The property file which I am using is having those details.

  This is very reasonable.

> For so reason when I am using single quote characters wsadmin is throwing the below error so I changed the single quote characters to double quote characters and it worked. I have updated the script with double quote characters.

  Jython (and Python) allow either single, or double quotes as string delimiters. The limitations are:

- The same quote character (either single or double) must be used to end the string that was used to start the string.  So, if you start the string with a single quote, then you must end with a single quote.

- If the string needs to include, or contain, the starting/ending quote character, then the place(s) within the string where this character should be positioned, must be "escaped" by having the quote character immediately preceded by a backslash character:

>>> 'Don\'t'
"Don't"

> WASX7015E: Exception running command: ...
> ... Invalid object name:

  The "name" that you specified is invalid because it should start and end with a slash...

AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )

> Traceback (innermost last):
  File "<string>", line 130, in ?
  File "<string>", line 123, in main
  File "<string>", line 59, in createPropValues
  File "<string>", line 64, in updateLP
TypeError: __add__ nor __radd__ defined for these operands

  The way to read this is:

- Line 130 is where the first (outermost) function call occurred.
  When we look at this line, we find that it contains:

130: main()

  Which is no surprise.

- The next function call happened in line 123, which happens to be within the function named main()
  as the stack trace tells us.  This line has:

123:   createPropValues()

- The next function call happened in line 59, which is in createPropValues, and which looks like:

 59:       updateLP(...)

- The last line (i.e., 64) tells us the one in which the error (exception) actually occurred.  This line has:

 64:    server = AdminConfig.getid("/Cell:"+cellName+"/Node:"+nodeName+"/Server:"+serverName)

  What's wrong with this statement?  Well, it all depends upon the values of the variables.
  If cellName, nodeName, and serverName are strings, then the plus sign represents a string concatenation operation.  However, if, for example, the value of cellName is None, we get the following:
wsadmin>"/Cell:" + None
WASX7015E: Exception running command: ""/Cell:" + None"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
TypeError: __add__ nor __radd__ defined for these operands

Open in new window

So, you really need to verify your data before you use it.

Does that make sense?
Thank you somuch for your help. Yes it make perfect sence.

Now I have resolve few issues with script but now it failing with a message saying Listener port not there on the server. Please find the details below. Can you please fix the logic which I have used in the script?
Requirments of othe script is

1. check whether the ListnerPort is there or not, if it not there exit from the script saying ListnerPort is not there.
2 If ListnerPort is there  update the ListnerPort properties by taking them from  the properties file.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Update_LP.py C:\ACS\Jython_Scripts\Upd
ate_LP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Update_LP.txt]"

updateLP: INFO --- In main function
updateLP: INFO --- Loading the properties to Hash Map => START......
updateLP: INFO --- Loading the properties to Hash Map => DONE.
updateLP: INFO --- Adding property value to servers START......
updateLP: INFO --- Checking to see if Listener port sample is configured on server server1
updateLP: INFO --- Listener port sample Not there on server server1. Skipping Listener port modification.

Your description of what you need (now) is much better.  [Thank you!]

Please attach the current version of your script.

Thanks!
Please find the attachement
Update-LP.py
Update-LP.txt
Hi  HonorGod

I know you are busy. Just want to know the status. Thank you very much for your help.
I know that it's not complete, but take a look at this...
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          head, tail = line.split( '=', 1 );
          jndi, rest = tail.split( ':', 1 );
          print 'jndi:', jndi;
          print 'rest:', rest;
    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

I don't have any ListenerPorts defined, so I was wondering if you would try the following for me in an  wsadmin command invocation:

I'm trying to find out if we can get the list of defined ListenerPorts scoped by an Application Server

Thanks
wsadmin -conntype none -lang jython -c "print AdminConfig.list( 'ListenerPort', AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' ) )"

Open in new window

Equivalent interactive commands:

---------------------------------------------------------------
s = AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )

print AdminConfig.list( 'ListenerPort', s )
---------------------------------------------------------------

Open in new window

wsadmin>s = AdminConfig.getid( '/Cell:ATL0LW00R996VTNNode01Cell/Node:ATL0LW00R996VTNNode01/Server:server1/' )
wsadmin>print AdminConfig.list( 'ListenerPort', s )
sample(cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#ListenerPort_1297826551343)
Excellent.  That helps immensely!

Alright.  This version makes use of that information.

Here's the next question for you:

Given the specified "ListenerPort Name", do you want to modify all of the attributes using the input line?

For example, from your input file, the "ListenerPort Name" should be "sample"
Do you want to change the connectionFactoryJNDIName to what follows, then
the maxSessions, maxRetries, and maxMessages using the (integer) values that follow?

What happens if a value is missing?

Are the values required, or optional?

Thanks for helping me understand.
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          prefix, suffix = line.split( '=', 1 );
          LPname, rest   = suffix.split( ':', 1 );
          print 'LPname:', LPname;
          print 'rest:', rest;
          for LP in AdminConfig.list( 'ListenerPort', server ).splitlines() :
            if LPname == AdminConfig.showAttribute( LP, 'name' ) :
              print AdminConfig.show( LP );

    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

It would be good if they are optional. Depending on the requirements we will update the properties file with the required values. If we did not specify a value in the properties files that value should not be changed.

Thank you so much for your help. You Rock...  
This "might" work...
'''Command: %(cmdName)s\n
Purpose: Use a properties file to modify Listener Ports\n
  Usage: wsadmin -f %(cmdName)s.py <inputFile>\n
Example: ./wsadmin.sh -f %(cmdName)s.py %(cmdName)s.txt'''

import AdminConfig;
import os;
import sys;


#---------------------------------------------------------------------
# Name: process()
# Role: Attempt to read, and process the specified input file.
#---------------------------------------------------------------------
def process( filename ) :
# print 'process( "%s" )' % filename;
  try :
    info, server = {}, None;
    f = open( filename );
    data = f.read().splitlines();
    for line in data :
      if line and not line.startswith( '#' ) :
        if line.find( ':' ) < 0 :
          name, value = line.split( '=', 1 );
          info[ name ] = value;
        elif line.startswith( 'Property:Value' ) :
          if not server :
            name   = '/Cell:%(CellName)s/Node:%(NodeName)s/Server:%(ServerName)s/' % info;
            server = AdminConfig.getid( name );
            if not server :
              print 'Specified server not found: %s\n' % name;
              break;
          #-----------------------------------------------------------
          # prefix == 'Property:Value'
          # suffix == ListenerPort Name:JNDI Name,Connection Factory Name,maxsessions,maxretries,maxmessages
          #-----------------------------------------------------------
          prefix, suffix = line.split( '=', 1 );
          LPname, rest   = suffix.split( ':', 1 );
          print 'LPname:', LPname;
          print 'rest:', rest;
          #-----------------------------------------------------------
          # [ 0 ] == destinationJNDIName
          # [ 1 ] == connectionFactoryJNDIName
          # [ 2 ] == maxSessions
          # [ 3 ] == maxRetries
          # [ 4 ] == maxMessages 
          #-----------------------------------------------------------
          values = rest.split( ',' );
          values.extend( [ '' ] * 5 ); # Guarantee sufficient values exist...
          for LP in AdminConfig.list( 'ListenerPort', server ).splitlines() :
            if LPname == AdminConfig.showAttribute( LP, 'name' ) :
              print 'Before:\n' + ( '-' * 50 );
              print AdminConfig.show( LP );
              print '-' * 50;
              #-------------------------------------------------------
              # Use list comprehension to 
              #-------------------------------------------------------
              changes =  [ item for item in [ 'destinationJNDIName'      , values[ 0 ] ],
                                            [ 'connectionFactoryJNDIName', values[ 1 ] ],
                                            [ 'maxSessions'              , values[ 2 ] ],
                                            [ 'maxRetries'               , values[ 3 ] ],
                                            [ 'maxMessages'              , values[ 4 ] ] if item[ 1 ] ] );
              print 'Changes: ' + str( changes );
              AdminConfig.modify( LP, changes );

              print ' After:\n' + ( '-' * 50 );
              print AdminConfig.show( LP );
              print '-' * 50;
    f.close();
  except :
    t, v = sys.exc_info()[ :2 ];
    t, v = str( t ), str( v );
    print 'Exception\n Type: %s\nValue: %s' % ( t, v );


#---------------------------------------------------------------------
# Name: textFile()
# Role: Determine if the specified file exists, and is a "regular"
#       file (e.g., is not a directory)
#---------------------------------------------------------------------
def textFile( filename ) :
  return os.path.exists( filename ) and os.path.isfile( filename );


#---------------------------------------------------------------------
# Name: main()
# Role: Routine used to perform script role.
#---------------------------------------------------------------------
def main() :
  argc = len( sys.argv );
  if argc != 1 :
    print 'Error: unexpected number of command line arguments: %d\n' % argc;
    Usage();

  filename = sys.argv[ 0 ];
# print 'filename: %s' % filename;
  if not textFile( filename ) :
    print 'Error: file not found, or invalid: %s\n' % filename;
    Usage();

  process( filename );


#---------------------------------------------------------------------
# Name: Usage()
# Role: Display script usage (docstring) information
#---------------------------------------------------------------------
def Usage( cmdName = None ) :
  import re;

  if not cmdName :
    cmdLine = os.environ.get( 'IBM_JAVA_COMMAND_LINE' );
    scriptPath = re.sub( '.*-f ([^ ]*).*', r'\1', cmdLine );
    scriptName = os.path.basename( scriptPath );

    if scriptName.endswith( '.py' ) :
      cmdName = scriptName[ :-3 ];
    else :
      cmdName = scriptName;

  print __doc__ % locals();
  sys.exit();


#---------------------------------------------------------------------
# Name: anonymous / unnamed
# Role: script execution appears to begin here
# Note: Verify that the script was executed, not imported.
#---------------------------------------------------------------------
if __name__ == '__main__' :
  main();
else :
  print 'Error: Script must be executed, not imported.\n'
  Usage( __name__ );

Open in new window

I am getting below error when I am executing the script

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP.py C:\A
CS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP.py"; exception information: co
m.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 6, in ?
ImportError: no module named AdminConfig
hm.  Sorry,  I guess that my environment automatically made the wsadmin scripting object available in a way that let me do that statement (i.e., line 6).

What happens if you delete, or comment out that line?

e.g.,

Change:

import AdminConfig;

To:

# import AdminConfig;
I  getting below error.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py C:
\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
Error: Script must be executed, not imported.

Command: main

Purpose: Use a properties file to modify Listener Ports

  Usage: wsadmin -f main.py <inputFile>

Example: ./wsadmin.sh -f main.py main.txt

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>
ooh.  What version of WebSphere are you using?!?

Change line 130 from this:

if __name__ == '__main__' :

To this:

if ( __name__ == '__main__' ) or ( __name__ == 'main' ) :

(sigh)... bit my wsadmin... thank you very much...
Did you try that suggestion?

Did it fix your issue?
hehe... That typo should have been..

bit BY wsadmin...

I am executing the script on WAS 6.1. Still gettings error...
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py C:
\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
WASX7017E: Exception received while running file "C:\ACS\Jython_Scripts\Final_Working_Scripts\updateLP_1.py"; exception information:
com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  (no code object) at line 0
  File "<string>", line 103
        main();
        ^
SyntaxError: invalid syntax
The indentation must be wrong.  Let me attach it as a file.
Update-LP.py.txt
Thank you so much for you hard work.
When I executed the above attached script it failed with below error in line 62. I think there extra ")" I removed it and script worked absolutely fine.

I think AdminConfig.Save() is missing Please let me know where to added save and sync node in the script.

C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>wsadmin -lang jython -f C:\ACS\Jython_Scripts\Final_Working_Scripts\fin\Update_LP.py
 C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt
WASX7209I: Connected to process "server1" on node ATL0LW00R996VTNNode01 using SOAP connector;  The type of process is: UnManagedProce
ss
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv v
ariable: "[C:\ACS\Jython_Scripts\Final_Working_Scripts\UpdateLP.txt]"
LPname: sample
rest: Dest,QCF,5,1,1
Before:
--------------------------------------------------
[connectionFactoryJNDIName QCF]
[destinationJNDIName Dest]
[maxMessages 1]
[maxRetries 1]
[maxSessions 1]
[name sample]
[stateManagement (cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#StateManageable_129782655134
3)]
--------------------------------------------------
Changes: [['destinationJNDIName', 'Dest'], ['connectionFactoryJNDIName', 'QCF'], ['maxSessions', '5'], ['maxRetries', '1'], ['maxMess
ages', '1']]
 After:
--------------------------------------------------
[connectionFactoryJNDIName QCF]
[destinationJNDIName Dest]
[maxMessages 1]
[maxRetries 1]
[maxSessions 5]
[name sample]
[stateManagement (cells/ATL0LW00R996VTNNode01Cell/nodes/ATL0LW00R996VTNNode01/servers/server1|server.xml#StateManageable_129782655134
3)]
--------------------------------------------------
WASX7309W: No "save" was performed before the script "C:\ACS\Jython_Scripts\Final_Working_Scripts\fin\Update_LP.py" exited; configura
tion changes will not be saved.

ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Once again Thank you very much for the script. You are the Best.
Why did you choose your answer as the solution?

Was that a mistake?  I think so... ;-)
I am sorry it is a mistake.
Thanks for the grade & points.

Good luck & have a great day.