2016-06-23 1 views
0

TL, DR, 현재 작업 디렉토리가 EAR 위치 앞에 어떻게 추가되는지 설명합니다.wsadmin - 지정되지 않은 경우 PWD를 가져 오는 자이 썬 스크립트

IBM WebSphere ND 용 Jython 스크립트를 실행하여 디렉토리의 일부 응용 프로그램을 일괄 설치하려고합니다. 스크립트는 EAR에 대한 경로와 모듈 매핑의 두 인수를 취합니다. 이 스크립트를 통해 App의 발견을 올바르게 수행하고 올바른 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 위치에서는 현재 작업 디렉토리보다 우선합니다. 그게 어디서 오는거야? 이것은 하루 종일 나를 미치게 만들었고, 나는 선택의 여지가 없다.

답변

1

서명은 다음과 같습니다

AdminApp.install(earFile,options) 

그래서 같이 두 개의 인수로 떨어져 그것을 깨는 시도하는 것이 더 쉬울 것입니다 :

for app_name in dirs : 
    install_app_loc = "%s/%s" % (ear_location, app_name) 
    install_app_opts = "'[ -MapModulesToServers [[ %s ]]]'" % (map_to_modules) 
    # ... 
    AdminApp.install(install_app_loc, install_app_opts)