[Cluster-devel] [PATCH 04/15] [cleanup] Split lines that were too long

Marek 'marx' Grac mgrac at redhat.com
Wed Apr 2 11:52:12 UTC 2014


---
 fence/agents/amt/fence_amt.py                   |  3 +-
 fence/agents/apc/fence_apc.py                   |  6 ++-
 fence/agents/apc_snmp/fence_apc_snmp.py         | 15 +++---
 fence/agents/cisco_ucs/fence_cisco_ucs.py       | 29 ++++++-----
 fence/agents/drac5/fence_drac5.py               |  3 +-
 fence/agents/eaton_snmp/fence_eaton_snmp.py     |  3 +-
 fence/agents/ibmblade/fence_ibmblade.py         |  3 +-
 fence/agents/ilo/fence_ilo.py                   |  6 ++-
 fence/agents/intelmodular/fence_intelmodular.py |  3 +-
 fence/agents/ipmilan/fence_ipmilan.py           |  3 +-
 fence/agents/lib/fencing.py.py                  | 67 +++++++++++++++++--------
 fence/agents/lib/fencing_snmp.py.py             | 19 ++++---
 fence/agents/lpar/fence_lpar.py                 |  6 ++-
 fence/agents/ovh/fence_ovh.py                   | 15 ++++--
 fence/agents/sanbox2/fence_sanbox2.py           |  3 +-
 fence/agents/virsh/fence_virsh.py               |  6 ++-
 fence/agents/vmware/fence_vmware.py             | 15 ++++--
 fence/agents/vmware_soap/fence_vmware_soap.py   |  3 +-
 fence/agents/wti/fence_wti.py                   | 10 ++--
 19 files changed, 140 insertions(+), 78 deletions(-)

diff --git a/fence/agents/amt/fence_amt.py b/fence/agents/amt/fence_amt.py
index 55e3e5b..51022ee 100644
--- a/fence/agents/amt/fence_amt.py
+++ b/fence/agents/amt/fence_amt.py
@@ -103,7 +103,8 @@ def define_new_opts():
 	all_opt["boot_option"] = {
 		"getopt" : "b:",
 		"longopt" : "boot-option",
-		"help" : "-b, --boot-option=[option]     Change the default boot behavior of the machine. (pxe|hd|hdsafe|cd|diag)",
+		"help" : "-b, --boot-option=[option]     "
+				"Change the default boot behavior of the machine. (pxe|hd|hdsafe|cd|diag)",
 		"required" : "0",
 		"shortdesc" : "Change the default boot behavior of the machine.",
 		"choices" : ["pxe", "hd", "hdsafe", "cd", "diag"],
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 71a3d3e..b97bbff 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -69,7 +69,8 @@ def get_power_status(conn, options):
 		conn.send_eol(options["--switch"])
 
 	while True:
-		exp_result = conn.log_expect(options, ["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
+		exp_result = conn.log_expect(options,
+				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
 		show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
 		for x in lines:
@@ -147,7 +148,8 @@ def set_power_status(conn, options):
 	else:
 		conn.send_eol(options["--switch"])
 
-	while 0 == conn.log_expect(options, [ "Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"])):
+	while 0 == conn.log_expect(options,
+			[ "Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"])):
 		conn.send_eol("")
 
 	conn.send_eol(options["--plug"]+"")
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 971919a..b07d04a 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -1,12 +1,15 @@
 #!/usr/bin/python
 
 # The Following agent has been tested on:
-# - APC Switched Rack PDU (MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3 AN1:apc_hw02_aos_270.bin
-#    AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin MN:AP7930 HR:B2) - SNMP v1
-# - APC Web/SNMP Management Card (MB:v3.8.6 PF:v3.5.8 PN:apc_hw02_aos_358.bin AF1:v3.5.7 AN1:apc_hw02_aos_358.bin
-#    AF1:v3.5.7 AN1:apc_hw02_rpdu_357.bin MN:AP7900 HR:B2) - SNMP v1 and v3 (noAuthNoPrivacy,authNoPrivacy, authPrivacy)
-# - APC Switched Rack PDU (MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin
-#    MN:AP7951 HR:B2) - SNMP v1
+# - APC Switched Rack PDU - SNMP v1
+#	(MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3
+#	AN1:apc_hw02_aos_270.bin AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin MN:AP7930 HR:B2)
+# - APC Web/SNMP Management Card - SNMP v1 and v3 (noAuthNoPrivacy,authNoPrivacy, authPrivacy)
+#	(MB:v3.8.6 PF:v3.5.8 PN:apc_hw02_aos_358.bin AF1:v3.5.7
+#       AN1:apc_hw02_aos_358.bin AF1:v3.5.7 AN1:apc_hw02_rpdu_357.bin MN:AP7900 HR:B2)
+# - APC Switched Rack PDU - SNMP v1
+#       (MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3
+#       AN1:apc_hw02_rpdu_273.bin MN:AP7951 HR:B2)
 # - Tripplite PDUMH20HVNET 12.04.0055 - SNMP v1, v2c, v3
 
 import sys
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 9a8ed90..388eda9 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -18,10 +18,9 @@ RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
 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["--suborg"] + \
-		"/ls-" + options["--plug"] + "/power\"/>", \
-		 int(options["--shell-timeout"]))
+	res = send_command(options, "<configResolveDn cookie=\"" + options["cookie"] +
+			"\" inHierarchical=\"false\" dn=\"org-root" + options["--suborg"] + "/ls-" +
+			options["--plug"] + "/power\"/>", int(options["--shell-timeout"]))
 
 	result = RE_STATUS.search(res)
 	if (result == None):
@@ -40,12 +39,11 @@ def set_power_status(conn, options):
 		'off' : "down"
 	}[options["--action"]]
 
-	send_command(options, \
-		"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
-		"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] + "/power\">" + \
-		"<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
-		"</pair></inConfigs></configConfMos>", \
-		int(options["--shell-timeout"]))
+	send_command(options, "<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" +
+			"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] +
+			"/power\">" + "<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" +
+			action + "\" status=\"modified\" />" + "</pair></inConfigs></configConfMos>",
+			int(options["--shell-timeout"]))
 
 	return
 
@@ -53,9 +51,8 @@ def get_list(conn, options):
 	outlets = { }
 
 	try:
-		res = send_command(options, \
-			"<configResolveClass cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" classId=\"lsServer\"/>", \
-			int(options["--shell-timeout"]))
+		res = send_command(options, "<configResolveClass cookie=\"" + options["cookie"] +
+				"\" inHierarchical=\"false\" classId=\"lsServer\"/>", int(options["--shell-timeout"]))
 
 		lines = res.split("<lsServer ")
 		for i in range(1, len(lines)):
@@ -130,7 +127,8 @@ used with Cisco UCS to fence machines."
 
 	### Login
 	try:
-		res = send_command(options, "<aaaLogin inName=\"" + options["--username"] + "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
+		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
@@ -151,7 +149,8 @@ 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["--shell-timeout"]))
+	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />",
+			int(options["--shell-timeout"]))
 
 	sys.exit(result)
 
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 20e2e8a..036f294 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -34,7 +34,8 @@ def get_power_status(conn, options):
 
 		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)
+		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"]:
 		return "on"
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index 0497c75..a329aeb 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -177,7 +177,8 @@ def get_outlets_status(conn, options):
 		# Plug indexing start from zero, so we substract '1' from the
 		# user's given plug number
 		if (device.ident_str == "Eaton Managed ePDU"):
-			port_num = str(int(((device.has_switches) and "%s:%s"%(t[len(t)-3], t[len(t)-1]) or "%s"%(t[len(t)-1]))) + 1)
+			port_num = str(int(((device.has_switches) and
+					"%s:%s"%(t[len(t)-3], t[len(t)-1]) or "%s"%(t[len(t)-1]))) + 1)
 
 			# Plug indexing start from zero, so we add '1'
 			# for the user's exposed plug number
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index 4567861..1e60e7d 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -32,7 +32,8 @@ def get_power_status(conn, options):
 	return (status == str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(CONTROL_OID, options["--plug"]), (options["--action"]=="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 = {}
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index a04aacf..48c829d 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -110,8 +110,10 @@ the iLO card through an XML stream."
 			conn.send("</RIB_INFO>\r\n")
 			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)
+			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")
 	except pexpect.TIMEOUT:
 		fail(EC_LOGIN_DENIED)
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index 3d90707..bd1faee 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -43,7 +43,8 @@ def get_power_status(conn, options):
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(STATUSES_OID, options["--plug"]), (options["--action"]=="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 = {}
diff --git a/fence/agents/ipmilan/fence_ipmilan.py b/fence/agents/ipmilan/fence_ipmilan.py
index ab5a75a..7b37194 100644
--- a/fence/agents/ipmilan/fence_ipmilan.py
+++ b/fence/agents/ipmilan/fence_ipmilan.py
@@ -143,7 +143,8 @@ def define_new_opts():
 	all_opt["privlvl"] = {
 		"getopt" : "L:",
 		"longopt" : "privlvl",
-		"help" : "-L, --privlvl=[level]          Privilege level on IPMI device (callback|user|operator|administrator)",
+		"help" : "-L, --privlvl=[level]          "
+				"Privilege level on IPMI device (callback|user|operator|administrator)",
 		"required" : "0",
 		"shortdesc" : "Privilege level on IPMI device",
 		"default" : "administrator",
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index be925d2..a713dc8 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -173,8 +173,10 @@ all_opt = {
 	"notls" : {
 		"getopt" : "t",
 		"longopt" : "notls",
-		"help" : "-t, --notls                    Disable TLS negotiation and force SSL3.0.\n" +
-	"                                        This should only be used for devices that do not support TLS1.0 and up.",
+		"help" : "-t, --notls                    "
+				"Disable TLS negotiation and force SSL3.0.\n"
+				"                                        "
+				"This should only be used for devices that do not support TLS1.0 and up.",
 		"required" : "0",
 		"shortdesc" : "Disable TLS negotiation",
 		"order" : 1 },
@@ -406,7 +408,6 @@ def add_dependency_options(options):
 			added_opt.extend([y for y in DEPENDENCY_OPT[x] if options.count(y) == 0])
 	return added_opt
 
-
 def version(command, release, build_date, copyright_notice):
 	print command, " ", release, " ", build_date
 	if len(copyright_notice) > 0:
@@ -426,8 +427,8 @@ def fail(error_code):
 		EC_WAITING_ON : "Failed: Timed out waiting to power ON",
 		EC_WAITING_OFF : "Failed: Timed out waiting to power OFF",
 		EC_STATUS : "Failed: Unable to obtain correct plug status or plug is not available",
-		EC_STATUS_HMC :
-			"Failed: Either unable to obtain correct plug status, partition is not available or incorrect HMC version used",
+		EC_STATUS_HMC : "Failed: Either unable to obtain correct plug status, "
+				"partition is not available or incorrect HMC version used",
 		EC_PASSWORD_MISSING : "Failed: You have to set login password",
 		EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action."
 	}[error_code] + "\n"
@@ -453,7 +454,8 @@ def metadata(avail_opt, options, docs):
 	sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"]))
 
 	print "<?xml version=\"1.0\" ?>"
-	print "<resource-agent name=\"" + os.path.basename(sys.argv[0]) + "\" shortdesc=\"" + docs["shortdesc"] + "\" >"
+	print "<resource-agent name=\"" + os.path.basename(sys.argv[0]) + \
+			"\" shortdesc=\"" + docs["shortdesc"] + "\" >"
 	if "symlink" in docs:
 		for (symlink, desc) in docs["symlink"]:
 			print "<symlink name=\"" + symlink + "\" shortdesc=\"" + desc + "\"/>"
@@ -641,7 +643,8 @@ def check_input(device_opt, opt):
 
 	if device_opt.count("ipport"):
 		if options.has_key("--ipport"):
-			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default "+ options["--ipport"] +")"
+			all_opt["ipport"]["help"] = "-u, --ipport=[port]            " + \
+					"TCP/UDP port to use (default " + options["--ipport"] +")"
 		elif options.has_key("--ssh"):
 			all_opt["ipport"]["default"] = 22
 			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default 22)"
@@ -666,7 +669,8 @@ def check_input(device_opt, opt):
 
 	## In special cases (show help, metadata or version) we don't need to check anything
 	#####
-	if options.has_key("--help") or options.has_key("--version") or (options.has_key("--action") and options["--action"].lower() == "metadata"):
+	if options.has_key("--help") or options.has_key("--version") or \
+			(options.has_key("--action") and options["--action"].lower() == "metadata"):
 		return options
 
 	options["--action"] = options["--action"].lower()
@@ -695,7 +699,8 @@ def check_input(device_opt, opt):
 		options["--action"] = "off"
 
 	## automatic detection and set of valid UUID from --plug
-	if (0 == options.has_key("--username")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
+	if (0 == options.has_key("--username")) and \
+			device_opt.count("login") and (device_opt.count("no_login") == 0):
 		fail_usage("Failed: You have to set login name")
 
 	if device_opt.count("ipaddr") and 0 == options.has_key("--ip") and 0 == options.has_key("--managed"):
@@ -706,7 +711,8 @@ def check_input(device_opt, opt):
 			if 0 == (options.has_key("--password") or options.has_key("--password-script")):
 				fail_usage("Failed: You have to enter password or password script")
 		else:
-			if 0 == (options.has_key("--password") or options.has_key("--password-script") or options.has_key("--identity-file")):
+			if 0 == (options.has_key("--password") or \
+					options.has_key("--password-script") or options.has_key("--identity-file")):
 				fail_usage("Failed: You have to enter password, password script or identity file")
 
 	if 0 == options.has_key("--ssh") and 1 == options.has_key("--identity-file"):
@@ -745,7 +751,8 @@ def check_input(device_opt, opt):
 		else:
 			options["--ipport"] = 23
 
-	if options.has_key("--plug") and len(options["--plug"].split(",")) > 1 and options.has_key("--method") and options["--method"] == "cycle":
+	if options.has_key("--plug") and len(options["--plug"].split(",")) > 1 and \
+			options.has_key("--method") and options["--method"] == "cycle":
 		fail_usage("Failed: Cannot use --method cycle for more than 1 plug")
 
 	for opt in device_opt:
@@ -755,7 +762,9 @@ def check_input(device_opt, opt):
 			if options.has_key(long):
 				options[long] = options[long].upper()
 				if not options["--" + all_opt[opt]["longopt"]] in possible_values_upper:
-					fail_usage("Failed: You have to enter a valid choice for %s from the valid values: %s" % ("--" + all_opt[opt]["longopt"] , str(all_opt[opt]["choices"])))
+					fail_usage("Failed: You have to enter a valid choice " + \
+							"for %s from the valid values: %s" % \
+							("--" + all_opt[opt]["longopt"] , str(all_opt[opt]["choices"])))
 
 	return options
 
@@ -846,7 +855,8 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 			## None as soon as all existing agent will support this operation
 			print "NOTICE: List option is not working on this device yet"
 			return
-		elif (options["--action"] == "list") or ((options["--action"] == "monitor") and 1 == options["device_opt"].count("port")):
+		elif (options["--action"] == "list") or \
+				((options["--action"] == "monitor") and 1 == options["device_opt"].count("port")):
 			outlets = get_outlet_list(tn, options)
 			## keys can be numbers (port numbers) or strings (names of VM)
 			for o in outlets.keys():
@@ -971,7 +981,8 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(userna
 			if options.has_key("--notls"):
 				gnutls_opts = "--priority \"NORMAL:-VERS-TLS1.2:-VERS-TLS1.1:-VERS-TLS1.0:+VERS-SSL3.0\""
 
-			command = '%s %s --insecure --crlf -p %s %s' % (SSL_PATH, gnutls_opts, options["--ipport"], options["--ip"])
+			command = '%s %s --insecure --crlf -p %s %s' % \
+					(SSL_PATH, gnutls_opts, options["--ipport"], options["--ip"])
 			try:
 				conn = fspawn(options, command)
 			except pexpect.ExceptionPexpect, ex:
@@ -979,15 +990,19 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(userna
 				syslog.syslog(syslog.LOG_ERR, str(ex))
 				sys.exit(EC_GENERIC_ERROR)
 		elif options.has_key("--ssh") and 0 == options.has_key("--identity-file"):
-			command = '%s %s %s@%s -p %s -o PubkeyAuthentication=no' % (SSH_PATH, force_ipvx, options["--username"], options["--ip"], options["--ipport"])
+			command = '%s %s %s@%s -p %s -o PubkeyAuthentication=no' % \
+					(SSH_PATH, force_ipvx, options["--username"], options["--ip"], options["--ipport"])
 			if options.has_key("--ssh-options"):
 				command += ' ' + options["--ssh-options"]
 
 			conn = fspawn(options, command)
 
 			if options.has_key("telnet_over_ssh"):
-				#This is for stupid ssh servers (like ALOM) which behave more like telnet (ignore name and display login prompt)
-				result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], int(options["--login-timeout"]))
+				# This is for stupid ssh servers (like ALOM) which behave more like telnet
+				# (ignore name and display login prompt)
+				result = conn.log_expect(options, \
+						[ re_login, "Are you sure you want to continue connecting (yes/no)?" ],
+						int(options["--login-timeout"]))
 				if result == 1:
 					conn.sendline("yes") # Host identity confirm
 					conn.log_expect(options, re_login, int(options["--login-timeout"]))
@@ -995,7 +1010,9 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(userna
 				conn.sendline(options["--username"])
 				conn.log_expect(options, re_pass, int(options["--login-timeout"]))
 			else:
-				result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], int(options["--login-timeout"]))
+				result = conn.log_expect(options, \
+						[ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ],
+						int(options["--login-timeout"]))
 				if result == 1:
 					conn.sendline("yes")
 					conn.log_expect(options, "ssword:", int(options["--login-timeout"]))
@@ -1003,17 +1020,22 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(userna
 			conn.sendline(options["--password"])
 			conn.log_expect(options, options["--command-prompt"], int(options["--login-timeout"]))
 		elif options.has_key("--ssh") and options.has_key("--identity-file"):
-			command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["--username"], options["--ip"], options["--identity-file"], options["--ipport"])
+			command = '%s %s %s@%s -i %s -p %s' % \
+					(SSH_PATH, force_ipvx, options["--username"], options["--ip"], \
+					options["--identity-file"], options["--ipport"])
 			if options.has_key("--ssh-options"):
 				command += ' ' + options["--ssh-options"]
 
 			conn = fspawn(options, command)
 
 			result = conn.log_expect(options, [ "Enter passphrase for key '" + options["--identity-file"] + "':", \
-				"Are you sure you want to continue connecting (yes/no)?" ] + options["--command-prompt"], int(options["--login-timeout"]))
+					"Are you sure you want to continue connecting (yes/no)?" ] + \
+					options["--command-prompt"], int(options["--login-timeout"]))
 			if result == 1:
 				conn.sendline("yes")
-				result = conn.log_expect(options, [ "Enter passphrase for key '"+options["--identity-file"]+"':"] + options["--command-prompt"], int(options["--login-timeout"]))
+				result = conn.log_expect(options,
+					[ "Enter passphrase for key '" + options["--identity-file"]+"':"] + \
+					options["--command-prompt"], int(options["--login-timeout"]))
 			if result == 0:
 				if options.has_key("--password"):
 					conn.sendline(options["--password"])
@@ -1039,7 +1061,8 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(userna
 
 			try:
 				conn.send_eol(options["--password"])
-				valid_password = conn.log_expect(options, [ re_login ] + options["--command-prompt"], int(options["--shell-timeout"]))
+				valid_password = conn.log_expect(options, [ re_login ] + \
+						options["--command-prompt"], int(options["--shell-timeout"]))
 				if valid_password == 0:
 					## password is invalid or we have to change EOL separator
 					options["eol"] = "\r"
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 0112494..3faa295 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -29,10 +29,13 @@ class FencingSnmp:
 		return ''.join(map(lambda x:x==r"'" and "'\\''" or x, string))
 
 	def complete_missed_params(self):
-		mapping = [
-			[['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"']
-			]
+		mapping = [[
+					['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:
 			e = val[0]
@@ -88,7 +91,10 @@ class FencingSnmp:
 		try:
 			self.log_command(command)
 
-			(res_output, res_code) = pexpect.run(command, int(self.options["--shell-timeout"]) + int(self.options["--login-timeout"]) + 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)
@@ -119,7 +125,8 @@ class FencingSnmp:
 				type_of_value = item[1]
 				break
 
-		cmd = "%s '%s' %s '%s'"% (self.prepare_cmd("snmpset"), self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value)))
+		cmd = "%s '%s' %s '%s'" % (self.prepare_cmd("snmpset"),
+				self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value)))
 
 		self.run_command(cmd, additional_timemout)
 
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index c4237f2..438acae 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -27,11 +27,13 @@ def get_power_status(conn, options):
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 		try:
-			status = re.compile("^" + options["--plug"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+			status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
+					re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 		except AttributeError:
 			fail(EC_STATUS_HMC)
 	elif options["--hmc-version"] == "4":
-		conn.send("lssyscfg -r lpar -m "+ options["--managed"] +" --filter 'lpar_names=" + options["--plug"] + "'\n")
+		conn.send("lssyscfg -r lpar -m "+ options["--managed"] +
+				" --filter 'lpar_names=" + options["--plug"] + "'\n")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 		try:
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index 4d2d9cb..647343c 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -40,7 +40,8 @@ def netboot_reboot(options, mode):
 	conn.service.dedicatedNetbootModifyById(options["session"], options["--plug"], mode, '', options["--email"])
 
 	# dedicatedHardRebootDo initiates a hard reboot on the given node
-	conn.service.dedicatedHardRebootDo(options["session"], options["--plug"], 'Fencing initiated by cluster', '', 'en')
+	conn.service.dedicatedHardRebootDo(options["session"],
+			options["--plug"], 'Fencing initiated by cluster', '', 'en')
 
 	conn.logout(options["session"])
 
@@ -124,10 +125,14 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 	reboot_t = reboot_time(options)
 
 	if options.has_key("--verbose"):
-		options["debug_fh"].write("reboot_start_end.start: "+ reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("before_netboot_reboot: " + before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("reboot_start_end.end: "  + reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("after_netboot_reboot: "  + after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("reboot_start_end.start: " +
+				reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("before_netboot_reboot: " +
+				before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("reboot_start_end.end: " +
+				reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("after_netboot_reboot: " +
+				after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
 
 	if reboot_t.start < after_netboot_reboot < reboot_t.end:
 		result = 0
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 86b646b..e0c0647 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -36,7 +36,8 @@ def get_power_status(conn, options):
 			pass
 		fail(EC_TIMED_OUT)
 
-	status = re.compile(".*AdminState\s+(online|offline)\s+", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+	status = re.compile(".*AdminState\s+(online|offline)\s+",
+			re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 
 	try:
 		return status_trans[status.lower().strip()]
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 0ebf668..29d3e58 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -40,7 +40,8 @@ def get_outlets_status(conn, options):
 			if ((fa_status==0) and (domain.group(1).lower()=="id") and (domain.group(2).lower()=="name")):
 				fa_status = 1
 			elif (fa_status==1):
-				result[domain.group(2)] = ("", (domain.group(3).lower() in ["running", "blocked", "idle", "no state", "paused"] and "on" or "off"))
+				result[domain.group(2)] = ("",
+						(domain.group(3).lower() in ["running", "blocked", "idle", "no state", "paused"] and "on" or "off"))
 	return result
 
 def get_power_status(conn, options):
@@ -58,7 +59,8 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	prefix = SUDO_PATH + " " if options.has_key("--use-sudo") else ""
-	conn.sendline(prefix + "virsh %s "%(options["--action"] == "on" and "start" or "destroy") + get_name_or_uuid(options))
+	conn.sendline(prefix + "virsh %s " %
+			(options["--action"] == "on" and "start" or "destroy") + get_name_or_uuid(options))
 
 	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	time.sleep(int(options["--power-wait"]))
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index c6209e8..8b76103 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -149,7 +149,8 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
 	try:
 		vmware_log(options, command)
 
-		(res_output, res_code) = pexpect.run(command, int(options["--shell-timeout"])+int(options["--login-timeout"])+additional_timeout, True)
+		(res_output, res_code) = pexpect.run(command,
+				int(options["--shell-timeout"]) + int(options["--login-timeout"]) + additional_timeout, True)
 
 		if (res_code==None):
 			fail(EC_TIMED_OUT)
@@ -170,7 +171,8 @@ def vmware_get_outlets_vi(conn, options, add_vm_name):
 	outlets = {}
 
 	if (add_vm_name):
-		all_machines = vmware_run_command(options, True, ("--operation status --vmname '%s'"% (quote_for_run(options["--plug"]))), 0)
+		all_machines = vmware_run_command(options, True,
+				("--operation status --vmname '%s'"% (quote_for_run(options["--plug"]))), 0)
 	else:
 		all_machines = vmware_run_command(options, True, "--operation list", int(options["--power-timeout"]))
 
@@ -232,9 +234,11 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
-		additional_params = "--operation %s --vmname '%s'"% ((options["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
+		additional_params = "--operation %s --vmname '%s'" % \
+				((options["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
 	elif ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
-		additional_params = "%s '%s'"% ((options["--action"]=="on" and "start" or "stop"), quote_for_run(options["--plug"]))
+		additional_params = "%s '%s'" % \
+				((options["--action"]=="on" and "start" or "stop"), quote_for_run(options["--plug"]))
 		if (options["--action"]=="off"):
 			additional_params += " hard"
 
@@ -323,7 +327,8 @@ This agent supports only vmrun from version 2.0.0 (VIX API 1.6.0)."
 	# Test user vmrun command version
 	if ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
 		if (not (vmware_is_supported_vmrun_version(options))):
-			fail_usage("Unsupported version of vmrun command! You must use at least version %d!"%(VMRUN_MINIMUM_REQUIRED_VERSION))
+			fail_usage("Unsupported version of vmrun command! You must use at least version %d!" %
+					(VMRUN_MINIMUM_REQUIRED_VERSION))
 
 	# Operate the fencing device
 	result = fence_action(None, options, set_power_status, get_power_status, get_outlets_status)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 8110c9e..6fa3cd6 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -73,7 +73,8 @@ def get_power_status(conn, options):
 	mo_PropertyCollector = Property(options["ServiceContent"].propertyCollector.value)
 	mo_PropertyCollector._type = 'PropertyCollector'
 
-	ContainerView = conn.service.CreateContainerView(mo_ViewManager, recursive = 1, container = mo_RootFolder, type = ['VirtualMachine'])
+	ContainerView = conn.service.CreateContainerView(mo_ViewManager, recursive = 1,
+			container = mo_RootFolder, type = ['VirtualMachine'])
 	mo_ContainerView = Property(ContainerView.value)
 	mo_ContainerView._type = "ContainerView"
 
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 9b7aa39..1cb3356 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -58,7 +58,8 @@ def get_plug_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["--action"]) == 0 and options["--plug"].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
@@ -94,11 +95,14 @@ def get_plug_group_status(conn, options):
 		line = lines[line_index]
 		if (line.find("|") >= 0 and line.lstrip().startswith("GROUP NAME") == False):
 			plug_line = [x.strip().lower() for x in line.split("|")]
-			if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[name_index]:
+			if ["list", "monitor"].count(options["--action"]) == 0 and \
+					options["--plug"].lower() == plug_line[name_index]:
 				plug_status = []
 				while line_index < len(lines) and line_index >= 0:
 					plug_line = [x.strip().lower() for x in lines[line_index].split("|")]
-					if len(plug_line) >= max(name_index, status_index) and len(plug_line[plug_index]) > 0 and (len(plug_line[name_index]) == 0 or options["--plug"].lower() == plug_line[name_index]):
+					if len(plug_line) >= max(name_index, status_index) and \
+							len(plug_line[plug_index]) > 0 and \
+							(len(plug_line[name_index]) == 0 or options["--plug"].lower() == plug_line[name_index]):
 						## Firmware 1.43 does not have a valid value of plug on first line as only name is defined on that line
 						if not "---" in plug_line[status_index]:
 							plug_status.append(plug_line[status_index])
-- 
1.9.0




More information about the Cluster-devel mailing list