Link to home
Create AccountLog in
Avatar of sweety_745
sweety_745Flag for United States of America

asked on

wsadmin script

Need to script the following cmd’s to script. So we can use it anytime.

in wsadmin

Intialize the values
objectName3 = AdminControl.queryNames("*:name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM1*")
objectName4 = AdminControl.queryNames("*:name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM2*")

Open in new window

Verify the Status of MBeans

AdminControl.invoke(objectName3, 'getStatus')
AdminControl.invoke(objectName4, 'getStatus')

Open in new window

From the above two statment, which ever gives us the result as 1  need to pause and resume.

AdminControl.invoke(objectName3, 'pause')
AdminControl.invoke(objectName3, 'resume')

Open in new window

Once the polling is resumed,

delay 15 minutes

stopInterface App1 on Cluster A

startInterface App1 on Cluster A
Avatar of HonorGod
Flag of United States of America image

What do you mean by?

stopInterface App1 on Cluster A
startInterface App1 on Cluster A

something like this perhaps?

import sys
from time import sleep

def process() :
    common = 'name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=%s*'
    try :
        for name in [ 'CM1', 'CM2' ] :
            objectName = AdminControl.queryNames( common % name )
            if objectName :
                status = AdminControl.invoke( objectName, 'getStatus' )
                if status == '1' :
                    AdminControl.invoke( objectName, 'pause' )
                    AdminControl.invoke( objectName, 'resume' )
                    print 'waiting...'
                    sleep( 15 * 60 * 60 )
                    print 'stopInterface App1 on Cluster A'
                    print 'startInterface App1 on Cluster A'
            else :
                print '\nError: object not found:', name
    except :
        Type, value = sys.exc_info()[ :2 ]
        print 'Unexpected exception:'
        print str( Type )
        print str( value )

if name in [ '__main__', 'main' ] :
else :
    print '\nError: Script should be executed, not imported.'
    print '\nUsage: ./ -lang jython -f' % __name__

Open in new window

Avatar of sweety_745


Testing this script now. Will get back to you soon..
it's not complete.

You haven't explained what you mean by:

stopInterface App1 on Cluster A
startInterface App1 on Cluster A
I was looking for application restart on Cluster-A. Sorry about that. Application and server name can be hard coded. It doesn't need to be grabbed Dynamic or scripted.
I would base that code on the following examples in the scriptLibraries folder:

Ex51: startApplicationOnCluster
Ex52: stopApplicationOnCluster

They are in the file in scriptLibraries/application/V70 folder
I updated your script as below:

To see are we sending the correct value to “objectName”. But it doesn’t look like  it is getting the objectName intialized

Change 1:
objectName = AdminControl.queryNames( common % name )
            print 'objecName1 : ', objectName

if __name__ in [ '__main__', 'main' ] :

wasadmin@dev10-ak-fis bin] $ ./ -lang jython -f /tmp/
WASX7209I: Connected to process "dmgr" on node dev10-DEV-CellManager using SOAP connector;  The type of process is: DeploymentManager
objecName1 :

Error: object not found: CM1
objecName1 :

Error: object not found: CM2
wasadmin@dev10-ak-fis bin] $

Open in new window
I think the problem is that there is a comma missing before the "*" in this assignment:

common = 'name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=%s*'

Change it to:

common = 'name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=%s,*'

and see if it is able to locate CM1 & CM2.
Still getting the same
What do you get when you execute this?

./ -lang jython -c "print AdminControl.queryNames( 'name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=%s*' % 'CM1' )"
Sorry, I missed the update. will check that now
My previous string might not correct.

Below is the Exact string what I am looking for:

wsadmin>objectName1 = AdminControl.queryNames("*:name=OC_SubsysGw_In_AjwmsMedApp#SubsysGw_In_AjwmsMedcom/bfusa/wps/otc/inbound/WilsonWMSShipCompleteExport#SubsysGw_In_AjwmsMed_J2CMessageEndpoint,J2EEApplication=OC_SubsysGw_In_AjwmsMedApp,J2EEServer=rmrs.AppTarget.WPS1Node.0,J2CResourceAdapter=WebSphere FTP Adapter,*")
wsadmin>objectName2 = AdminControl.queryNames("*:name=OC_SubsysGw_In_AjwmsMedApp#SubsysGw_In_AjwmsMedcom/bfusa/wps/otc/inbound/WilsonWMSShipCompleteExport#SubsysGw_In_AjwmsMed_J2CMessageEndpoint,J2EEApplication=OC_SubsysGw_In_AjwmsMedApp,J2EEServer=rmrs.AppTarget.WPS2Node.0,J2CResourceAdapter=WebSphere FTP Adapter,*")
wsadmin>AdminControl.invoke(objectName1, 'getStatus')
wsadmin>AdminControl.invoke(objectName2, 'getStatus')

Open in new window

Since the status of objectName1  is 1, i want that to pause and resume
wsadmin>AdminControl.invoke(objectName1, 'pause')
wsadmin>AdminControl.invoke(objectName1, 'resume')

Open in new window

Hi HonorGod,
Can you take a look at the above question.  above one it the correct script i pass to wsadmin in step by step process.

Avatar of HonorGod
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account