Obviously you can change DMGR ports at profile creation time and node ports at federation time.... but the cluster member ports need to be done after creation (a bit rubbish if you ask me) ... so here's a script that iterates around all cluster members and changes ports from a pre-defined (passed in as an arg) base port.
import sys;
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Functions
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def modPorts ( cName,startPort ):
# Get a list of hostnames
dict = {}
for node in AdminConfig.list('Node').split():
nHost = AdminConfig.showAttribute(node, 'hostName')
nName = AdminConfig.showAttribute(node, 'name')
# Tie the hostname to the nodename and store in a hashtable for later use
dict[nName] = nHost
try:
clusterId=AdminConfig.getid('/Cell:'+cellName+'/ServerCluster:'+cName)
members=AdminConfig.list('ClusterMember',clusterId).splitlines()
for member in members :
sPort = startPort
nodeName=AdminConfig.showAttribute(member,"nodeName")
memberName=AdminConfig.showAttribute(member,"memberName")
portNames = ['WC_defaulthost','WC_adminhost','WC_defaulthost_secure','WC_adminhost_secure','BOOTSTRAP_ADDRESS','SOAP_CONNECTOR_ADDRESS','SAS_SSL_SERVERAUTH_LISTENER_ADDRESS','CSIV2_SSL_SERVERAUTH_L
ISTENER_ADDRESS','CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS','DCS_UNICAST_ADDRESS','SIB_ENDPOINT_ADDRESS','SIB_ENDPOINT_SECURE_ADDRESS','SIP_DEFAULTHOST','SIP_DEFAULTHOST_SECURE','SIB_MQ_ENDPOINT_ADDRESS','O
RB_LISTENER_ADDRESS','SIB_MQ_ENDPOINT_SECURE_ADDRESS','IPC_CONNECTOR_ADDRESS']
host = dict[nodeName]
print "INFO: Cluster member is "+memberName+" and hostname is "+host
for portName in portNames:
print "INFO: Setting "+portName+" to "+str(sPort)
AdminTask.modifyServerPort(memberName, '[-nodeName '+nodeName+' -endPointName '+portName+' -host '+host+' -port '+str(sPort)+' -modifyShared true ]')
sPort=sPort+1
except:
print "ERROR - problem settign ports for "+cName
print sys.exc_info()[0]
else:
AdminConfig.save()
print "Complete"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Main
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
envName=sys.argv[0]
startPort=int(sys.argv[1])
clusterLabel=sys.argv[2]
cell = AdminConfig.list('Cell')
cellName = AdminConfig.showAttribute(cell, 'name')
print "INFO: Setting "+clusterLabel+" ports"
modPorts(envName+"."+clusterLabel, startPort)
This would be called for each cluster .. for example ...
wsadmin.sh -lang jython -user clarkeb -password mypassword -f setPorts.py PSDEV001 11000 AppTarget
No comments:
Post a Comment