【问题标题】:Weblogic WSLT in modular python script模块化python脚本中的Weblogic WSLT
【发布时间】:2023-04-05 21:55:01
【问题描述】:

我正在创建一个脚本,以使用wslt.sh 以声明方式自动创建 JMS 资源。这样我只需要运行wslt.sh create_resources.py planned_resources.properties

create_resources.py 导入我的另一个模块 import include.jms as nmjms。此 include/jms.py 调用 WSLT 的 cdcmo

问题是,调用cd 不会改变jms.py 模块中cmo 的状态,所以在cd 调用之后,我无法在cmo 上执行上下文相关的命令。这令人沮丧……

【问题讨论】:

    标签: python weblogic weblogic-10.x


    【解决方案1】:

    首先,使用以下代码创建一个模块 wl.py:

    # 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"
    

    接下来,将此模块导入您的 jms.py 模块并调用 wlst 命令,如下所示:wl.cd('...')

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-21
    • 2021-08-16
    • 1970-01-01
    • 2023-03-14
    • 2020-01-18
    • 1970-01-01
    • 2014-02-11
    相关资源
    最近更新 更多