2011-01-05 28 views
0

我找一個Jython腳本,執行以下操作:的Jython:端口定義

  1. 服務器>應用程序服務器> server1的>端口> WC_default>(設置)端口= 8080。

  2. enviornment> virtaul主機> deault_host>主機別名> [如果沒有與主機名的條目== *,則端口= 8080]

非常感謝你。

回答

1

使用下面的代碼爲出發點:

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]])