啟動 wasadmin
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -username ${username} -password ${password} -lang jython -profileName AppSrv01
執行 .py 檔案
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -username ${username} -password ${password} -lang jython -profileName AppSrv01 -f ${FILE}
********** 可以用的 AdminObject
*AdminConfig provides an interface to the WAS configuration repository available under profile_root/config. All AdminConfig services are provided by the Deployment Manager (assuming you're connecting remotely); there is no dependency on node agents.
*AdminControl provides an interface to JMX managed beans (MBeans) in your WAS environment. In general, MBeans are only available for the resources that are running. For example, if an application server is down, the corresponding MBean will not be available.
**********列出所有 Server
import java.lang.System as sys
lineSeparator = sys.getProperty('line.separator')
jdbcps=AdminConfig.list('Server').split(lineSeparator)
for server in jdbcps:
print "====================================================="
print server
print AdminConfig.showAttribute(server,'name')
#print AdminConfig.showall(server)
print "====================================================="
**********儲存變更
AdminConfig.save()
********** Sync 另外一個 Node
import java.lang.System as sys
def getAnotherNode():
lineSeparator = sys.getProperty('line.separator')
nodes = AdminConfig.list('Node').split(lineSeparator)
thisnode=AdminControl.getNode()
for node in nodes:
nodename = AdminConfig.showAttribute(node, 'name')
#print "PROC "+nodename
if(nodename != thisnode):
#print "find "+nodename
return nodename
nodename = getAnotherNode()
Sync1=AdminControl.completeObjectName("type=NodeSync,node="+nodename+",*")
print nodename
if Sync1 != "":
AdminControl.invoke(Sync1, 'sync')
AdminConfig.save()
******************* 在 jython 檔中引入另一個 jython 檔的方式
用 execfile('C:/temp/save.py') 引入另一個檔,然後 直接 call 另一個 jython 檔中的 function
** 用 python include 的方式的話,不涉及 AdminApp, AdminConfig, AdminControl, AdminTask 元件的部分都可以正常工作。但是被引入的檔案本身看不到這些元件,所以會吐這種東西出來
NameError: AdminConfig
** 用 import 的方式似乎會當成 java 檔 compilie 成 class ?
參考
** 用 python include 的方式的話,不涉及 AdminApp, AdminConfig, AdminControl, AdminTask 元件的部分都可以正常工作。但是被引入的檔案本身看不到這些元件,所以會吐這種東西出來
NameError: AdminConfig
** 用 import 的方式似乎會當成 java 檔 compilie 成 class ?
參考
*******************參考
ServerManagement command group for the AdminTask objectConfiguring servers with scripting