Reputation: 3708
TL;DR, Some how the Present Working Directory is being prepended to the EAR location.
I am trying to run a Jython script for IBM WebSphere ND to do a batch install of some applications in a directory. The script takes two arguments, the path to the EARs, and then the Module Mappings. Going through this script, it does the discovery of the Apps correctly, and prints the correct AdminApp.install() command, but when I run the actual command, it somehow is putting the PWD in the EAR directory.
# 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
Then I run that script using these commands. I made a Run_wsadmin.sh wrapper to mask the username and passwords among other options to launch the wsadmin console and run scripts.
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 ]]]'"
So, I'm not sure where the PWD is coming from, but in the EAR Location, it keeps prepending the present working directory. Where is that coming from? This has been driving me insane all day, and I'm out of options.
Upvotes: 0
Views: 809
Reputation: 5320
The signature is:
AdminApp.install(earFile,options)
So it's probably easier to try breaking it apart into two separate args like:
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)
Upvotes: 1