Here is a little jython script that I wrote to go through a WAS environment and change the values of a particular JDBC provider. The sync command is later executed.
import string
lineSeparator = java.lang.System.getProperty('line.separator')
def SYNCNODE():
NODELIST = AdminConfig.list("Node").split(lineSeparator)
repID = AdminControl.completeObjectName("WebSphere:type=ConfigRepository,process=dmgr,*")
AdminControl.invoke(repID, "refreshRepositoryEpoch")
print "Synching Nodes"
for NODENAME in NODELIST:
NODE=NODENAME.split('(')[0]
NODESYNC=AdminControl.completeObjectName("WebSphere:type=NodeSync,node="+NODE+",*")
if (len(NODESYNC) == 0):
continue
else:
AdminControl.invoke(NODESYNC, "sync")
print "NODE " + NODE + " has been synchronized successfully"
# Modify classpath for each type of provider installed
myCell = str(AdminControl.getCell())
providerList = AdminConfig.list('JDBCProvider', AdminConfig.getid('/Cell:' + myCell + '/'))
counter = 0
correctDB2Path="${DB2_9_JDBC_DRIVER_PATH}/db2java.zip"
providerList = providerList.split("\n")
for providerID in providerList:
if (providerID.find("DB2_TYPE_2_LEGACY_V9_1") != -1):
jdbcProviderId = AdminConfig.getid( '/Cell:' + myCell + '/JDBCProvider:DB2_TYPE_2_LEGACY_V9_1/')
classpathAttribute = AdminConfig.showAttribute(jdbcProviderId, 'classpath')
if ( classpathAttribute == correctDB2Path ):
print "\tThe variable is already correct: " + classpathAttribute
break
print "Before: " + classpathAttribute
AdminConfig.modify(jdbcProviderId, [['classpath', '' ]])
AdminConfig.modify(jdbcProviderId, [['classpath', correctDB2Path ]])
classpathAttribute = AdminConfig.showAttribute(jdbcProviderId, 'classpath')
print "After: " + classpathAttribute
AdminConfig.save()
SYNCNODE()