webspherejythonwsadminwas

Use variable in AdminApp.update() function in WAS wsadmin


I'm not able to use a string variable inside AdminApp.update() function that contains the value of sys.argv[0] (EAR filename)

I've tried with %s and then add %(APP_NAME) at the end but it doesn't work.

I'd like to use the variable here:

/installableApps/VARIABLE_I_PASS_FROM_COMMAND

Here is the command:

/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/wsadmin.sh -lang jython -username wasadmin -password ********** -f /root/subidasPRE/Sample/subidaBatchSample.py Sample-Batch.ear

And here is the code:

import sys
APP_NAME  =  sys.argv[0]
AdminApp.update('SampleEAR', 'app', '[ -operation update -contents /installableApps/%s -nopreCompileJSPs -installed.ear.destination $(APP_INSTALL_ROOT)/myCellCell01 -distributeApp -nouseMetaDataFromBinary -nodeployejb -nocreateMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -MapModulesToServers [[ SampleEAREJB SampleEAREJB.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_PER SampleEAREJB_PER.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_SIN SampleEAREJB_SIN.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_PRO SampleEAREJB_PRO.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_COM SampleEAREJB_COM.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_CTR SampleEAREJB_CTR.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_TGEN SampleEAREJB_TGEN.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_DOC SampleEAREJB_DOC.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_CTB SampleEAREJB_CTB.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_RIE SampleEAREJB_RIE.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_REC SampleEAREJB_REC.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_TAR SampleEAREJB_TAR.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_AGE SampleEAREJB_AGE.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_PLN SampleEAREJB_PLN.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ ArqEjbGOperaciones.jar ArqEjbGOperaciones.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEAREJB_GCO SampleEAREJB_GCO.jar,META-INF/ejb-jar.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEARWeb SampleEARWeb.war,WEB-INF/web.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ ArqBatchS ArqBatchSWeb.war,WEB-INF/web.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ][ SampleEARWebInterno SampleEARWebInterno.war,WEB-INF/web.xml WebSphere:cell=myCellCell01,cluster=BatchSampleEAR+WebSphere:cell=myCellCell01,node=centurionNode01,server=webpreint443 ]] -MapWebModToVH [[ SampleEARWebInterno SampleEARWebInterno.war,WEB-INF/web.xml SampleEAR_private_host ]] -MapSharedLibForMod [[ BatchSampleEAR META-INF/application.xml LibAxis14+SampleEARlib ]]] % (APP_NAME)' )
AdminConfig.save()

Thanks.


Solution

  • So I finally found the way.

    This works:

    /installableApps/'+APP_NAME+'
    

    Hope this helps somebody.