Чтобы точно определить, частично ли запущено / остановлено приложение, необходимо сначала определить цели развертывания, на которых развернуто приложение, а затем определить, работает ли приложение на этом сервере:
def isApplicationRunning(applicationName, serverName, nodeName) :
return AdminControl.completeObjectName("type=Application,name=%s,process=%s,node=%s,*" % (applicationName, serverName, nodeName)) != ""
def printApplicationStatus(applicationName) :
servers = started = 0
targets = AdminApplication.getAppDeploymentTarget(applicationName)
for target in targets :
type = AdminConfig.getObjectType(target)
if (type == "ClusteredTarget") :
clusterName = AdminConfig.showAttribute(target, "name")
members = AdminUtilities.convertToList(AdminConfig.getid("/ServerCluster:%s/ClusterMember:/" % clusterName))
for member in members :
serverName = AdminConfig.showAttribute(target, "name")
nodeName = AdminConfig.showAttribute(member, "nodeName")
started += isApplicationRunning(applicationName, serverName, nodeName)
servers += 1
elif (type == "ServerTarget") :
serverName = AdminConfig.showAttribute(target, "name")
nodeName = AdminConfig.showAttribute(target, "nodeName")
started += isApplicationRunning(applicationName, serverName, nodeName)
servers += 1
if (started == 0) :
print "The application [%s] is NOT RUNNING." % applicationName
elif (started != servers) :
print "The application [%s] is PARTIALLY RUNNING." % applicationName
else :
print "The application [%s] is RUNNING." % applicationName
if (__name__ == "__main__"):
printApplicationStatus(sys.argv[0]);
Обратите внимание, что библиотека сценариев AdminApplication
существует только для WAS 7+, поэтому, если вы используете более старую версию, вам нужно будет самостоятельно получить цели развертывания.