Site icon

Get targets of deployed application in weblogic admin server (WLST)

Get target(s) of deployed application in weblogic (WLST)

def getApplicationTargets(appName):
    newTargets = []

    try:
        cd('AppDeployments/'+appName)
        for t in cmo.getTargets():
            newTargets.append(t.getName())
        cd('/')
    except Exception, e:
        pass
    return newTargets

connect("myAdmin","mypassword","myAdminServer:7001")


#Enter the Application name
appName = 'myDeployedApp'
targets=getApplicationTargets(appName)

if len(targets) == 0:
    print ('Application ' + appName + ' does not contain any target')
else:
    print ('Application ' + appName + ' has targets :' + ''.join(targets))
disconnect()

Output: get targets of deployed application in weblogic server

c:\fmw_12.2.1.3.0\wls12213\wlserver\server\bin>setWLSEnv.cmd

CLASSPATH="c:\PROGRA~1\Java\JDK18~1.0_1\lib\tools.jar;
c:\FMW_12~1.0\wls12213\wlserver\modules\features\wlst.wls.classpath.jar;
c:\PROGRA~1\Java\JDK18~1.0_1\lib\tools.jar;
c:\FMW_12~1.0\wls12213\wlserver\modules\features\WLSTWL~1.JAR;
c:\PROGRA~1\Java\JDK18~1.0_1\lib\tools.jar;
c:\FMW_12~1.0\wls12213\wlserver\modules\features\WLSTWL~1.JAR"

PATH="c:\FMW_12~1.0\wls12213\wlserver\server\native\win\x64;
c:\FMW_12~1.0\wls12213\wlserver\server\bin;
c:\FMW_12~1.0\wls12213\ORACLE~1\modules\THIRDP~1\ORGAPA~1.ANT\1980~1.0\APACHE~1.8\bin;
c:\PROGRA~1\Java\JDK18~1.0_1\jre\bin;c:\PROGRA~1\Java\JDK18~1.0_1\bin;
C:\PROGRA~2\COMMON~1\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;
C:\Windows\System32\wbem;C:\Windows\System32\WINDOW~1\v1.0\;
C:\Windows\System32\OpenSSH\;C:\PROGRA~1\PuTTY\;
c:\FMW_12~1.0\wls12213\ORACLE~1\modules\ORGAPA~1.5\bin;
c:\FMW_12~1.0\wls12213\ORACLE~1\modules\ORGAPA~1.5\bin;
c:\FMW_12~1.0\wls12213\oracle_common\modules\org.apache.maven_3.2.5\bin"
Your environment has been set.

c:\fmw_12.2.1.3.0\wls12213\oracle_common\common\bin>wlst.cmd d:\weblogic\getTargetsOfApps.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://slc07fic.us.oracle.com:7001 with userid weblogic ...
Successfully connected to Admin Server "AdminServer" that belongs to domain "my_domain".

Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

Application myDeployedApp has targets :AdminServer, myCluster
Disconnected from weblogic server: AdminServer
Exit mobile version