I'm creating a script to automate creation of JMS resources in a declarative way using wslt.sh
. This way I just need to run wslt.sh create_resources.py planned_resources.properties
create_resources.py imports another module of mine import include.jms as nmjms
. This include/jms.py calls cd
and cmo
of the WSLT.
The problem is, calling cd
doesn't change the state of cmo
in the jms.py module, so that I can't execute context related commands on cmo
after the cd
invocation. This is frustating...
First, create a module wl.py with the folowing code :
# Caution: This file is part of the command scripting implementation.
# Do not edit or move this file because this may cause commands and scripts to fail.
# Do not try to reuse the logic in this file or keep copies of this file because this
# could cause your scripts to fail when you upgrade to a different version.
# Copyright (c) 2004,2014, Oracle and/or its affiliates. All rights reserved.
"""
This is WLST Module that a user can import into other Jython Modules
"""
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
theInterpreter = WLSTUtil.ensureInterpreter();
WLSTUtil.ensureWLCtx(theInterpreter)
execfile(WLSTUtil.getWLSTCoreScriptPath())
execfile(WLSTUtil.getWLSTNMScriptPath())
execfile(WLSTUtil.getWLSTScriptPath())
execfile(WLSTUtil.getOfflineWLSTScriptPath())
exec(WLSTUtil.getOfflineWLSTScriptForModule())
execfile(WLSTUtil.getWLSTCommonModulePath())
theInterpreter = None
sys.ps1 = origPrompt
modules = WLSTUtil.getWLSTModules()
for mods in modules:
execfile(mods.getAbsolutePath())
jmodules = WLSTUtil.getWLSTJarModules()
for jmods in jmodules:
fis = jmods.openStream()
execfile(fis, jmods.getFile())
fis.close()
wlstPrompt = "false"
Next, import this module in your jms.py module and call wlst commands like this : wl.cd('...')