fence-agents/bz1827652-fence_vmware_rest-2-fix-1000-VM-monitor-error.patch

77 lines
3.1 KiB
Diff
Raw Normal View History

From 0296bc8512e37b8b935bc342b6493ed4fa8aa001 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 14 May 2020 13:17:04 +0200
Subject: [PATCH 1/2] fence_vmware_rest: fix exception and remove default value
for filter parameter (which was shown in the manpage)
---
agents/vmware_rest/fence_vmware_rest.py | 3 +--
tests/data/metadata/fence_vmware_rest.xml | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/agents/vmware_rest/fence_vmware_rest.py b/agents/vmware_rest/fence_vmware_rest.py
index 6daff121..2635ae07 100644
--- a/agents/vmware_rest/fence_vmware_rest.py
+++ b/agents/vmware_rest/fence_vmware_rest.py
@@ -46,7 +46,7 @@ def get_list(conn, options):
if "--filter" in options:
command = command + "?" + options["--filter"]
res = send_command(conn, command)
- except:
+ except Exception as e:
logging.debug("Failed: {}".format(e))
fail(EC_STATUS)
@@ -165,7 +165,6 @@ def define_new_opts():
"longopt" : "filter",
"help" : "--filter=[filter] Filter to only return relevant VMs"
" (e.g. \"filter.names=node1&filter.names=node2\").",
- "default" : "",
"required" : "0",
"shortdesc" : "Filter to only return relevant VMs. It can be used to avoid "
"the agent failing when more than 1000 VMs should be returned.",
diff --git a/tests/data/metadata/fence_vmware_rest.xml b/tests/data/metadata/fence_vmware_rest.xml
index d60c8775..830b6a21 100644
--- a/tests/data/metadata/fence_vmware_rest.xml
+++ b/tests/data/metadata/fence_vmware_rest.xml
@@ -91,7 +91,7 @@ NOTE: If there's more than 1000 VMs there is a filter parameter to work around t
</parameter>
<parameter name="filter" unique="0" required="0">
<getopt mixed="--filter=[filter]" />
- <content type="string" default="" />
+ <content type="string" />
<shortdesc lang="en">Filter to only return relevant VMs. It can be used to avoid the agent failing when more than 1000 VMs should be returned.</shortdesc>
</parameter>
<parameter name="quiet" unique="0" required="0">
From 7420cf9f11568be7239956bed4631cdbaa6fb87c Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 14 May 2020 14:17:03 +0200
Subject: [PATCH 2/2] fence_vmware_rest: dont fail when receiving more than
1000 VM error during monitor-action
---
agents/vmware_rest/fence_vmware_rest.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/agents/vmware_rest/fence_vmware_rest.py b/agents/vmware_rest/fence_vmware_rest.py
index 2635ae07..675de246 100644
--- a/agents/vmware_rest/fence_vmware_rest.py
+++ b/agents/vmware_rest/fence_vmware_rest.py
@@ -48,7 +48,14 @@ def get_list(conn, options):
res = send_command(conn, command)
except Exception as e:
logging.debug("Failed: {}".format(e))
- fail(EC_STATUS)
+ if str(e).startswith("400"):
+ if options.get("--original-action") == "monitor":
+ return outlets
+ else:
+ logging.error("More than 1000 VMs returned. Use --filter parameter to limit which VMs to list.")
+ fail(EC_STATUS)
+ else:
+ fail(EC_STATUS)
for r in res["value"]:
outlets[r["name"]] = ("", state[r["power_state"]])