使用 wsadmin 脚本编制列示已安装的应用程序中的模块

使用 AdminApp 对象 listModules 命令来列示已安装的应用程序中的模块。

关于此任务

您可以运行 listModules 命令来查看哪些模块在安装的应用程序中。

过程

  1. 启动 wsadmin 脚本编制工具。
  2. 显示应用程序模块。
    使用 Jacl:
    $AdminApp listModules DefaultApplication -server
    使用 Jython:
    print AdminApp.listModules('DefaultApplication', '-server')
    表 1. listmodules 命令元素. 运行 listmodules 命令来列示应用程序模块。
    元素 描述
    $ 是使用其值替换变量名的 Jacl 运算符
    print 是 Jython 命令
    AdminApp 是支持应用程序对象管理的对象
    listmodules 是 AdminApp 命令
    DefaultApplication 是应用程序名称
    -server 是指定的可选选项
    示例输出:
    DefaultApplication#IncCMP11.jar+META-INF/ejb-jar.xml#WebSphere:cell=mycell,node=mynode,server=myserver
    DefaultApplication#DefaultWebApplication.war+WEB-INF/web.xml#WebSphere:cell=mycell,node=mynode,server=myserver

示例

以下示例列示了安装在 server1 服务器上名为 node1 的节点中的所有企业应用程序上的所有模块。

星号 (*) 意味着模块安装在 server1 和 node1 以及其他服务器或节点上。加号 (+) 意味着模块仅安装在 server1 和 node1 上。

 1  #-----------------------------------------------------------------------------------
       2  # setting up variables to keep server name and node name 
       3  #------------------------------------------------------------------------------
       4  set  serverName  server1
       5  set  nodeName  node1
       6  #-------------------------------------------------------------------------------
       7  # setting up 2 global lists to keep the modules
       8  #--------------------------------------------------------------------------------
       9  set  ejbList {}
      10 set webList {}
11
12 #----------------------------------------------------------------------------------------
13 # gets all deployment objects and assigned it to deployments variable
14 #-----------------------------------------------------------------------------------------
15 set deployments [$AdminConfig getid /Deployment:/]
16
17 #-----------------------------------------------------------------------------------------
18 # lines 22 thru 148 Iterates through all the deployment objects to get the modules
19 # and perform filtering to list application that has at least one module installed
20 # in server1 in node myNode
21 #-----------------------------------------------------------------------------------------
22 foreach deployment $deployments {
23
24     # ------------------------------------------------------------------------------------
25     # reset the lists that hold modules for each application
26     #-------------------------------------------------------------------------------------
27     set webList {}
28     set ejbList {}
29
30     #------------------------------------------
31     # get the application name
32     #------------------------------------------
33     set appName [lindex [split $deployment (] 0]
34
35     #------------------------------------------          
36     # get the deployedObjects
37     #------------------------------------------
38     set depObject [$AdminConfig showAttribute $deployment deployedObject]
39
40     #--------------------------------------------    
41     # get all modules in the application
42     #---------------------------------------------
43     set modules [lindex [$AdminConfig showAttribute $depObject modules] 0] 
44
45     #---------------------------------------------------------------------------------------------
46     # initialize lists to save all the modules in the appropriate list to where they belong
47     #---------------------------------------------------------------------------------------------
48     set modServerMatch {}  
49     set modServerMoreMatch {}
50     set modServerNotMatch {}
51
52         #-----------------------------------------------------------------------------------------
53         # lines 55 to 112 iterate through all modules to get the targetMappings
54         #------------------------------------------------------------------------------------------
55         foreach module $modules {
56             #--------------------------------------------------------------------------------------
57             # setting up some flag to do some filtering and get modules for server1 on node1
58             #--------------------------------------------------------------------------------------
59             set sameNodeSameServer "false"
60            set diffNodeSameServer "false"
61             set sameNodeDiffServer "false"
62             set diffNodeDiffServer "false"
63
64             #--------------------------------------------
65             # get the targetMappings
66             #--------------------------------------------
67             set targetMaps [lindex [$AdminConfig showAttribute $module targetMappings] 0]
68
69             #---------------------------------------------------------------------------------------
70            # lines 72 to 111 iterate through all targetMappings to get the target
71             #---------------------------------------------------------------------------------------
72             foreach targetMap $targetMaps { 
73                 #------------------------------
74                # get the target
75                 #------------------------------
76                 set target [$AdminConfig showAttribute $targetMap target]
77
78                 #--------------------------------------------------
79                 # do filtering to skip ClusteredTargets  
80                 #--------------------------------------------------
81                 set targetName [lindex [split $target #] 1]
82                if {[regexp "ClusteredTarget" $targetName] != 1} { 
83                     set sName [$AdminConfig showAttribute $target name]
84                     set nName [$AdminConfig showAttribute $target nodeName]
85              
86                     #----------------------------------------------
87                     # do the server name match
88                     #----------------------------------------------
89                     if {$sName == $serverName} {
90                       if {$nName == $nodeName} {
91                 set sameNodeSameServer "true"
92                         } else {
93                 set diffNodeSameServer "true"
94                         }
95                    } else {
96                          #--------------------------------------- 
97                          # do the node name match
98                          #---------------------------------------
99                          if {$nName == $nodeName} {
100                 set sameNodeDiffServer "true"
101                        } else {
102                            set diffNodeDiffServer "true"
103                        }
104                  }
105 
106                  if {$sameNodeSameServer == "true"} {
107                      if {$sameNodeDiffServer == "true" || $diffNodeDiffServer == "true" || 
															$diffNodeSameServer == "true"} {
108                          break
109                      }
110                 }
111            }
112      }
113
114      #---------------------------------------------
115      # put it in the appropriate list
116      #---------------------------------------------   
117      if {$sameNodeSameServer == "true"} {
118          if {$diffNodeDiffServer == "true" || $diffNodeSameServer == "true" || 
						$sameNodeDiffServer == "true"} {
119               set modServerMoreMatch [linsert $modServerMoreMatch end 
							[$AdminConfig showAttribute $module uri]]
120           } else {
121               set modServerMatch [linsert $modServerMatch end [$AdminConfig showAttribute $module uri]]
122          }      
123     } else {
124          set modServerNotMatch [linsert $modServerNotMatch end [$AdminConfig showAttribute $module uri]]
125     }
126  }  
127
128
129  #----------------------------------------------------------------
130  # print the output with some notation as a mark
131  #----------------------------------------------------------------
132  if {$modServerMatch != {} || $modServerMoreMatch != {}} {
133      puts stdout "\tApplication name: $appName"
      134  }
      135
      136  #---------------------------------------------------------
      137  # do grouping to appropriate module and print
      138  #---------------------------------------------------------
      139  if {$modServerMatch != {}} {
      140      filterAndPrint $modServerMatch "+"
      141  }
      142  if {$modServerMoreMatch != {}} {
      143      filterAndPrint $modServerMoreMatch "*"
      144  }
      145  if {($modServerMatch != {} || $modServerMoreMatch != {}) "" $modServerNotMatch != {}} {
      146      filterAndPrint $modServerNotMatch ""
      147  }
      148}
      149
      150   
      151  proc filterAndPrint {lists flag} {
      152     global webList
      153     global ejbList
      154     set webExists "false"
      155     set ejbExists "false"
      156
      157     #--------------------------------------------------------------------------------------
      158     # If list already exists, flag it so as not to print the title more then once
      159     # and reset the list
      160     #---------------------------------------------------------------------------------------
      161     if {$webList != {}} {
      162         set webExists "true"
      163         set webList {}
      164     }   
      165     if {$ejbList != {}} {
      166         set ejbExists "true"
      167         set ejbList {}
      168     }
      169
      170     #------------------------------------------------------------------
      171     # do some filtering for web modules and ejb modules
      172     #------------------------------------------------------------------
      173     foreach list $lists {
      174          set temp [lindex [split $list .] 1]
      175          if {$temp == "war"} {
      176               set webList [linsert $webList end $list]
      177          } elseif {$temp == "jar"} {
      178               set ejbList [linsert $ejbList end $list]
      179          }
      180     }
      181
      182     #---------------------------------------
      183     # sort the list before printing
      184     #---------------------------------------
      185     set webList [lsort -dictionary $webList]
      186     set ejbList [lsort -dictionary $ejbList]
      187
      188     #----------------------------------------------------------------
      189     # print out all the web modules installed in server1
      190     #----------------------------------------------------------------
      191     if {$webList != {}} {
      192         if {$webExists == "false"} {
      193              puts stdout "\t\tWeb Modules:"
      194         }
      195         foreach web $webList {
      196             puts stdout "\t\t\t$web  $flag"
      197         }
      198     }
      199
      200     #--------------------------------------------------------------
      201     # print out all the ejb modules installed in server1
      202     #--------------------------------------------------------------
      203     if {$ejbList != {}} {
      204          if {$ejbExists == "false"} {
      205                puts stdout "\t\tEJB Modules:"
      206          }
      207          foreach ejb $ejbList {
      208                puts stdout "\t\t\t$ejb  $flag"
      209          }
      210     }
      211}
      
Example output for server1 on node node1:
       Application name: TEST1
                EJB Modules:
                        deplmtest.jar  +
                Web Modules:
                        mtcomps.war  *
        Application name: TEST2
                Web Modules:
                        mtcomps.war  +
                EJB Modules:
                        deplmtest.jar  +
        Application name: TEST3
                Web Modules:
                        mtcomps.war  *
                EJB Modules:
                        deplmtest.jar  *
        Application name: TEST4
                EJB Modules:
                        deplmtest.jar  *
                Web Modules:
                        mtcomps.war

指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_listmodule
文件名:txml_listmodule.html