86a3dd56d6
- fence_brocade: Add support for 'list' action - fencing: Monitor is not working correctly without 'list' or 'status' - fence_apc_snmp: Add support for firmware 6.x - fence_zvm: Add support for "on" and "status" - fence_zvm: Add current XML metadata to test suite - [build] Fix automake files, so 'make distcheck' works - fencing: Add new options --ssl-secure and --ssl-insecure - [tests] Update XML metadata of fence agents - fence_cisco_ucs & fence_vmware_soap: Logout has to be performed even when fencing fails - fence_zvm: Fixes for better upstream inclusion - fence_zvm: Add support for 'on', improve documentation - Added patches: - 0001-fence_brocade-Add-support-for-list-action.patch - 0002-fencing-Monitor-is-not-working-correctly-without-lis.patch - 0003-fence_apc_snmp-Add-support-for-firmware-6.x.patch - 0004-fence_zvm-Add-support-for-on-and-status.patch - 0005-fence_zvm-Add-current-XML-metadata-to-test-suite.patch - 0006-build-Fix-automake-files-so-make-distcheck-works.patch - 0007-fencing-Add-new-options-ssl-secure-and-ssl-insecure.patch - 0008-tests-Update-XML-metadata-of-fence-agents.patch - 0009-fence_cisco_ucs-fence_vmware_soap-Logout-has-to-be-p.patch - 0010-fence_zvm-Fixes-for-better-upstream-inclusion.patch - 0011-fence_zvm-Add-support-for-on-improve-documentation.patch - Add dependency on python-requests OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/fence-agents?expand=0&rev=16
172 lines
5.8 KiB
Diff
172 lines
5.8 KiB
Diff
From 65ae2524836e5ba5252fdc800e6276f80fdfac57 Mon Sep 17 00:00:00 2001
|
|
From: Marek 'marx' Grac <mgrac@redhat.com>
|
|
Date: Mon, 8 Sep 2014 15:10:05 +0200
|
|
Subject: [PATCH 09/11] fence_cisco_ucs & fence_vmware_soap: Logout has to be
|
|
performed even when fencing fails
|
|
|
|
Previously, logout was not performed in the case when fence agent was aborted e.g. timeout. What could
|
|
lead to a situation when connections were not closed correctly. In the extreme case, it was not possible
|
|
to log into device at all
|
|
|
|
Resolves: rhbz#1111599
|
|
---
|
|
fence/agents/cisco_ucs/fence_cisco_ucs.py | 35 +++++++++++++++++----------
|
|
fence/agents/vmware_soap/fence_vmware_soap.py | 29 +++++++++++++---------
|
|
2 files changed, 39 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
|
|
index 888d689..f411433 100644
|
|
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
|
|
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
|
|
@@ -19,6 +19,8 @@ RE_STATUS = re.compile("<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
|
|
RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
|
|
RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
|
|
|
|
+options_global = None
|
|
+
|
|
def get_power_status(conn, options):
|
|
del conn
|
|
|
|
@@ -115,27 +117,37 @@ def define_new_opts():
|
|
"default" : "",
|
|
"order" : 1}
|
|
|
|
+def logout():
|
|
+ ### Logout; we do not care about result as we will end in any case
|
|
+ try:
|
|
+ send_command(options_global, "<aaaLogout inCookie=\"" + options_global["cookie"] + "\" />",
|
|
+ int(options_global["--shell-timeout"]))
|
|
+ except Exception:
|
|
+ pass
|
|
+
|
|
def main():
|
|
+ global options_global
|
|
device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg"]
|
|
|
|
atexit.register(atexit_handler)
|
|
+ atexit.register(logout)
|
|
|
|
define_new_opts()
|
|
|
|
- options = check_input(device_opt, process_input(device_opt))
|
|
+ options_global = check_input(device_opt, process_input(device_opt))
|
|
|
|
docs = {}
|
|
docs["shortdesc"] = "Fence agent for Cisco UCS"
|
|
docs["longdesc"] = "fence_cisco_ucs is an I/O Fencing agent which can be \
|
|
used with Cisco UCS to fence machines."
|
|
docs["vendorurl"] = "http://www.cisco.com"
|
|
- show_docs(options, docs)
|
|
+ show_docs(options_global, docs)
|
|
|
|
- run_delay(options)
|
|
+ run_delay(options_global)
|
|
### Login
|
|
try:
|
|
- res = send_command(options, "<aaaLogin inName=\"" + options["--username"] +
|
|
- "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
|
|
+ res = send_command(options_global, "<aaaLogin inName=\"" + options_global["--username"] +
|
|
+ "\" inPassword=\"" + options_global["--password"] + "\" />", int(options_global["--login-timeout"]))
|
|
result = RE_COOKIE.search(res)
|
|
if result == None:
|
|
## Cookie is absenting in response
|
|
@@ -143,22 +155,19 @@ used with Cisco UCS to fence machines."
|
|
except Exception:
|
|
fail(EC_LOGIN_DENIED)
|
|
|
|
- options["cookie"] = result.group(1)
|
|
+ options_global["cookie"] = result.group(1)
|
|
|
|
##
|
|
## Modify suborg to format /suborg
|
|
- if options["--suborg"] != "":
|
|
- options["--suborg"] = "/" + options["--suborg"].lstrip("/").rstrip("/")
|
|
+ if options_global["--suborg"] != "":
|
|
+ options_global["--suborg"] = "/" + options_global["--suborg"].lstrip("/").rstrip("/")
|
|
|
|
##
|
|
## Fence operations
|
|
####
|
|
- result = fence_action(None, options, set_power_status, get_power_status, get_list)
|
|
-
|
|
- ### Logout; we do not care about result as we will end in any case
|
|
- send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />",
|
|
- int(options["--shell-timeout"]))
|
|
+ result = fence_action(None, options_global, set_power_status, get_power_status, get_list)
|
|
|
|
+ ## Logout is done every time at atexit phase
|
|
sys.exit(result)
|
|
|
|
if __name__ == "__main__":
|
|
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
index 3217c6b..2cea105 100644
|
|
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
|
|
@@ -20,6 +20,9 @@ REDHAT_COPYRIGHT=""
|
|
BUILD_DATE="April, 2011"
|
|
#END_VERSION_GENERATION
|
|
|
|
+options_global = None
|
|
+conn_global = None
|
|
+
|
|
class RequestsTransport(HttpAuthenticated):
|
|
def __init__(self, **kwargs):
|
|
self.cert = kwargs.pop('cert', None)
|
|
@@ -203,12 +206,21 @@ def set_power_status(conn, options):
|
|
def remove_tmp_dir(tmp_dir):
|
|
shutil.rmtree(tmp_dir)
|
|
|
|
+def logout():
|
|
+ try:
|
|
+ conn_global.service.Logout(options_global["mo_SessionManager"])
|
|
+ except Exception:
|
|
+ pass
|
|
+
|
|
def main():
|
|
+ global options_global
|
|
+ global conn_global
|
|
device_opt = ["ipaddr", "login", "passwd", "web", "ssl", "notls", "port"]
|
|
|
|
atexit.register(atexit_handler)
|
|
+ atexit.register(logout)
|
|
|
|
- options = check_input(device_opt, process_input(device_opt))
|
|
+ options_global = check_input(device_opt, process_input(device_opt))
|
|
|
|
##
|
|
## Fence agent specific defaults
|
|
@@ -224,7 +236,7 @@ format (e.g. /datacenter/vm/Discovered virtual machine/myMachine). \
|
|
In the cases when name of yours VM is unique you can use it instead. \
|
|
Alternatively you can always use UUID to access virtual machine."
|
|
docs["vendorurl"] = "http://www.vmware.com"
|
|
- show_docs(options, docs)
|
|
+ show_docs(options_global, docs)
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logging.getLogger('suds.client').setLevel(logging.CRITICAL)
|
|
@@ -234,18 +246,11 @@ Alternatively you can always use UUID to access virtual machine."
|
|
##
|
|
## Operate the fencing device
|
|
####
|
|
- conn = soap_login(options)
|
|
+ conn_global = soap_login(options_global)
|
|
|
|
- result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
|
|
-
|
|
- ##
|
|
- ## Logout from system
|
|
- #####
|
|
- try:
|
|
- conn.service.Logout(options["mo_SessionManager"])
|
|
- except Exception:
|
|
- pass
|
|
+ result = fence_action(conn_global, options_global, set_power_status, get_power_status, get_power_status)
|
|
|
|
+ ## Logout from system is done automatically via atexit()
|
|
sys.exit(result)
|
|
|
|
if __name__ == "__main__":
|
|
--
|
|
1.8.4.5
|
|
|