Blame SOURCES/bz1214359-5-fence_compute.patch

55aad9
From a1f988fa0f3f89f8dac17717295c4219a02757cf Mon Sep 17 00:00:00 2001
55aad9
From: "Fabio M. Di Nitto" <fdinitto@redhat.com>
55aad9
Date: Sat, 20 Jun 2015 07:45:08 +0200
55aad9
Subject: [PATCH 1/3] fence_compute: add support for recording fencing
55aad9
 operations in attrd
55aad9
55aad9
This is required to support multiple compute nodes failure at once
55aad9
with controller node failures happening at the same time.
55aad9
55aad9
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
55aad9
---
55aad9
 fence/agents/compute/fence_compute.py | 28 +++++++++++++++++++++++++++-
55aad9
 1 file changed, 27 insertions(+), 1 deletion(-)
55aad9
55aad9
diff --git a/fence/agents/compute/fence_compute.py b/fence/agents/compute/fence_compute.py
55aad9
index 000aef7..d8a1e95 100644
55aad9
--- a/fence/agents/compute/fence_compute.py
55aad9
+++ b/fence/agents/compute/fence_compute.py
55aad9
@@ -71,6 +71,10 @@ def _host_evacuate(host, on_shared_storage):
55aad9
 			for server in hyper.servers:
55aad9
 				response.append(_server_evacuate(server, on_shared_storage))
55aad9
 
55aad9
+def set_attrd_status(host, status, options):
55aad9
+	logging.debug("Setting fencing status for %s to %s" % (host, status))
55aad9
+	run_command(options, "attrd_updater -p -n evacute -Q -N %s -v %s" % (host, status))
55aad9
+
55aad9
 def set_power_status(_, options):
55aad9
 	global override_status
55aad9
 
55aad9
@@ -159,6 +163,15 @@ def define_new_opts():
55aad9
 		"default" : "",
55aad9
 		"order": 5,
55aad9
 	}
55aad9
+	all_opt["record-only"] = {
55aad9
+		"getopt" : "",
55aad9
+		"longopt" : "record-only",
55aad9
+		"help" : "--record-only                  Record the target as needing evacuation but as yet do not intiate it",
55aad9
+		"required" : "0",
55aad9
+		"shortdesc" : "Only record the target as needing evacuation",
55aad9
+		"default" : "False",
55aad9
+		"order": 5,
55aad9
+	}
55aad9
 	all_opt["no-shared-storage"] = {
55aad9
 		"getopt" : "",
55aad9
 		"longopt" : "no-shared-storage",
55aad9
@@ -175,7 +188,8 @@ def main():
55aad9
 	atexit.register(atexit_handler)
55aad9
 
55aad9
 	device_opt = ["login", "passwd", "tenant-name", "auth-url",
55aad9
-		"no_login", "no_password", "port", "domain", "no-shared-storage", "endpoint-type"]
55aad9
+		"no_login", "no_password", "port", "domain", "no-shared-storage", "endpoint-type",
55aad9
+		"record-only"]
55aad9
 	define_new_opts()
55aad9
 	all_opt["shell_timeout"]["default"] = "180"
55aad9
 
55aad9
@@ -199,6 +213,18 @@ def main():
55aad9
 	if options["--action"] != "list" and options["--domain"] != "" and options.has_key("--plug"):
55aad9
 		options["--plug"] = options["--plug"] + "." + options["--domain"]
55aad9
 
55aad9
+	if options["--record-only"] != "False":
55aad9
+		if options["--action"] == "on":
55aad9
+			set_attrd_status(options["--plug"], "no", options)
55aad9
+			sys.exit(0)
55aad9
+
55aad9
+		elif options["--action"] in ["off", "reboot"]:
55aad9
+			set_attrd_status(options["--plug"], "yes", options)
55aad9
+			sys.exit(0)
55aad9
+
55aad9
+		elif options["--action"] in ["status", "monitor"]:
55aad9
+			sys.exit(0)
55aad9
+
55aad9
 	# The first argument is the Nova client version
55aad9
 	nova = nova_client.Client('2',
55aad9
 		options["--username"],
55aad9
-- 
55aad9
1.9.3
55aad9