Skip to contentSkip to conversation

fence agents: Transfer non-SNMP fence agents to long-opts

PATCH New Marek 'marx' Grac 1 participant 2 messages Nov 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 fence agents: Transfer non-SNMP fence agents to long-opts

---
 fence/agents/alom/fence_alom.py               |    8 ++--
 fence/agents/apc/fence_apc.py                 |   70 ++++++++++++------------
 fence/agents/bladecenter/fence_bladecenter.py |   30 +++++-----
 fence/agents/cisco_ucs/fence_cisco_ucs.py     |   18 +++---
 fence/agents/drac5/fence_drac5.py             |   14 +++---
 fence/agents/hpblade/fence_hpblade.py         |   18 +++---
 fence/agents/ilo/fence_ilo.py                 |   34 ++++++------
 fence/agents/ilo_mp/fence_ilo_mp.py           |    6 +-
 fence/agents/ldom/fence_ldom.py               |   16 +++---
 fence/agents/lpar/fence_lpar.py               |   56 ++++++++++----------
 fence/agents/rhevm/fence_rhevm.py             |    4 +-
 fence/agents/rsa/fence_rsa.py                 |    6 +-
 fence/agents/rsb/fence_rsb.py                 |   18 +++---
 fence/agents/sanbox2/fence_sanbox2.py         |   18 +++---
 fence/agents/virsh/fence_virsh.py             |   10 ++--
 fence/agents/vmware/fence_vmware.py           |   70 ++++++++++++------------
 fence/agents/vmware_soap/fence_vmware_soap.py |   26 +++++-----
 fence/agents/wti/fence_wti.py                 |   40 +++++++-------
 18 files changed, 231 insertions(+), 231 deletions(-)
fence/agents/alom/fence_alom.py +4 -4
index 3f39b2d..abe0a1a 100644
@@ -17,18 +17,18 @@ BUILD_DATE=""
 
 def get_power_status(conn, options):
 	conn.send_eol("showplatform")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	status = re.search("standby", conn.before.lower())
 	result = (status != None and "off" or "on")
 
 	return result
 
 def set_power_status(conn, options):
-	cmd_line = (options["-o"] == "on" and "poweron" or "poweroff -f -y")
+	cmd_line = (options["--action"] == "on" and "poweron" or "poweroff -f -y")
 	conn.send_eol(cmd_line)
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	# Get the machine some time between poweron and poweroff
-	time.sleep(int(options["-g"]))
+	time.sleep(int(options["--power-timeout"]))
 		
 def main():
 	device_opt = [  "ipaddr", "login", "passwd", "passwd_script", "cmd_prompt", "secure",
fence/agents/apc/fence_apc.py +35 -35

155 lines not on this page · raw message

fence/agents/bladecenter/fence_bladecenter.py +15 -15
index 726a15f..cf38e10 100644
@@ -23,40 +23,40 @@ BUILD_DATE="March, 2008"
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["-n"] + "\]>"
+	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
 
-	conn.send_eol("env -T system:blade[" + options["-n"] + "]")
-	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
+	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
 	if i == 1:
 		## Given blade number does not exist
-		if options.has_key("-M"):
+		if options.has_key("--missing-as-off"):
 			return "off"
 		else:
 			fail(EC_STATUS)
 	conn.send_eol("power -state")
-	conn.log_expect(options, node_cmd, int(options["-Y"]))
+	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 	status = conn.before.splitlines()[-1]
 	conn.send_eol("env -T system")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["-n"] + "\]>"
+	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
 
-	conn.send_eol("env -T system:blade[" + options["-n"] + "]")
-	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
+	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
+	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
 	if i == 1:
 		## Given blade number does not exist
-		if options.has_key("-M"):
+		if options.has_key("--missing-as-off"):
 			return
 		else:
 			fail(EC_GENERIC_ERROR)
 
-	conn.send_eol("power -"+options["-o"])
-	conn.log_expect(options, node_cmd, int(options["-Y"]))
+	conn.send_eol("power -"+options["--action"])
+	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 	conn.send_eol("env -T system")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 def get_blades_list(conn, options):
 	outlets = { }
@@ -64,9 +64,9 @@ def get_blades_list(conn, options):
 	node_cmd = "system>"
 
 	conn.send_eol("env -T system")
-	conn.log_expect(options, node_cmd, int(options["-Y"]))
+	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 	conn.send_eol("list -l 2")
-	conn.log_expect(options, node_cmd, int(options["-Y"]))
+	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 
 	lines = conn.before.split("\r\n")
 	filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
fence/agents/cisco_ucs/fence_cisco_ucs.py +9 -9
index 5ed2c35..2a81c68 100644
@@ -19,8 +19,8 @@ RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
 def get_power_status(conn, options):
 	res = send_command(options, \
 		"<configResolveDn cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" dn=\"org-root" + options["-s"] + \
-		"/ls-" + options["-n"] + "/power\"/>", \
-		 int(options["-Y"]))
+		"/ls-" + options["--plug"] + "/power\"/>", \
+		 int(options["--shell-timeout"]))
 
 	result = RE_STATUS.search(res)
 	if (result == None):
@@ -37,14 +37,14 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "up",
 		'off' : "down"
-	}[options["-o"]]
+	}[options["--action"]]
 	
 	res = send_command(options, \
 		"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
-		"<inConfigs><pair key=\"org-root" + options["-s"] + "/ls-" + options["-n"] + "/power\">" + \
-		"<lsPower dn=\"org-root/ls-" + options["-n"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
+		"<inConfigs><pair key=\"org-root" + options["-s"] + "/ls-" + options["--plug"] + "/power\">" + \
+		"<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
 		"</pair></inConfigs></configConfMos>", \
-		int(options["-Y"]))
+		int(options["--shell-timeout"]))
 	
 	return
 
@@ -54,7 +54,7 @@ def get_list(conn, options):
 	try:
 		res = send_command(options, \
 			"<configResolveClass cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" classId=\"lsServer\"/>", \
-			int(options["-Y"]))
+			int(options["--shell-timeout"]))
 
 		lines = res.split("<lsServer ")
 		for i in range(1, len(lines)):
@@ -113,7 +113,7 @@ used with Cisco UCS to fence machines."
 	show_docs(options, docs)
 
 	### Login
-	res = send_command(options, "<aaaLogin inName=\"" + options["-l"] + "\" inPassword=\"" + options["-p"] + "\" />", int(options["-y"]))
+	res = send_command(options, "<aaaLogin inName=\"" + options["--username"] + "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
 	result = RE_COOKIE.search(res)
 	if (result == None):	
 		## Cookie is absenting in response
@@ -135,7 +135,7 @@ used with Cisco UCS to fence machines."
 	result = fence_action(None, options, set_power_status, get_power_status, get_list)
 
 	### Logout; we do not care about result as we will end in any case
-	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["-Y"]))
+	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["--shell-timeout"]))
 	
 	sys.exit(result)
 
fence/agents/drac5/fence_drac5.py +7 -7
index f8c129d..bce8cef 100644
@@ -24,11 +24,11 @@ BUILD_DATE="March, 2008"
 
 def get_power_status(conn, options):
 	if options["model"] == "DRAC CMC":
-		conn.send_eol("racadm serveraction powerstatus -m " + options["-m"])
+		conn.send_eol("racadm serveraction powerstatus -m " + options["--module-name"])
 	elif options["model"] == "DRAC 5":
 		conn.send_eol("racadm serveraction powerstatus")
 		
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 				
 	status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
 	if status.lower().strip() in ["on", "powering on", "powering off"]:
@@ -40,13 +40,13 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "powerup",
 		'off': "powerdown"
-	}[options["-o"]]
+	}[options["--action"]]
 
 	if options["model"] == "DRAC CMC":
-		conn.send_eol("racadm serveraction " + action + " -m " + options["-m"])
+		conn.send_eol("racadm serveraction " + action + " -m " + options["--module-name"])
 	elif options["model"] == "DRAC 5":
 		conn.send_eol("racadm serveraction " + action)
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 def get_list_devices(conn, options):
 	outlets = { }
@@ -55,7 +55,7 @@ def get_list_devices(conn, options):
 		conn.send_eol("getmodinfo")
 
 		list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
-		conn.log_expect(options, options["-c"], int(options["-g"]))
+		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
 				outlets[list_re.search(line).group(1)] = ("", list_re.search(line).group(2))
@@ -95,7 +95,7 @@ By default, the telnet interface is not  enabled."
 	conn = fence_login(options)
 
 	if conn.before.find("CMC") >= 0:
-		if 0 == options.has_key("-m") and 0 == ["monitor", "list"].count(options["-o"].lower()):
+		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)")
 			
 		options["model"] = "DRAC CMC"
fence/agents/hpblade/fence_hpblade.py +9 -9
index c4f045e..6532065 100644
@@ -17,8 +17,8 @@ BUILD_DATE="March, 2008"
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	conn.send_eol("show server status " + options["-n"])
-	conn.log_expect(options, options["-c"] , int(options["-Y"]))
+	conn.send_eol("show server status " + options["--plug"])
+	conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
 		
 	power_re = re.compile("^\s*Power: (.*?)\s*$")
 	status = "unknown"
@@ -28,7 +28,7 @@ def get_power_status(conn, options):
 			status = res.group(1)
 
 	if status == "unknown":
-		if options.has_key("-M"):
+		if options.has_key("--missing-as-off"):
 			return "off"
 		else:
 			fail(EC_STATUS)
@@ -36,17 +36,17 @@ def get_power_status(conn, options):
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	if options["-o"] == "on":
-		conn.send_eol("poweron server " + options["-n"])
-	elif options["-o"] == "off":
-		conn.send_eol("poweroff server " + options["-n"] + " force")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	if options["--action"] == "on":
+		conn.send_eol("poweron server " + options["--plug"])
+	elif options["--action"] == "off":
+		conn.send_eol("poweroff server " + options["--plug"] + " force")
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 def get_blades_list(conn, options):
 	outlets = { }
 
 	conn.send_eol("show server list" )
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	list_re = re.compile("^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
 	for line in conn.before.splitlines():
fence/agents/ilo/fence_ilo.py +17 -17
index 66472aa..c85a063 100644
@@ -22,18 +22,18 @@ BUILD_DATE="March, 2008"
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
-		" PASSWORD = \"" + options["-p"] + "\">\r\n")
+	conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+		" PASSWORD = \"" + options["--password"] + "\">\r\n")
 	conn.send("<SERVER_INFO MODE = \"read\"><GET_HOST_POWER_STATUS/>\r\n")
 	conn.send("</SERVER_INFO></LOGIN>\r\n")
-	conn.log_expect(options, "HOST_POWER=\"(.*?)\"", int(options["-g"]))
+	conn.log_expect(options, "HOST_POWER=\"(.*?)\"", int(options["--power-timeout"]))
 
 	status = conn.match.group(1)
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
-		" PASSWORD = \"" + options["-p"] + "\">\r\n")
+	conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+		" PASSWORD = \"" + options["--password"] + "\">\r\n")
 	conn.send("<SERVER_INFO MODE = \"write\">")
 
 	if options.has_key("fw_processor") and options["fw_processor"] == "iLO2":
@@ -41,10 +41,10 @@ def set_power_status(conn, options):
 			conn.send("<HOLD_PWR_BTN TOGGLE=\"yes\" />\r\n")
 		else:
 			conn.send("<HOLD_PWR_BTN />\r\n")
-	elif options["-r"] < 2.21:
-		conn.send("<SET_HOST_POWER HOST_POWER = \"" + options["-o"] + "\" />\r\n")
+	elif options["--ribcl-version"] < 2.21:
+		conn.send("<SET_HOST_POWER HOST_POWER = \"" + options["--action"] + "\" />\r\n")
 	else:
-		if options["-o"] == "off":
+		if options["--action"] == "off":
 			conn.send("<HOLD_PWR_BTN/>\r\n")
 		else:
 			conn.send("<PRESS_PWR_BTN/>\r\n")
@@ -81,23 +81,23 @@ the iLO card through an XML stream."
 	conn = fence_login(options)
 	try:
 		conn.send("<?xml version=\"1.0\"?>\r\n")
-		conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["-y"]))
+		conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["--login-timeout"]))
 		version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
-		if options.has_key("-r") == 0:
-			options["-r"] = float(version)
+		if options.has_key("--ribcl-version") == 0:
+			options["--ribcl-version"] = float(version)
 
-		if options["-r"] >= 2:
+		if options["--ribcl-version"] >= 2:
 			conn.send("<RIBCL VERSION=\"2.0\">\r\n")
 		else:
 			conn.send("<RIBCL VERSION=\"1.2\">\r\n")
 
-		conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
-			" PASSWORD = \"" + options["-p"] + "\">\r\n")
-		if options["-r"] >= 2:
+		conn.send("<LOGIN USER_LOGIN = \"" + options["--username"] + "\"" + \
+			" PASSWORD = \"" + options["--password"] + "\">\r\n")
+		if options["--ribcl-version"] >= 2:
 			conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
 			conn.send("</RIB_INFO>\r\n")
-			conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["-Y"]))
-			conn.log_expect(options, "/>", int(options["-Y"]))
+			conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
+			conn.log_expect(options, "/>", int(options["--shell-timeout"]))
 			options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1))
 			options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
 		conn.send("</LOGIN>\r\n")
fence/agents/ilo_mp/fence_ilo_mp.py +3 -3
index 7cf068a..85764c6 100644
@@ -14,7 +14,7 @@ def get_power_status(conn, options):
 	conn.send_eol("show /system1")
 		
 	re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
-	conn.log_expect(options, re_state, int(options["-Y"]))
+	conn.log_expect(options, re_state, int(options["--shell-timeout"]))
 
 	status = conn.match.group(1).lower()
 
@@ -24,12 +24,12 @@ def get_power_status(conn, options):
 		return "off"
 
 def set_power_status(conn, options):
-	if options["-o"] == "on":
+	if options["--action"] == "on":
 		conn.send_eol("start /system1")
 	else:
 		conn.send_eol("stop -f /system1")
 
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 	return
 
fence/agents/ldom/fence_ldom.py +8 -8
index 0d67e3f..0f41d75 100644
@@ -23,11 +23,11 @@ COMMAND_PROMPT_NEW = "[PEXPECT]"
 # Start comunicating after login. Prepare good environment.
 def start_communication(conn, options):
 	conn.send_eol ("PS1='"+COMMAND_PROMPT_NEW+"'")
-	res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["-Y"]))
+	res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["--shell-timeout"]))
 	if res == 0:
 		#CSH stuff
 		conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
-		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
+		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
 	
 
 def get_power_status(conn, options):
@@ -35,7 +35,7 @@ def get_power_status(conn, options):
 		
 	conn.send_eol("ldm ls")
 		    
-	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
+	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
 
 	result = {}
 
@@ -51,22 +51,22 @@ def get_power_status(conn, options):
 			elif (fa_status==1):
 				result[domain.group(1)] = ("", (domain.group(2).lower()=="bound" and "off" or "on"))
 
-	if (not (options["-o"] in ['monitor','list'])):
-		if (not (options["-n"] in result)):
+	if (not (options["--action"] in ['monitor','list'])):
+		if (not (options["--plug"] in result)):
 			fail_usage("Failed: You have to enter existing logical domain!")
 		else:
-			return result[options["-n"]][1]
+			return result[options["--plug"]][1]
 	else:
 		return result
 
 def set_power_status(conn, options):
 	start_communication(conn, options)
          	
-	cmd_line = "ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
+	cmd_line = "ldm "+(options["--action"]=="on" and "start" or "stop -f")+" \""+options["--plug"]+"\""
             	
 	conn.send_eol(cmd_line)
 		    
-	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-g"]))
+	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--power-timeout"]))
 		
 def main():
 	device_opt = [  "ipaddr", "login", "passwd", "passwd_script",
fence/agents/lpar/fence_lpar.py +28 -28

95 lines not on this page · raw message

fence/agents/rhevm/fence_rhevm.py +2 -2
index 7f5abde..fb97d51 100644
@@ -18,7 +18,7 @@ RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
 
 def get_power_status(conn, options):
 	### Obtain real ID from name
-	res = send_command(options, "vms/?search=name%3D" + options["-n"])
+	res = send_command(options, "vms/?search=name%3D" + options["--plug"])
 
 	result = RE_GET_ID.search(res)
 	if (result == None):
@@ -45,7 +45,7 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "start",
 		'off' : "stop"
-	}[options["-o"]]
+	}[options["--action"]]
 
 	url = "vms/" + options["id"] + "/" + action
 	res = send_command(options, url, "POST")
fence/agents/rsa/fence_rsa.py +3 -3
index 75cf1f7..e1e303f 100644
@@ -19,7 +19,7 @@ BUILD_DATE=""
 
 def get_power_status(conn, options):
 	conn.send_eol("power state")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 				
 	match = re.compile("Power: (.*)", re.IGNORECASE).search(conn.before)
 	if (match != None):
@@ -30,8 +30,8 @@ def get_power_status(conn, options):
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	conn.send_eol("power " + options["-o"])
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.send_eol("power " + options["--action"])
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 def main():
 	device_opt = [  "ipaddr", "login", "passwd", "passwd_script",
fence/agents/rsb/fence_rsb.py +9 -9
index 40c922e..395a844 100755
@@ -12,10 +12,10 @@ BUILD_DATE=""
 
 def get_power_status(conn, options):
 	conn.send("2")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	status = re.compile("Power Status : (on|off)", re.IGNORECASE).search(conn.before).group(1)
 	conn.send("0")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	return (status.lower().strip())
 
@@ -23,18 +23,18 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "4",
 		'off': "1"
-	}[options["-o"]]
+	}[options["--action"]]
 
 	conn.send("2")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	conn.send_eol(action)
-	conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["-Y"]))
+	conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["--shell-timeout"]))
 	conn.send_eol("yes")
-	conn.log_expect(options, "any key to continue", int(options["-g"]))
+	conn.log_expect(options, "any key to continue", int(options["--power-timeout"]))
 	conn.send_eol("")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	conn.send_eol("0")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 def main():
 	device_opt = [  "ipaddr", "login", "passwd", "passwd_script",
@@ -59,7 +59,7 @@ def main():
 
 	# set default port for telnet only
 	if 0 == opt.has_key("-x") and 0 == opt.has_key("-u"):
-		opt["-u"] = 3172
+		opt["--ipport"] = 3172
 	options = check_input(device_opt, opt)
 
 	docs = { }
fence/agents/sanbox2/fence_sanbox2.py +9 -9
index 173c819..ccbfd8e 100644
@@ -24,8 +24,8 @@ def get_power_status(conn, options):
 		'offline' : "off"
 	}
 	try:
-		conn.send_eol("show port " + options["-n"])
-		conn.log_expect(options, options["-c"], int(options["-Y"]))
+		conn.send_eol("show port " + options["--plug"])
+		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	except pexpect.TIMEOUT:
 		try:
 			conn.send_eol("admin end")
@@ -46,11 +46,11 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "online",
 		'off' : "offline"
-	}[options["-o"]]
+	}[options["--action"]]
 
 	try:
-		conn.send_eol("set port " + options["-n"] + " state " + action)
-		conn.log_expect(options, options["-c"], int(options["-g"]))
+		conn.send_eol("set port " + options["--plug"] + " state " + action)
+		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	except pexpect.TIMEOUT:
 		try:
 			conn.send_eol("admin end")
@@ -61,8 +61,8 @@ def set_power_status(conn, options):
 		fail(EC_TIMED_OUT)                                                                         	
 
 	try:
-		conn.send_eol("set port " + options["-n"] + " state " + action)
-		conn.log_expect(options, options["-c"], int(options["-g"]))
+		conn.send_eol("set port " + options["--plug"] + " state " + action)
+		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	except pexpect.TIMEOUT:
 		try:
 			conn.send_eol("admin end")
@@ -77,7 +77,7 @@ def get_list_devices(conn, options):
 
 	try:
 		conn.send_eol("show port")
-		conn.log_expect(options, options["-c"], int(options["-Y"]))
+		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 		list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
 		for line in conn.before.splitlines():
@@ -125,7 +125,7 @@ because the connection will block any necessary fencing actions."
 	conn = fence_login(options)
 
 	conn.send_eol("admin start")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
 		## Someone else is in admin section, we can't enable/disable
fence/agents/virsh/fence_virsh.py +5 -5
index c8c49a4..b157385 100644
@@ -22,7 +22,7 @@ def get_outlets_status(conn, options):
 		prefix = ""
 
 	conn.sendline(prefix + "virsh list --all")
-	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	result = {}
 
@@ -42,10 +42,10 @@ def get_outlets_status(conn, options):
 def get_power_status(conn, options):
 	outlets = get_outlets_status(conn, options)
 
-	if (not (options["-n"] in outlets)):
+	if (not (options["--plug"] in outlets)):
 		fail_usage("Failed: You have to enter existing name of virtual machine!")
 	else:
-		return outlets[options["-n"]][1]
+		return outlets[options["--plug"]][1]
 
 def set_power_status(conn, options):
 	if options.has_key("-d"):
@@ -53,9 +53,9 @@ def set_power_status(conn, options):
 	else:
 		prefix = ""
 
-	conn.sendline(prefix + "virsh %s "%(options["-o"] == "on" and "start" or "destroy")+options["-n"])
+	conn.sendline(prefix + "virsh %s "%(options["--action"] == "on" and "start" or "destroy")+options["--plug"])
 
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	time.sleep(1)
 
 def main():
fence/agents/vmware/fence_vmware.py +35 -35

136 lines not on this page · raw message

fence/agents/vmware_soap/fence_vmware_soap.py +13 -13
index 2710603..4ef03f0 100644
@@ -14,12 +14,12 @@ BUILD_DATE="April, 2011"
 #END_VERSION_GENERATION
 
 def soap_login(options):
-	if options.has_key("-z"):
+	if options.has_key("--ssl"):
 		url = "https://"
 	else:
 		url = "http://"
 	
-	url += options["-a"] + ":" + str(options["-u"]) + "/sdk"
+	url += options["--ip"] + ":" + str(options["-u"]) + "/sdk"
 	conn = Client(url + "/vimService.wsdl")
 	conn.set_options(location = url)
 
@@ -30,7 +30,7 @@ def soap_login(options):
 	mo_SessionManager._type = 'SessionManager'
 	
 	try:
-		SessionManager = conn.service.Login(mo_SessionManager, options["-l"], options["-p"])
+		SessionManager = conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
 	except Exception, ex:
 		fail(EC_LOGIN_DENIED)	
 
@@ -104,22 +104,22 @@ def get_power_status(conn, options):
 		uuid.update(more_uuid)
 		mappingToUUID.update(more_mappingToUUID)
 		# Do not run unnecessary SOAP requests
-		if options.has_key("-U") and options["-U"] in uuid:
+		if options.has_key("--uuid") and options["--uuid"] in uuid:
 			break
 
-	if ["list", "monitor"].count(options["-o"]) == 1:
+	if ["list", "monitor"].count(options["--action"]) == 1:
 		return machines
 	else:
-		if options.has_key("-U") == False:
-			if options["-n"].startswith('/'):
+		if options.has_key("--uuid") == False:
+			if options["--plug"].startswith('/'):
 				## Transform InventoryPath to UUID
 				mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
 				mo_SearchIndex._type = "SearchIndex"
 			
-				vm = conn.service.FindByInventoryPath(mo_SearchIndex, options["-n"])
+				vm = conn.service.FindByInventoryPath(mo_SearchIndex, options["--plug"])
 			
 				try:
-					options["-U"] = mappingToUUID[vm.value]
+					options["--uuid"] = mappingToUUID[vm.value]
 				except KeyError, ex:
 					fail(EC_STATUS)
 				except AttributeError, ex:
@@ -128,14 +128,14 @@ def get_power_status(conn, options):
 				## Name of virtual machine instead of path
 				## warning: if you have same names of machines this won't work correctly
 				try:
-					(options["-U"], _) = machines[options["-n"]]
+					(options["--uuid"], _) = machines[options["--plug"]]
 				except KeyError, ex:
 					fail(EC_STATUS)
 				except AttributeError, ex:
 					fail(EC_STATUS)
 
 		try:
-			if uuid[options["-U"]] == "poweredOn":
+			if uuid[options["--uuid"]] == "poweredOn":
 				return "on"
 			else:
 				return "off"
@@ -145,12 +145,12 @@ def get_power_status(conn, options):
 def set_power_status(conn, options):
 	mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
 	mo_SearchIndex._type = "SearchIndex"
-	vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch = 1, uuid = options["-U"])
+	vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch = 1, uuid = options["--uuid"])
 
 	mo_machine = Property(vm.value)
 	mo_machine._type = "VirtualMachine"
 	
-	if options["-o"] == "on":
+	if options["--action"] == "on":
 		conn.service.PowerOnVM_Task(mo_machine)
 	else:
 		conn.service.PowerOffVM_Task(mo_machine)	
fence/agents/wti/fence_wti.py +20 -20
index 2337e10..80b5e96 100644
@@ -26,18 +26,18 @@ def get_power_status(conn, options):
 
 	conn.send("/S"+"\r\n")
 
-	if isinstance(options["-c"], list):
-		re_all = list(options["-c"])
+	if isinstance(options["--command-prompt"], list):
+		re_all = list(options["--command-prompt"])
 	else:
-		re_all = [options["-c"]]
+		re_all = [options["--command-prompt"]]
 	re_next = re.compile("Enter: ", re.IGNORECASE)
 	re_all.append(re_next)
 
-	result = conn.log_expect(options, re_all, int(options["-Y"]))
+	result = conn.log_expect(options, re_all, int(options["--shell-timeout"]))
 	listing = conn.before
 	if result == (len(re_all) - 1):
 		conn.send("\r\n")
-		conn.log_expect(options, options["-c"], int(options["-Y"]))
+		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 		listing += conn.before
 	
 	plug_section = 0
@@ -52,7 +52,7 @@ def get_power_status(conn, options):
 			plug_line = [x.strip().lower() for x in line.split("|")]
 			if len(plug_line) < len(plug_header):
 				plug_section = -1
-			if ["list", "monitor"].count(options["-o"]) == 0 and options["-n"].lower() == plug_line[plug_index]:
+			if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[plug_index]:
 				return plug_line[status_index]
 			else:
 				## We already believe that first column contains plug number
@@ -67,7 +67,7 @@ def get_power_status(conn, options):
 			name_index = plug_header.index("name")
 			status_index = plug_header.index("status")
 
-	if ["list", "monitor"].count(options["-o"]) == 1:
+	if ["list", "monitor"].count(options["--action"]) == 1:
 		return outlets
 	else:
 		return "PROBLEM"
@@ -76,10 +76,10 @@ def set_power_status(conn, options):
 	action = {
 		'on' : "/on",
 		'off': "/off"
-	}[options["-o"]]
+	}[options["--action"]]
 
-	conn.send(action + " " + options["-n"] + ",y\r\n")
-	conn.log_expect(options, options["-c"], int(options["-g"]))
+	conn.send(action + " " + options["--plug"] + ",y\r\n")
+	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 def main():
 	device_opt = [  "ipaddr", "login", "passwd", "passwd_script",
@@ -107,12 +107,12 @@ is running because the connection will block any necessary fencing actions."
 	##
 	## @note: if it possible that this device does not need either login, password or both of them
 	#####	
-	if 0 == options.has_key("-x"):
+	if 0 == options.has_key("--ssh"):
 		try:
 			try:
 				conn = fspawn(options, TELNET_PATH)
 				conn.send("set binary\n")
-				conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
+				conn.send("open %s -%s\n"%(options["--ip"], options["-u"]))
 			except pexpect.ExceptionPexpect, ex:
 				sys.stderr.write(str(ex) + "\n")
 				sys.stderr.write("Due to limitations, binary dependencies on fence agents "
@@ -120,20 +120,20 @@ is running because the connection will block any necessary fencing actions."
 				sys.exit(EC_GENERIC_ERROR)
 			
 			re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
-			re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["-c"])), re.IGNORECASE)
+			re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["--command-prompt"])), re.IGNORECASE)
 
-			result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
+			result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
 			if result == 0:
-				if options.has_key("-l"):
-					conn.send(options["-l"]+"\r\n")
-					result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
+				if options.has_key("--username"):
+					conn.send(options["--username"]+"\r\n")
+					result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
 				else:
 					fail_usage("Failed: You have to set login name")
 		
 			if result == 1:
-				if options.has_key("-p"):
-					conn.send(options["-p"]+"\r\n")
-					conn.log_expect(options, options["-c"], int(options["-Y"]))	
+				if options.has_key("--password"):
+					conn.send(options["--password"]+"\r\n")
+					conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))	
 				else:
 					fail_usage("Failed: You have to enter password or password script")
 		except pexpect.EOF:
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 3/3 fence agents: Transfer SNMP fence agents to long-opts + transfer script

---
 fence/agents/apc_snmp/fence_apc_snmp.py         |   24 ++++++++--------
 fence/agents/cisco_mds/fence_cisco_mds.py       |    6 ++--
 fence/agents/ibmblade/fence_ibmblade.py         |    4 +-
 fence/agents/ifmib/fence_ifmib.py               |    6 ++--
 fence/agents/intelmodular/fence_intelmodular.py |    4 +-
 fence/agents/ipdu/fence_ipdu.py                 |   10 +++---
 fence/agents/lib/fencing_snmp.py.py             |   33 ++++++++++++-----------
 fence/agents/lib/transfer.py                    |   16 +++++++++++
 8 files changed, 60 insertions(+), 43 deletions(-)
 create mode 100755 fence/agents/lib/transfer.py
fence/agents/apc_snmp/fence_apc_snmp.py +12 -12
index 6f95f37..8a97ae4 100644
@@ -94,16 +94,16 @@ def apc_resolv_port_id(conn, options):
 		apc_set_device(conn, options)
 
 	# Now we resolv port_id/switch_id
-	if ((options["-n"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
-		port_id = int(options["-n"])
+	if ((options["--plug"].isdigit()) and ((not device.has_switches) or (options["--switch"].isdigit()))):
+		port_id = int(options["--plug"])
 
 		if (device.has_switches):
-			switch_id = int(options["-s"])
+			switch_id = int(options["--switch"])
 	else:
 		table = conn.walk(device.outlet_table_oid, 30)
 
 		for x in table:
-			if (x[1].strip('"') == options["-n"]):
+			if (x[1].strip('"') == options["--plug"]):
 				t = x[0].split('.')
 				if (device.has_switches):
 					port_id = int(t[len(t)-1])
@@ -112,7 +112,7 @@ def apc_resolv_port_id(conn, options):
 					port_id = int(t[len(t)-1])
 
 	if (port_id == None):
-		fail_usage("Can't find port with name %s!"%(options["-n"]))
+		fail_usage("Can't find port with name %s!"%(options["--plug"]))
 
 def get_power_status(conn, options):
 	if (port_id == None):
@@ -129,7 +129,7 @@ def set_power_status(conn, options):
 
 	oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
 
-	conn.set(oid, (options["-o"]=="on" and device.turn_on or device.turn_off))
+	conn.set(oid, (options["--action"]=="on" and device.turn_on or device.turn_off))
 
 
 def get_outlets_status(conn, options):
@@ -172,14 +172,14 @@ def main():
 	options = check_input(device_opt, process_input(device_opt))
 
         ## Support for -n [switch]:[plug] notation that was used before
-	if ((options.has_key("-n")) and (-1 != options["-n"].find(":"))):
-		(switch, plug) = options["-n"].split(":", 1)
+	if ((options.has_key("--plug")) and (-1 != options["--plug"].find(":"))):
+		(switch, plug) = options["--plug"].split(":", 1)
 		if ((switch.isdigit()) and (plug.isdigit())):
-			options["-s"] = switch
-			options["-n"] = plug
+			options["--switch"] = switch
+			options["--plug"] = plug
 
-	if (not (options.has_key("-s"))):
-		options["-s"] = "1"
+	if (not (options.has_key("--switch"))):
+		options["--switch"] = "1"
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for APC over SNMP"
fence/agents/cisco_mds/fence_cisco_mds.py +3 -3
index 8ebce8a..cb45d73 100644
@@ -47,7 +47,7 @@ def get_power_status(conn, options):
 	return (status=="1" and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set(PORT_OID, (options["-o"]=="on" and 1 or 2))
+	conn.set(PORT_OID, (options["--action"]=="on" and 1 or 2))
 
 # Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
 # in format a.b.c.d...z and returned dict has key only z
@@ -96,8 +96,8 @@ which can be used with any Cisco MDS 9000 series with SNMP enabled device."
 	docs["vendorurl"] = "http://www.cisco.com"
 	show_docs(options, docs)
 
-	if (not (options["-o"] in ["list","monitor"])):
-		PORT_OID = cisco_port2oid(options["-n"])
+	if (not (options["--action"] in ["list","monitor"])):
+		PORT_OID = cisco_port2oid(options["--plug"])
 
 	# Operate the fencing device
 	result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
fence/agents/ibmblade/fence_ibmblade.py +2 -2
index ceb747d..759bfc4 100644
@@ -27,11 +27,11 @@ STATUS_SET_ON = 1
 ### FUNCTIONS ###
 
 def get_power_status(conn, options):
-	(_, status) = conn.get("%s.%s"% (STATUSES_OID, options["-n"]))
+	(_, status) = conn.get("%s.%s"% (STATUSES_OID, options["--plug"]))
 	return (status == str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(CONTROL_OID, options["-n"]), (options["-o"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
+	conn.set("%s.%s"%(CONTROL_OID, options["--plug"]), (options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
 
 def get_outlets_status(conn, _):
 	result = {}
fence/agents/ifmib/fence_ifmib.py +3 -3
index 170134e..9a17257 100644
@@ -59,7 +59,7 @@ def get_power_status(conn, options):
 	global port_num
 
 	if (port_num==None):
-		port_num = port2index(conn, options["-n"])
+		port_num = port2index(conn, options["--plug"])
 
 	(oid, status) = conn.get("%s.%d"%(STATUSES_OID, port_num))
 	return (status==str(STATUS_UP) and "on" or "off")
@@ -68,9 +68,9 @@ def set_power_status(conn, options):
 	global port_num
 
 	if (port_num==None):
-		port_num = port2index(conn, options["-n"])
+		port_num = port2index(conn, options["--plug"])
 
-	conn.set("%s.%d"%(STATUSES_OID, port_num), (options["-o"]=="on" and STATUS_UP or STATUS_DOWN))
+	conn.set("%s.%d"%(STATUSES_OID, port_num), (options["--action"]=="on" and STATUS_UP or STATUS_DOWN))
 
 # Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
 # in format a.b.c.d...z and returned dict has key only z
fence/agents/intelmodular/fence_intelmodular.py +2 -2
index 3fd9822..a590ced 100644
@@ -38,11 +38,11 @@ STATUS_SET_OFF = 3
 ### FUNCTIONS ###
 
 def get_power_status(conn, options):
-	(oid, status) = conn.get("%s.%s"% (STATUSES_OID, options["-n"]))
+	(oid, status) = conn.get("%s.%s"% (STATUSES_OID, options["--plug"]))
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(STATUSES_OID, options["-n"]), (options["-o"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
+	conn.set("%s.%s"%(STATUSES_OID, options["--plug"]), (options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
 
 def get_outlets_status(conn, options):
 	result = {}
fence/agents/ipdu/fence_ipdu.py +5 -5
index da7f192..6c93b53 100644
@@ -66,8 +66,8 @@ def ipdu_resolv_port_id(conn, options):
 		ipdu_set_device(conn, options)
 
 	# Now we resolv port_id/switch_id
-	if ((options["-n"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
-		port_id = int(options["-n"])
+	if ((options["--plug"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
+		port_id = int(options["--plug"])
 
 		if (device.has_switches):
 			switch_id = int(options["-s"])
@@ -75,7 +75,7 @@ def ipdu_resolv_port_id(conn, options):
 		table = conn.walk(device.outlet_table_oid, 30)
 
 		for x in table:
-			if (x[1].strip('"')==options["-n"]):
+			if (x[1].strip('"')==options["--plug"]):
 				t = x[0].split('.')
 				if (device.has_switches):
 					port_id = int(t[len(t)-1])
@@ -84,7 +84,7 @@ def ipdu_resolv_port_id(conn, options):
 					port_id = int(t[len(t)-1])
 
 	if (port_id==None):
-		fail_usage("Can't find port with name %s!"%(options["-n"]))
+		fail_usage("Can't find port with name %s!"%(options["--plug"]))
 
 def get_power_status(conn, options):
 	if (port_id==None):
@@ -101,7 +101,7 @@ def set_power_status(conn, options):
 
 	oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
 
-	conn.set(oid,(options["-o"]=="on" and device.turn_on or device.turn_off))
+	conn.set(oid,(options["--action"]=="on" and device.turn_on or device.turn_off))
 
 
 def get_outlets_status(conn, options):
fence/agents/lib/fencing_snmp.py.py +17 -16
index e4c4636..89f8ece 100644
@@ -31,8 +31,8 @@ class FencingSnmp:
 
 	def complete_missed_params(self):
 		mapping = [
-			[['P','p','!E'],'self.options["-E"]="authPriv"'],
-			[['!d','c','!l','!P','!p'],'self.options["-d"]="2c"']
+			[['snmp-priv-passwd','password','!snmp-sec-level'],'self.options["--snmp-sec-level"]="authPriv"'],
+			[['!snmp-version','community','!username','!snmp-priv-passwd','!password'],'self.options["--snmp-version"]="2c"']
 			]
 
 		for val in mapping:
@@ -41,11 +41,11 @@ class FencingSnmp:
 			res = True
 
 			for item in e:
-				if ((item[0]=='!') and (self.options.has_key("-"+item[1]))):
+				if ((item[0]=='!') and (self.options.has_key("--"+item[1:]))):
 					res = False
 					break
 
-				if ((item[0]!='!') and (not self.options.has_key("-"+item[0]))):
+				if ((item[0]!='!') and (not self.options.has_key("--"+item[0:]))):
 					res = False
 					break
 
@@ -58,37 +58,38 @@ class FencingSnmp:
 		self.complete_missed_params()
 
 		#mapping from our option to snmpcmd option
-		mapping = (('d', 'v'),('c', 'c'))
+		mapping = (('snmp-version', 'v'),('community', 'c'))
 
 		for item in mapping:
-			if (self.options.has_key("-"+item[0])):
-				cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["-" + item[0]]))
+			if (self.options.has_key("--" + item[0])):
+				cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[0]]))
 
 		# Some options make sense only for v3 (and for v1/2c can cause "problems")
-		if (self.options.has_key("-d")) and (self.options["-d"] == "3"):
+		if (self.options.has_key("--snmp-version")) and (self.options["--snmp-version"] == "3"):
 			# Mapping from our options to snmpcmd options for v3
-			mapping_v3 = (('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','u'))
+			mapping_v3 = (('snmp-auth-prot','a'), ('snmp-sec-level','l'), ('snmp-priv-prot','x'), \
+				('snmp-priv-passwd','X'),('password','A'),('username','u'))
 			for item in mapping_v3:
-				if (self.options.has_key("-"+item[0])):
-					cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["-" + item[0]]))
+				if (self.options.has_key("--"+item[0])):
+					cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[1]]))
 
 		force_ipvx = ""
 
-		if (self.options.has_key("-6")):
+		if (self.options.has_key("--inet6-only")):
 			force_ipvx = "udp6:"
 
-		if (self.options.has_key("-4")):
+		if (self.options.has_key("--inet4-only")):
 			force_ipvx = "udp:"
 
-		cmd += " '%s%s%s'"% (force_ipvx, self.quote_for_run(self.options["-a"]),
-				self.options.has_key("-u") and self.quote_for_run(":" + str (self.options["-u"])) or "")
+		cmd += " '%s%s%s'"% (force_ipvx, self.quote_for_run(self.options["--ip"]),
+				self.options.has_key("--udpport") and self.quote_for_run(":" + str (self.options["--udpport"])) or "")
 		return cmd
 
 	def run_command(self, command, additional_timemout=0):
 		try:
 			self.log_command(command)
 
-			(res_output, res_code) = pexpect.run(command, int(self.options["-Y"]) + int(self.options["-y"]) + additional_timemout, True)
+			(res_output, res_code) = pexpect.run(command, int(self.options["--shell-timeout"]) + int(self.options["--login-timeout"]) + additional_timemout, True)
 
 			if (res_code==None):
 				fail(EC_TIMED_OUT)
fence/agents/lib/transfer.py new file +16 -0
new file mode 100755
index 0000000..ddf2486
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+from fencing import *
+
+def main():
+	for key in all_opt.keys():
+		if all_opt[key].has_key("getopt") and all_opt[key].has_key("longopt"):
+			print "s/options\[\"-" + all_opt[key]["getopt"].rstrip(":") + "\"\]/options[\"--" + \
+				all_opt[key]["longopt"] + "\"]/g"
+			print "s/options.has_key(\"-" + all_opt[key]["getopt"].rstrip(":") + "\")/options.has_key(" + \
+				"\"--" + all_opt[key]["longopt"] + "\")/g"
+
+
+
+if __name__ == "__main__":
+	main()
\ No newline at end of file
Signature · 1 line
1.7.7.6