Example: Listing the modules in an appserver


 

+

Search Tips   |   Advanced Search

 

This example lists all of the modules on all of the enterprise applications that are installed on the server1 server in a node named node1.

An asterisk (*) means that the module is installed on server1 and node1 and another server or node. A plus sign (+) means that the module is installed on server1 and node1 only.

 
####
#### listModulesA.jacl
####
#### ./wsadmin.bat -user wasadmin -password wasadmin -f ./listModulesA.py
####
#
#
#### Set up variables to keep server name and node name 
#### set serverName  server1  set nodeName  Michael-DellNode01  puts "Hello"


### Set up 2 global lists to keep the modules
 set ejbList {} set webList {}


### Get all deployment objects and assigned it to deployments variable

 set deployments [$AdminConfig getid /Deployment:/]


### Iterate through all the deployment objects to get the modules
### and perform filtering to list application that has at least one module installed
### in server1 in node myNode
 foreach deployment $deployments {

   ### Reset the lists that hold modules for each application 
   set webList {}
   set ejbList {}

   
   ### Get the application name
   
   set appName [lindex [split $deployment (] 0]

   
   ### Get the deployedObjects
   
   set depObject [$AdminConfig showAttribute $deployment deployedObject]

   
   ### Get all modules in the application 42     #
   set modules [lindex [$AdminConfig showAttribute $depObject modules] 0] 

   
   ### Initialize lists to save all the modules in the appropriate list to where they belong
   
   set modServerMatch {}  
   set modServerMoreMatch {}
   set modServerNotMatch {}

       
       ### Iterate through all modules to get the targetMappings
       
       foreach module $modules {
           
           ### Set up some flag to do some filtering and get modules for server1 on node1 
           
           set sameNodeSameServer "false"
           set diffNodeSameServer "false"
           set sameNodeDiffServer "false"
           set diffNodeDiffServer "false"

           
           ### Get the targetMappings
           
           set targetMaps [lindex [$AdminConfig showAttribute $module targetMappings] 0]

           
           ### Iterate through all targetMappings to get the target
           
           foreach targetMap $targetMaps { 

               ### Get the target
               set target [$AdminConfig showAttribute $targetMap target]

               
               ### Do filtering to skip ClusteredTargets  
               
               set targetName [lindex [split $target ###] 1]
               if {[regexp "ClusteredTarget" $targetName] != 1} { 
                   set sName [$AdminConfig showAttribute $target name]
                   set nName [$AdminConfig showAttribute $target nodeName]
            
                   
                   ### do the server name match
                   
                   if {$sName == $serverName} {
                     if {$nName == $nodeName} {
                         set sameNodeSameServer "true"
                       } else {
                         set diffNodeSameServer "true"
                       }
                  } else {
                        
                        ### do the node name match
                        
                        if {$nName == $nodeName} {
                            set sameNodeDiffServer "true"
                      } else {
                          set diffNodeDiffServer "true"
                      }
                }

                if {$sameNodeSameServer == "true"} {
                    if {$sameNodeDiffServer == "true" || $diffNodeDiffServer == "true" || 
                         $diffNodeSameServer == "true"} {
                        break
                    }
               }
          }
    }

    
    ### Put it in the appropriate list
    
    if {$sameNodeSameServer == "true"} {
        if {$diffNodeDiffServer == "true" || $diffNodeSameServer == "true" || $sameNodeDiffServer == "true"} {
             set modServerMoreMatch [linsert $modServerMoreMatch end [$AdminConfig showAttribute $module uri]]
         } else {
             set modServerMatch [linsert $modServerMatch end [$AdminConfig showAttribute $module uri]]
        }      
   } else {
        set modServerNotMatch [linsert $modServerNotMatch end [$AdminConfig showAttribute $module uri]]
   }
}  



### Print the output with some notation as a mark
 if {$modServerMatch != {} || $modServerMoreMatch != {}} {
    puts stdout "\tApplication name: $appName"
}


### Do grouping to appropriate module and print

#if {$modServerMatch != {}} {
#    filterAndPrint $modServerMatch "+"
#}
#if {$modServerMoreMatch != {}} {
#    filterAndPrint $modServerMoreMatch "*"
#}
#if {($modServerMatch != {} || $modServerMoreMatch != {}) "" $modServerNotMatch != {}} {
#    filterAndPrint $modServerNotMatch ""
#}
}

  proc filterAndPrint {lists flag} {
   global webList
   global ejbList
   set webExists "false"
   set ejbExists "false"


   ### If list already exists, flag it so as not to print the title more then once
   ### and reset the list

#   if {$webList != {}} {
#       set webExists "true"
#       set webList {}
#   }   
#   if {$ejbList != {}} {
#       set ejbExists "true"
#       set ejbList {}
#   }
#
#   
#   ### Do some filtering for web modules and ejb modules
#  
#   foreach list $lists {
#        set temp [lindex [split $list .] 1]
#        if {$temp == "war"} {
#             set webList [linsert $webList end $list]
#        } elseif {$temp == "jar"} {
#             set ejbList [linsert $ejbList end $list]
#        }
#   }
#
#   
#   ### Sort the list before printing
#   
#   set webList [lsort -dictionary $webList]
#   set ejbList [lsort -dictionary $ejbList]
#
#   
#   ### Print out all the web modules installed in server1 
#   
#   if {$webList != {}} {
#       if {$webExists == "false"} {
#            puts stdout "\t\tWeb Modules:"
#       }
#       foreach web $webList {
#           puts stdout "\t\t\t$web  $flag"
#       }
#   }
#
#   
#   ### Print out all the ejb modules installed in server1 
#   
#   if {$ejbList != {}} {
#        if {$ejbExists == "false"} {
#              puts stdout "\t\tEJB Modules:"
#        }
#        foreach ejb $ejbList {
#              puts stdout "\t\t\t$ejb  $flag"
#        }
#   }
}
       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




 

Related tasks


Listing the modules in an installed application with scripting