[Cluster-devel] [PATCH 2/7] COMPATIBILITY BREAK: fence_drac5 replace --m / --modulename / modulename / module_name with standard -n / --plug / port

Marek 'marx' Grac mgrac at redhat.com
Sun Nov 25 13:18:05 UTC 2012


This change apply to you only if you use fence agent against DRAC CMC, other DRACs are bound to one machine, so they
do not use this option at all. Device option no_port (no port is needed) was added, previously modulename was optional
and this is not true with 'port' option by default.
---
 fence/agents/drac5/fence_drac5.py |   10 ++++----
 fence/agents/lib/fencing.py.py    |   41 ++++++++----------------------------
 2 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 09157fe..8560c39 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -24,7 +24,7 @@ BUILD_DATE="March, 2008"
 
 def get_power_status(conn, options):
 	if options["model"] == "DRAC CMC":
-		conn.send_eol("racadm serveraction powerstatus -m " + options["--module-name"])
+		conn.send_eol("racadm serveraction powerstatus -m " + options["--plug"])
 	elif options["model"] == "DRAC 5":
 		conn.send_eol("racadm serveraction powerstatus")
 		
@@ -43,7 +43,7 @@ def set_power_status(conn, options):
 	}[options["--action"]]
 
 	if options["model"] == "DRAC CMC":
-		conn.send_eol("racadm serveraction " + action + " -m " + options["--module-name"])
+		conn.send_eol("racadm serveraction " + action + " -m " + options["--plug"])
 	elif options["model"] == "DRAC 5":
 		conn.send_eol("racadm serveraction " + action)
 	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
@@ -79,7 +79,7 @@ def define_new_opts():
 
 def main():
 	device_opt = [  "ipaddr", "ipport", "login", "passwd", "cmd_prompt", "secure", \
-			"drac_version", "module_name" ]
+			"drac_version", "port", "no_port" ]
 
 	atexit.register(atexit_handler)
 
@@ -105,8 +105,8 @@ By default, the telnet interface is not  enabled."
 	conn = fence_login(options)
 
 	if conn.before.find("CMC") >= 0:
-		if 0 == options.has_key("--module-name") and 0 == ["monitor", "list"].count(options["--action"].lower()):
-			fail_usage("Failed: You have to enter module name (-m)")
+		if 0 == options.has_key("--plug") and 0 == ["monitor", "list"].count(options["--action"].lower()):
+			fail_usage("Failed: You have to enter module name (-n)")
 			
 		options["model"] = "DRAC CMC"
 	elif conn.before.find("DRAC 5") >= 0:
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0736f91..a9bc0b4 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -120,6 +120,10 @@ all_opt = {
 		"getopt" : "",
 		"help" : "",
 		"order" : 1 },
+	"no_port" : {
+		"getopt" : "",
+		"help" : "",
+		"order" : 1 },
 	"passwd" : {
 		"getopt" : "p:",
 		"longopt" : "password",
@@ -141,13 +145,6 @@ all_opt = {
 		"required" : "0",
 		"shortdesc" : "Identity file for ssh",
 		"order" : 1 },
-	"module_name" : {
-		"getopt" : "m:",
-		"longopt" : "module-name",
-		"help" : "-m, --module-name=<module>     DRAC/MC module name",
-		"required" : "0",
-		"shortdesc" : "DRAC/MC module name",
-		"order" : 1 },
 	"drac_version" : {
 		"getopt" : "d:",
 		"longopt" : "drac-version",
@@ -186,8 +183,8 @@ all_opt = {
 	"port" : {
 		"getopt" : "n:",
 		"longopt" : "plug",
-		"help" : "-n, --plug=<id>                Physical plug number on device, \n" + 
-        "                                        name of virtual machine or UUID",
+		"help" : "-n, --plug=<id>                Physical plug number on device, UUID or \n" + 
+        "                                        identification of machine",
 		"required" : "1",
 		"shortdesc" : "Physical plug number, name of virtual machine or UUID",
 		"order" : 1 },
@@ -545,11 +542,6 @@ def process_input(avail_opt):
 			else:
 				longopt_list.append(all_opt[k]["longopt"])
 
-	## Compatibility layer
-	if avail_opt.count("module_name") == 1:
-		getopt_string += "n:"
-		longopt_list.append("plug=")
-	
 	##
 	## Read options from command line or standard input
 	#####
@@ -574,16 +566,6 @@ def process_input(avail_opt):
 						("-" + all_opt[x]["getopt"] == o or "-" + all_opt[x]["getopt"].rstrip(":") == o):
 						opt["--" + all_opt[x]["longopt"]] = dict(old_opt)[o]
 				opt[o] = dict(old_opt)[o]
-
-		## Compatibility Layer
-		#####
-		z = dict(opt)
-		if z.has_key("--plug") == 1:
-			z["-m"] = z["--plug"]
-
-		opt = z
-		##
-		#####
 	else:
 		opt = { }
 		name = ""
@@ -605,10 +587,6 @@ def process_input(avail_opt):
 				name = "port"
 			elif name == "hostname":
 				name = "ipaddr"
-			elif name == "modulename":
-				name = "module_name"
-			elif name == "port" and 1 == avail_opt.count("drac_version"):
-				name = "module_name"
 
 			##
 			######
@@ -714,8 +692,8 @@ def check_input(device_opt, opt):
 			fail_usage("Failed: Identity file " + options["--identity-file"] + " does not exist")
 
 	if (0 == ["list", "monitor"].count(options["--action"].lower())) and \
-		0 == options.has_key("--plug") and device_opt.count("port"):
-		fail_usage("Failed: You have to enter plug number")
+		0 == options.has_key("--plug") and device_opt.count("port") and device_opt.count("no_port") == 0:
+		fail_usage("Failed: You have to enter plug number or machine identification")
 
 	if options.has_key("--password-script"):
 		options["--password"] = os.popen(options["--password-script"]).read().rstrip()
@@ -782,8 +760,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 		## Process options that manipulate fencing device
 		#####
 		if (options["--action"] == "list") and \
-			0 == options["device_opt"].count("port") and 0 == options["device_opt"].count("partition") and \
-			0 == options["device_opt"].count("module_name"):
+			0 == options["device_opt"].count("port") and 0 == options["device_opt"].count("partition"):
 			print "N/A"
 			return
 		elif (options["--action"] == "list" and get_outlet_list == None):
-- 
1.7.7.6




More information about the Cluster-devel mailing list