【发布时间】:2011-01-05 04:07:48
【问题描述】:
我正在寻找执行以下操作的 jython 脚本:
服务器 > 应用程序服务器 > server1 > 端口 > WC_default >(设置)端口=8080。
enviornment > virtaul hosts > deault_host > 主机别名 > [如果有主机名==*的条目,则端口= 8080]
非常感谢。
【问题讨论】:
我正在寻找执行以下操作的 jython 脚本:
服务器 > 应用程序服务器 > server1 > 端口 > WC_default >(设置)端口=8080。
enviornment > virtaul hosts > deault_host > 主机别名 > [如果有主机名==*的条目,则端口= 8080]
非常感谢。
【问题讨论】:
使用以下代码作为起点:
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]])
【讨论】: