This Script will change the ports of Node Agent:
WRITTEN BY Suvash
This Script changes node agent ports and picks port value from portsFile.properties
import sys,java
from java.util import Properties
from java.io import FileInputStream
from org.python.modules import time
lineSep = java.lang.System.getProperty('line.separator')
def change_port(bootstrap,orb,csiv2_multi,csiv2_server,dcs,drs,nda,nma1,nma2,sas,soap,host,node):
global AdminApp
global AdminConfig
global AdminControl
global AdminTask
cell = AdminControl.getCell()
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "BOOTSTRAP_ADDRESS"
portsDict["host"] = host
portsDict["port"] = bootstrap
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "ORB_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = orb
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = csiv2_multi
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = csiv2_server
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "DCS_UNICAST_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = dcs
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "DRS_CLIENT_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = drs
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = nda
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_IPV6_MULTICAST_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["port"] = nma1
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "NODE_MULTICAST_DISCOVERY_ADDRESS"
portsDict["host"] = host
portsDict["port"] = nma2
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SAS_SSL_SERVERAUTH_LISTENER_ADDRESS"
portsDict["host"] = host
portsDict["port"] = sas
portsDict["modifyShared"] = "true"
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
portsDict = {}
portsDict["nodeName"] = node
portsDict["endPointName"] = "SOAP_CONNECTOR_ADDRESS"
portsDict["host"] = host
portsDict["modifyShared"] = "true"
portsDict["port"] = soap
AdminTask.modifyServerPort('nodeagent',
["-%s %s" % (key, value) for key, value in portsDict.items()])
#--Saving Configuration--#
AdminConfig.save()
## Syncronizing node
nodelist = AdminTask.listManagedNodes().split(lineSep)
for nodename in nodelist :
print " Syncronizing node.......... "
####################Identifying the ConfigRepository MBean and assign it to variable######################
repo = AdminControl.completeObjectName('type=ConfigRepository,process=nodeagent,node='+ nodename +',*')
print AdminControl.invoke(repo, 'refreshRepositoryEpoch')
sync = AdminControl.completeObjectName('cell='+ cell +',node='+ nodename +',type=NodeSync,*')
print AdminControl.invoke(sync , 'sync')
print " ----------------------------------------------------------------------------------------- "
print " Full Resyncronization completed "
print " ----------------------------------------------------------------------------------------- "
if (len(sys.argv)!= 13):
print "you didnt supplied correct number of argument"
else:
bootstrap=sys.argv[0]
orb=sys.argv[1]
csiv2_multi=sys.argv[2]
csiv2_server=sys.argv[3]
dcs=sys.argv[4]
drs=sys.argv[5]
nda=sys.argv[6]
nma1=sys.argv[7]
nma2=sys.argv[8]
sas=sys.argv[9]
soap=sys.argv[10]
host=sys.argv[11]
node=sys.argv[12]
change_port(bootstrap,orb,csiv2_multi,csiv2_server,dcs,drs,nda,nma1,nma2,sas,soap,host,node)
No comments:
Post a Comment