Synchronisation d'un noeud WebSphere avec un script jython.

La synchronisation d'un noeud permet de récupèrer la configuration du dmgr.
Nous allons l'automatiser en jython.

Nous allons nommer le script sync_node_migration.py.

Le lancement de la commande se fait de la manière suivante
Lors de la première execution tout les fihciers "jar" apparaissent, c'est normal.
was8@arecibo:/home/was8$ /apps/WebSphere/profiles8/dmgr/bin/wsadmin.sh -lang jython -f /apps/tmpInstall/WASManager/src/JYTHON/sync_node_migration.py                       <
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/startup.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/bootstrap.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/lmproxy.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/urlprotocols.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/lib/tools.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/deploytool/itp/batchboot.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/deploytool/itp/batch2.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/optionalLibraries/jython/jython.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.admin.core.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.admin.services.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.admin.system.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.batch.admin.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.batch.runtime.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.eba.admin.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.proxy.admin.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.coregroupbridge.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.dist.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.gateway.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.wim.base.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.wim.core.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.wim.mig.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.wim.ui.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.runtime.wim.wmm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.soa.sca.admin.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.soa.sca.admin.osoa.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.soa.sca.aries.admin.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/com.ibm.ws.soa.sca.runtime.osoa.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/org.eclipse.core.runtime.compatibility.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/plugins/org.eclipse.core.runtime_.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/endorsed_apis/jaxws-api.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/endorsed_apis/jaxb-api.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/endorsed_apis/javax.j2ee.annotation.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ppc64/default/jclSC160/vm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/annotation.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/beans.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/java.util.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/jndi.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/logging.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/security.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/sql.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmorb.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmorbapi.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmcfw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/rt.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/charsets.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/resources.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmpkcs.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmcertpathfw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmjgssfw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmjssefw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmsaslfw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmjcefw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmjgssprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmjsseprovider2.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ibmcertpathprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/management-agent.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/xml.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/jlm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/javascript.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/CmpCrmf.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/IBMSecureRandom.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/JavaDiagnosticsCollector.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/dnsns.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/dtfj-interface.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/dtfj.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/dtfjview.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/gskikm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/healthcenter.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmcmsprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmjcefips.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmjceprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmkeycert.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmpkcs11impl.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmsaslprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmspnego.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmxmlcrypto.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/ibmxmlencprovider.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/iwsorbutil.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/jaccess.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/jdmpview.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/localedata.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/traceformat.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/jre/lib/ext/xmlencfw.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/lib/dt.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/lib/htmlconverter.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/lib/ibmorbtools.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/java/lib/jconsole.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/EJBCommandTarget.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/IVTClient.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/OTiSConvertTime.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/activation-impl.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/admin.config.sched.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/aspectjrt.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/batch.wccm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/batchprops.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/batchutilsfep.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/batfepapi.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/bsf-engines.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/commandlineutils.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/commons-discovery.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/databeans.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/ffdcSupport.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/htmlshell.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/iscdeploy.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/ivblogbr.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/j2ee.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/jNative2ascii.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/jacl.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/jrom.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/launchclient.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/mail-impl.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/openwebbeans.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/pc-appext.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/pmirm4arm.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/rrd-appext.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/rsadbutils.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/rsahelpers.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/serviceadapter.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/setup.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/tcljava.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/wses_dynaedge.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/wsif-compatb.jar'
*sys-package-mgr*: processing new jar, '/apps/WebSphere/AppServer8/lib/ext/tw-cur.jar'
ListeNodes --->  ['arecibo(cells/areciboNetwork/nodes/arecibo|node.xml#Node_1)', 'areciboManager(cells/areciboNetwork/nodes/areciboManager|node.xml#Node_1)']
nodeName --->  arecibo
                node arecibo synchronized
nodeName --->  areciboManager
                node areciboManager already synchronized
was8@arecibo:/home/was8$

Voici le code du script sync_node_migration.py.

#=============================
# Version  1.1 
# Created by : TURLAN Franck
# Society : ARECIBO
# Email : franckturlan@yahoo.com
#=============================== 

#============================ 
#Configuration Change
#============================ 
import sys
import java
global AdminControl, AdminConfig
lineSeparator = java.lang.System.getProperty('line.separator')

def SyncNode():
  ListeNodes = AdminConfig.list('Node').split(lineSeparator)
  print "ListeNodes ---> ",ListeNodes
  for node in ListeNodes:
   nodeName = AdminConfig.showAttribute(node,'name')
   print "nodeName ---> ",nodeName
   nodembean = AdminControl.completeObjectName('type=NodeSync,node=' + nodeName + ',*')
   if (nodembean != ""):
    AdminControl.invoke(nodembean,'sync') 
    print "\t\tnode " + nodeName + " synchronized"
   else :
    print "\t\tnode " + nodeName + " already synchronized"

SyncNode()