Skip to content

Commit

Permalink
This avoids a failure when power on is used with HP iLO and DRAC.
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Alvarez-Valle <javier.alvarez-valle@citrix.com>
  • Loading branch information
Javier Alvarez-Valle committed Jul 8, 2010
1 parent ef317b7 commit 1153db2
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions scripts/poweron/power-on.py
Expand Up @@ -15,6 +15,20 @@ def __init__(self, *args):
Exception.__init__(self, *args)


def waitForXapi(session,host):
attempts = 0
finished = False
metrics = None
while not finished and (attempts < 120):
attempts = attempts + 1
time.sleep(5)
metrics = session.xenapi.host.get_metrics(host)
try:
finished = session.xenapi.host_metrics.get_live(metrics)
except:
pass
return str(finished)


def main(session, args):
remote_host_uuid = args['remote_host_uuid']
Expand All @@ -33,20 +47,21 @@ def main(session, args):
secret = power_on_config['power_on_password_secret']
secretref=session.xenapi.secret.get_by_uuid(secret)
password = session.xenapi.secret.get_value(secretref)

if mode == "iLO":
modu= __import__('iLO')
return modu.iLO( ip, user, password)
modu.iLO( ip, user, password)
else:
modu= __import__('DRAC')
return modu.DRAC(ip, user, password)
modu.DRAC( ip, user, password)
return waitForXapi(session,remote_host)
elif mode=="wake-on-lan":
modu= __import__('wlan')
return modu.wake_on_lan(session, remote_host, remote_host_uuid)
# Custom script
elif mode!="":
modu= __import__(mode)
return modu.custom(session,remote_host,power_on_config)
modu.custom(session,remote_host,power_on_config)
return waitForXapi(session,remote_host)
# Disabled
else:
raise HOST_POWER_ON_NOT_CONFIGURED()
Expand Down

0 comments on commit 1153db2

Please sign in to comment.