jython: port definition
I am looking for a j开发者_如何学Cython script that does the following:
Servers > application servers > server1 > Ports > WC_default > (set) port=8080.
enviornment > virtaul hosts > deault_host > host aliases > [if there is an entry with host name==*, then port = 8080]
Thank you very much.
Use the following code as a starting point:
serverEntries = AdminConfig.list('ServerEntry', AdminConfig.getid('/Node:' + nodeName + '/')).split(java.lang.System.getProperty('line.separator'))
for serverEntry in serverEntries:
if AdminConfig.showAttribute(serverEntry, "serverName") == 'server1':
sepString = AdminConfig.showAttribute(serverEntry, "specialEndpoints")
sepList = sepString[1:len(sepString)-1].split(" ")
for specialEndPoint in sepList:
endPointNm = AdminConfig.showAttribute(specialEndPoint, "endPointName")
if endPointNm == "WC_defaulthost":
ePoint = AdminConfig.showAttribute(specialEndPoint, "endPoint")
# at this point you probably want to do a resetAttribute instead of showAttribute
defaultHostPort = AdminConfig.showAttribute(ePoint, "port")
break
for hostAlias in AdminConfig.getid('/Cell:' + cellName + '/VirtualHost:default_host/HostAlias:/').split(java.lang.System.getProperty('line.separator')):
if AdminConfig.showAttribute(hostAlias, 'port') == defaultHostPort:
print "Deleting host alias for port " + defaultHostPort
AdminConfig.remove(hostAlias)
AdminConfig.create('HostAlias', AdminConfig.getid('/Cell:' + cellName + '/VirtualHost:default_host/'), [['hostname', '*'],['port', defaultHostPort]])
精彩评论