Jean-Christoph
Jean-Christoph

Reputation: 21

wsadmin obtain server name of an application stopped

This is my first question and I think this is not the last.

for start a application with wsadmin I need the name of the server.

    appManager = AdinControl.completeObjectName('type=ApplicationManager,process='+serverName+',*')
    AdminControl.invoke(appManager,'startApplication',myAppName)

I know how to obtain the name server when the application is started but not when is stopped.

Could you help me please.

Best regards Jean-Christophe

Upvotes: 2

Views: 3607

Answers (2)

Jean-Christoph
Jean-Christoph

Reputation: 21

I think that I've find a solution, but I don't know if its works with dmgr (I'm on holiday, I've tested with WAS 8.5.5 trial version). I've understood that AdminControl works with active applications objects, therefore my first test can't works to start my application.

app = raw_input("Donner le nom de l'application a demarree: ")

print "recuperation du nom de server"
mods = AdminApp.listModules(app,'-server')
( name, module, server ) = mods.split( '#' )
serverName = server.split( '=' ) [ -1 ] #quite ugly, If you have best solution, I take

appManager= AdminControl.completeObjectName('type=ApplicationManager,process='+serverName+',*')

print "Demarrage d'une application :"
AdminControl.invoke(appManager,'startApplication',app)

Thanks for your help Best regards Jean-Christophe

Upvotes: 0

Threadicide
Threadicide

Reputation: 126

Consider the code below. This uses clusters and searches every server, but could be modified for your situation. You could modify the first block to only look for servers within one app.

# Get a list of all valid servers
cell=AdminConfig.list('Cell')
cellName=AdminConfig.showAttribute(cell, 'name')
clusterID=AdminConfig.getid('/ServerCluster:<My Cluster>/')
clusterList=AdminConfig.list('ClusterMember', clusterID)

servers=clusterList.split("\n")

# For each server check if its running using completeObjectName
#   If it returns null its a valid server name, the server just isn't running
#   If it returns info its running.
for serverID in servers:
   serverName=AdminConfig.showAttribute(serverID, 'memberName')
   nodeName=AdminConfig.showAttribute(serverID, 'nodeName')
   aServer=AdminControl.completeObjectName('cell=' + cellName + ',node=' + nodeName + ',name=' + serverName + ',type=Server,*')
   if (aServer != ""):
      aState=AdminControl.getAttribute(aServer, 'state')
   else:
      aState="STOPPED"
      # Since this server is not running write code here to start it.
   print "Server", serverName, "is in a", aSt

Upvotes: 1

Related Questions