0
TL; DR, 某些如何將當前工作目錄添加到EAR位置。wsadmin - Jython腳本在未指定時拾取PWD
我正在嘗試運行IBM WebSphere ND的Jython腳本來執行目錄中某些應用程序的批量安裝。該腳本需要兩個參數,即EAR的路徑,然後是模塊映射。通過這個腳本,它正確地發現了應用程序,並打印了正確的AdminApp.install()命令,但是當我運行實際的命令時,它以某種方式將PWD放入EAR目錄中。
# This script takes a batch list of EAR names with the extension .ear
# example:
# script.py "/path/to/ear/files" "WebSphere:cell=CELL,stuff=..."
#
import os
import sys
# Gets the Cell Name for the environment
cell_name = AdminControl.getCell()
# Get DMGR Name
dmgr_name = "DMGRDEV" # Needs to not be hardcoded
# The location where the EARs will be stored to be installed.
#ear_location = "/home/wasadmin/ears"
ear_location = sys.argv[0]
# Gets list of files in a directory
dirs = os.listdir(ear_location)
# JVMs and clusters to map the application to.
map_to_modules = sys.argv[1]
for app_name in dirs :
install_app = "'%s/%s', '[ -MapModulesToServers [[ %s ]]]'" % (ear_location, app_name, map_to_modules)
print("Installing " + app_name + ".")
print("AdminApp.install(%s)" % (install_app))
AdminApp.install(install_app)
print("Saving Changes.")
AdminConfig.save()
print("Synching Changes.")
AdminControl.invoke('' + AdminControl.completeObjectName(""+ dmgr_name +",type=DeploymentManager,*") + '', 'multiSync', '[false]', '[java.lang.Boolean]')
# End of for app_name in applicaiton_array
然後我使用這些命令運行該腳本。我製作了一個Run_wsadmin.sh包裝來屏蔽其他選項中的用戶名和密碼,以啓動wsadmin控制檯並運行腳本。
Run_wsadmin.sh -f installEAR.py "/opt/IBM/WebSphere/AppExports3" "WebSphere:cell=wsibpmpsdev00Cell01,cluster=DEV00_DE_1.AppCluster+WebSphere:cell=wsibpmpsdev00Cell01,node=WPS00,server=DEV00IHS00"
WASX7209I: Connected to process "dmgr" on node DMGRDEV using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[/opt/IBM/WebSphere/AppExports3, WebSphere:cell=wsibpmpsdev00Cell01,cluster=DEV00_DE_1.AppCluster+WebSphere:cell=wsibpmpsdev00Cell01,node=WPS00,server=DEV00IHS00]"
Installing Solution_ChangeApp.ear.
AdminApp.install('/opt/IBM/WebSphere/AppExports3/Solution_ChangeApp.ear', '[ -MapModulesToServers [[ WebSphere:cell=wsibpmpsdev00Cell01,cluster=DEV00_DE_1.AppCluster+WebSphere:cell=wsibpmpsdev00Cell01,node=WPS00,server=DEV00IHS00 ]]]')
WASX7017E: Exception received while running file "installEAR.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7115E: Cannot read input file "/home/wasadmin/ContinuousIntegrationScripts/'/opt/IBM/WebSphere/AppExports3/Solution_ChangeApp.ear', '[ -MapModulesToServers [[ WebSphere:cell=wsibpmpsdev00Cell01,cluster=DEV00_DE_1.AppCluster+WebSphere:cell=wsibpmpsdev00Cell01,node=WPS00,server=DEV00IHS00 ]]]'"
所以,我不確定PWD是從哪裏來的,但在EAR位置,它保持了前面的當前工作目錄。那來自哪裏?這整天都讓我瘋狂,而且我沒有選擇。