I have two WLST queries. I execute it through WebLogic Scripting Tool console. These queries are:
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;
Output example:
2) List of hosts-machines
connect('weblogic','password','t3://localhost:7001')
svrs = cmo.getServers()
domainRuntime()
for host in svrs:
machine = host.getMachine();
print "Host: " + machine.getName()
Output example:
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.
The output needed is something like that:
Thanks in advance.
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.