

execfile('common.py')

nmProps = domain_dir +'/nodemanager/nodemanager.properties'

print "Starting nodemanager..."
startNodeManager(block='true', timeout=30000, PropertiesFile=nmProps, 
  NodeManagerHome=domain_dir+"/nodemanager",
  username=username, password=passwd,domainName=domain_name,domainDir=domain_dir)

adminprops = makePropertiesObject("Username="+username+";Password="+passwd)
print "Admin Props" + str(adminprops)

serverprops = makePropertiesObject("AdminURL="+serverURL+";Username="+username+";Password="+passwd)
print "MS Props" + str(serverprops)

def startServer(serverName, startprops):
  try:
    print "Starting " + str(serverName)
    nmStart(serverName,domainDir=domain_name,props=startprops)
  except:
    print "could not start " + str(serverName)

nmConnect(username,passwd,domainName=domain_name)

startServer(adminName, adminprops)
startServer("DynamicCluster-1", serverprops)
startServer("DynamicCluster-2", serverprops)

nmDisconnect()

connectToServer()

print "Starting OTD instance"
try:
  start(otdInstance,"SystemComponent")
except:
  print ""
  print "Error starting " + otdInstance + ", likely already running or not yet configured"
  print ""
