WLST 查询(将部署的应用程序和主机一起列出) [英] WLST query (List deployed applications and hosts together)

查看:45
本文介绍了WLST 查询(将部署的应用程序和主机一起列出)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 WLST 查询.我通过 WebLogic 脚本工具控制台执行它.这些查询是:

I have two WLST queries. I execute it through WebLogic Scripting Tool console. These queries are:

1) 已部署的应用程序和状态列表:

1) List of deployed applications and status:

connect('weblogic','password','t3://localhost:7001')
cd('AppDeployments')
deplymentsList=cmo.getAppDeployments()
for app in deplymentsList:
      domainConfig()
      cd ('/AppDeployments/'+app.getName()+'/Targets')
      mytargets = ls(returnMap='true')
      domainRuntime()
      cd('AppRuntimeStateRuntime')
      cd('AppRuntimeStateRuntime')
      for targetinst in mytargets:
            curstate4=cmo.getCurrentState(app.getName(),targetinst)
            print app.getApplicationName(), targetinst, curstate4;

输出示例:

  • WeblogicApp Cluster1 STATE_ACTIVE
  • DMS 应用程序管理服务器 STATE_ACTIVE
  • Benefits Cluster2 STATE_ACTIVE

2) 主机列表

connect('weblogic','password','t3://localhost:7001')     
svrs = cmo.getServers()
domainRuntime()
for host in svrs: 
    machine = host.getMachine();
    print "Host:  " + machine.getName()

输出示例:

  • 主机:192.168.200.1
  • 主机:192.168.200.2
  • 主机:192.168.200.3
  • 主机:Machine-0
  • 主机:Machine-1
  • 主机:Machine-2

我需要获取这两个信息(应用程序及其主机或共享主机,如果他们拥有多个).我不知道如何解决和混合查询以在一个查询中获取两个信息,或者至少在第二个查询中获取与部署应用程序相关的信息 - 主机.

I need to get both info (an application and their host or shared hosts if they have it more than one). I don't know how to solve and mix the queries to get both info in one query, or at least to get the info related about deployment application - hosts in the second query.

所需的输出是这样的:

  • WeblogicApp Cluster1 STATE_ACTIVE 192.168.200.2
  • WeblogicApp Cluster1 STATE_ACTIVE 192.168.200.3
  • DMS 应用程序管理服务器 STATE_ACTIVE 192.168.200.1
  • DMS 应用程序管理服务器 STATE_ACTIVE Machine-1
  • DMS 应用程序管理服务器 STATE_ACTIVE Machine-2
  • 好处 Cluster1 STATE_ACTIVE Machine-0
  • ................

提前致谢.

推荐答案

聚会有点晚了.但是,如果其他人来寻找答案,我想出了第一个脚本的扩展以提供所需的结果:

A little late to the party. But if anybody else comes by searching for answers I came up with extension of the first script to give the desired result:

connect('weblogic','password','t3://localhost:7001')
setShowLSResult(false)
cd('AppDeployments')
deplymentsList=cmo.getAppDeployments()
domainConfig()
for app in deplymentsList:
    cd ('/AppDeployments/'+app.getName()+'/Targets')
    mytargets = ls(returnMap='true')
    for targetinst in mytargets:
        domainRuntime()
        cd('AppRuntimeStateRuntime')
        cd('AppRuntimeStateRuntime')
        curstate4 = cmo.getCurrentState(app.getName(),targetinst)
        domainConfig()
        cd('/AppDeployments/'+app.getName()+'/Targets/'+targetinst)
        myType = cmo.getType()
        if myType == 'Cluster':
            myServers = cd('/AppDeployments/'+app.getName()+'/Targets/'+targetinst+'/Servers', returnMap='true')
            for server in myServers:
                cd('/AppDeployments/'+app.getName()+'/Targets/'+targetinst+'/Servers/'+server)
                machineName = cmo.getMachine().getName()
                print app.getApplicationName(), targetinst, curstate4, machineName
        elif myType == 'Server':
            cd('/AppDeployments/'+app.getName()+'/Targets/'+targetinst)
            machineName = cmo.getMachine().getName()
            print app.getApplicationName(), targetinst, curstate4, machineName

输出将类似于原始问题中所述的输出.

The output will be similar to the output stated in the original question.

这篇关于WLST 查询(将部署的应用程序和主机一起列出)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆