Blame SOURCES/bz1827652-fence_vmware_rest-2-fix-1000-VM-monitor-error.patch

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