Blob Blame History Raw
From a1f988fa0f3f89f8dac17717295c4219a02757cf Mon Sep 17 00:00:00 2001
From: "Fabio M. Di Nitto" <fdinitto@redhat.com>
Date: Sat, 20 Jun 2015 07:45:08 +0200
Subject: [PATCH 1/3] fence_compute: add support for recording fencing
 operations in attrd

This is required to support multiple compute nodes failure at once
with controller node failures happening at the same time.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 fence/agents/compute/fence_compute.py | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/fence/agents/compute/fence_compute.py b/fence/agents/compute/fence_compute.py
index 000aef7..d8a1e95 100644
--- a/fence/agents/compute/fence_compute.py
+++ b/fence/agents/compute/fence_compute.py
@@ -71,6 +71,10 @@ def _host_evacuate(host, on_shared_storage):
 			for server in hyper.servers:
 				response.append(_server_evacuate(server, on_shared_storage))
 
+def set_attrd_status(host, status, options):
+	logging.debug("Setting fencing status for %s to %s" % (host, status))
+	run_command(options, "attrd_updater -p -n evacute -Q -N %s -v %s" % (host, status))
+
 def set_power_status(_, options):
 	global override_status
 
@@ -159,6 +163,15 @@ def define_new_opts():
 		"default" : "",
 		"order": 5,
 	}
+	all_opt["record-only"] = {
+		"getopt" : "",
+		"longopt" : "record-only",
+		"help" : "--record-only                  Record the target as needing evacuation but as yet do not intiate it",
+		"required" : "0",
+		"shortdesc" : "Only record the target as needing evacuation",
+		"default" : "False",
+		"order": 5,
+	}
 	all_opt["no-shared-storage"] = {
 		"getopt" : "",
 		"longopt" : "no-shared-storage",
@@ -175,7 +188,8 @@ def main():
 	atexit.register(atexit_handler)
 
 	device_opt = ["login", "passwd", "tenant-name", "auth-url",
-		"no_login", "no_password", "port", "domain", "no-shared-storage", "endpoint-type"]
+		"no_login", "no_password", "port", "domain", "no-shared-storage", "endpoint-type",
+		"record-only"]
 	define_new_opts()
 	all_opt["shell_timeout"]["default"] = "180"
 
@@ -199,6 +213,18 @@ def main():
 	if options["--action"] != "list" and options["--domain"] != "" and options.has_key("--plug"):
 		options["--plug"] = options["--plug"] + "." + options["--domain"]
 
+	if options["--record-only"] != "False":
+		if options["--action"] == "on":
+			set_attrd_status(options["--plug"], "no", options)
+			sys.exit(0)
+
+		elif options["--action"] in ["off", "reboot"]:
+			set_attrd_status(options["--plug"], "yes", options)
+			sys.exit(0)
+
+		elif options["--action"] in ["status", "monitor"]:
+			sys.exit(0)
+
 	# The first argument is the Nova client version
 	nova = nova_client.Client('2',
 		options["--username"],
-- 
1.9.3