Monday, October 6, 2014

To get TARGETS for application deployed on Weblogic using WLST

This function will return the list of Targets on which application has been deployed. 
It will take application name as the input parameter (i.e. APPNAME). 
It is using regular expression to extract server name or cluster name from the string. 
The FOR loop will run for each cluster/server. 
You need to import below classes for this function to work:

import re
import java.util.ArrayList as ArrayList

So the function will look like below:

def Target(APPNAME):
    try:
        print('#######################################################')
        print('Below are the Targets for '), APPNAME
        print('#######################################################')
        cd('AppDeployments/'+APPNAME)
        arr = ArrayList()
        arr=get('Targets')
        for myStr in arr:
            m = re.search('=(\w+),', str(myStr))
            print m.group(1)
        print('#######################################################')
    except Exception, e:
        print('Exception is ')
        print e
        dumpStack()
        raise

Sample Output:

#######################################################
Below are the Targets for  ServerState
#######################################################
SOA_MngdSvr1
SOA_MngdSvr2
#######################################################
.
.
.
.
#######################################################
Below are the Targets for  ServerState
#######################################################
B2B_Cluster
BAM_Cluster
SOA_Cluster
#######################################################

No comments:

Post a Comment