2

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

Brett Kail
  • 33,593
  • 2
  • 85
  • 90
  • Are you using WAS ND (with multiple servers in cell, possibly with clusters) or just WAS BASE/EXPRESS? For BASE/EXPRESS you can simply skip 'process' attribute in your query. If it's ND, then the answer isn't going to be that trivial. – Marcin Płonka Jul 25 '14 at 20:55
  • I use WAS ND with multiple server in cell but not clustering. Thanks – Jean-Christoph Jul 27 '14 at 08:30

2 Answers2

1

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
Threadicide
  • 126
  • 7
  • Perhaps I don't understand, you search which server stopped. I try to start an application, for that I need to find out the name of the server, the server is allready started. Therefore, this piece of code sound great, I'll test it. – Jean-Christoph Jul 28 '14 at 15:27
0

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