fence-agents: master - fence_ovh: Fix problems according to patch in mailing list.
Marek GrĂ¡c
marx at fedoraproject.org
Mon May 5 10:29:48 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=12b0210e50cef44bbea4857b0d147990173946e5
Commit: 12b0210e50cef44bbea4857b0d147990173946e5
Parent: 745a14e0df001a41835ca8def53a9580154d158d
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Mon Apr 28 16:52:35 2014 +0200
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Mon May 5 12:03:32 2014 +0200
fence_ovh: Fix problems according to patch in mailing list.
---
fence/agents/ovh/fence_ovh.py | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index a705913..7ada388 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -35,9 +35,7 @@ def define_new_opts():
"default" : "",
"order" : 1}
-def netboot_reboot(options, mode):
- conn = soap_login(options)
-
+def netboot_reboot(conn, options, mode):
# dedicatedNetbootModifyById changes the mode of the next reboot
conn.service.dedicatedNetbootModifyById(options["session"], options["--plug"], mode, '', options["--email"])
@@ -47,17 +45,13 @@ def netboot_reboot(options, mode):
conn.logout(options["session"])
-def reboot_time(options):
- conn = soap_login(options)
-
+def reboot_time(conn, options):
result = conn.service.dedicatedHardRebootStatus(options["session"], options["--plug"])
tmpstart = datetime.strptime(result.start, '%Y-%m-%d %H:%M:%S')
tmpend = datetime.strptime(result.end, '%Y-%m-%d %H:%M:%S')
result.start = tmpstart
result.end = tmpend
- conn.logout(options["session"])
-
return result
def soap_login(options):
@@ -109,6 +103,8 @@ Poweroff is simulated with a reboot into rescue-pro mode."
if not options.has_key("--email"):
fail_usage("You have to enter e-mail address which is notified by fence agent")
+ conn = soap_login(options)
+
# Save datetime just before changing netboot
before_netboot_reboot = datetime.now()
@@ -116,18 +112,18 @@ Poweroff is simulated with a reboot into rescue-pro mode."
if options["--action"] == 'off':
# Reboot in Rescue-pro
- netboot_reboot(options, OVH_RESCUE_PRO_NETBOOT_ID)
+ netboot_reboot(conn, options, OVH_RESCUE_PRO_NETBOOT_ID)
time.sleep(STATUS_RESCUE_PRO_SLEEP)
elif options["--action"] in ['on', 'reboot']:
# Reboot from HD
- netboot_reboot(options, OVH_HARD_DISK_NETBOOT_ID)
+ netboot_reboot(conn, options, OVH_HARD_DISK_NETBOOT_ID)
time.sleep(STATUS_HARD_DISK_SLEEP)
# Save datetime just after reboot
after_netboot_reboot = datetime.now()
# Verify that action was completed sucesfully
- reboot_t = reboot_time(options)
+ reboot_t = reboot_time(conn, options)
logging.debug("reboot_start_end.start: %s\n",
reboot_t.start.strftime('%Y-%m-%d %H:%M:%S'))
@@ -145,6 +141,11 @@ Poweroff is simulated with a reboot into rescue-pro mode."
result = 1
logging.debug("ERROR: Netboot reboot wasn't OK.\n")
+ try:
+ conn.service.logout(options["session"])
+ except Exception:
+ pass
+
sys.exit(result)
if __name__ == "__main__":
More information about the cluster-commits
mailing list