[Cluster-devel] [PATCH 15/15] [cleanup] Fix invalid names of variables

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


---
 fence/agents/apc/fence_apc.py             |  8 ++++----
 fence/agents/brocade/fence_brocade.py     |  4 ++--
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 26 +++++++++++++-------------
 fence/agents/lib/check_used_options.py    |  8 ++++----
 fence/agents/lib/fencing.py.py            | 14 +++++++-------
 fence/agents/rhevm/fence_rhevm.py         | 26 +++++++++++++-------------
 fence/agents/xenapi/fence_xenapi.py       |  4 ++--
 7 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 1e86c07..f744583 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -74,8 +74,8 @@ def get_power_status(conn, options):
 				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
 		show_re = re.compile(r'(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
-		for x in lines:
-			res = show_re.search(x)
+		for line in lines:
+			res = show_re.search(line)
 			if (res != None):
 				outlets[res.group(2)] = (res.group(3), res.group(4))
 		conn.send_eol("")
@@ -187,8 +187,8 @@ def get_power_status5(conn, options):
 
 	show_re = re.compile(r'^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
 
-	for x in lines:
-		res = show_re.search(x)
+	for line in lines:
+		res = show_re.search(line)
 		if (res != None):
 			outlets[res.group(1)] = (res.group(2), res.group(3))
 
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
index a60355d..35082ee 100644
--- a/fence/agents/brocade/fence_brocade.py
+++ b/fence/agents/brocade/fence_brocade.py
@@ -20,8 +20,8 @@ def get_power_status(conn, options):
 	show_re = re.compile(r'^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
 	lines = conn.before.split("\n")
 
-	for x in lines:
-		res = show_re.search(x)
+	for line in lines:
+		res = show_re.search(line)
 		if (res != None):
 			# We queried if it is disabled, so we have to negate answer
 			if res.group(1) == "ON":
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index d073af6..ee1ae11 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -63,9 +63,9 @@ def get_list(conn, options):
 
 		lines = res.split("<lsServer ")
 		for i in range(1, len(lines)):
-			dn = RE_GET_DN.search(lines[i]).group(1)
+			node_name = RE_GET_DN.search(lines[i]).group(1)
 			desc = RE_GET_DESC.search(lines[i]).group(1)
-			outlets[dn] = (desc, None)
+			outlets[node_name] = (desc, None)
 	except AttributeError:
 		return { }
 	except IndexError:
@@ -83,17 +83,17 @@ def send_command(opt, command, timeout):
 	url += "//" + opt["--ip"] + ":" + str(opt["--ipport"]) + "/nuova"
 
 	## send command through pycurl
-	c = pycurl.Curl()
-	b = StringIO.StringIO()
-	c.setopt(pycurl.URL, url)
-	c.setopt(pycurl.HTTPHEADER, [ "Content-type: text/xml" ])
-	c.setopt(pycurl.POSTFIELDS, command)
-	c.setopt(pycurl.WRITEFUNCTION, b.write)
-	c.setopt(pycurl.TIMEOUT, timeout)
-	c.setopt(pycurl.SSL_VERIFYPEER, 0)
-	c.setopt(pycurl.SSL_VERIFYHOST, 0)
-	c.perform()
-	result = b.getvalue()
+	conn = pycurl.Curl()
+	web_buffer = StringIO.StringIO()
+	conn.setopt(pycurl.URL, url)
+	conn.setopt(pycurl.HTTPHEADER, [ "Content-type: text/xml" ])
+	conn.setopt(pycurl.POSTFIELDS, command)
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
+	conn.setopt(pycurl.TIMEOUT, timeout)
+	conn.setopt(pycurl.SSL_VERIFYPEER, 0)
+	conn.setopt(pycurl.SSL_VERIFYHOST, 0)
+	conn.perform()
+	result = web_buffer.getvalue()
 
 	if opt["log"] >= LOG_MODE_VERBOSE:
 		opt["debug_fh"].write(command + "\n")
diff --git a/fence/agents/lib/check_used_options.py b/fence/agents/lib/check_used_options.py
index ce74fa9..7f821b1 100755
--- a/fence/agents/lib/check_used_options.py
+++ b/fence/agents/lib/check_used_options.py
@@ -46,13 +46,13 @@ def main():
 	for line in agent_file:
 		counter += 1
 
-		for x in option_use_re.findall(line):
-			if not available.has_key(x):
+		for option in option_use_re.findall(line):
+			if not available.has_key(option):
 				print "ERROR on line %d in %s: option %s is not defined" % (counter, agent, option_use_re.search(line).group(1))
 				without_errors = False
 
-		for x in option_has_re.findall(line):
-			if not available.has_key(x):
+		for option in option_has_re.findall(line):
+			if not available.has_key(option):
 				print "ERROR on line %d in %s: option %s is not defined" % (counter, agent, option_has_re.search(line).group(1))
 				without_errors = False
 
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index fe4d9c4..013ae68 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -404,11 +404,11 @@ def atexit_handler():
 		sys.exit(EC_GENERIC_ERROR)
 
 def add_dependency_options(options):
-	## Add options which are available for every fence agent
+	## Add also options which are available for every fence agent
 	added_opt = []
-	for x in options + ["default"]:
-		if DEPENDENCY_OPT.has_key(x):
-			added_opt.extend([y for y in DEPENDENCY_OPT[x] if options.count(y) == 0])
+	for opt in options + ["default"]:
+		if DEPENDENCY_OPT.has_key(opt):
+			added_opt.extend([y for y in DEPENDENCY_OPT[opt] if options.count(y) == 0])
 	return added_opt
 
 def fail_usage(message = ""):
@@ -860,10 +860,10 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 				((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():
-				(alias, status) = outlets[o]
+			for outlet_id in outlets.keys():
+				(alias, status) = outlets[outlet_id]
 				if options["--action"] != "monitor":
-					print o + options["--separator"] + alias
+					print outled_id + options["--separator"] + alias
 			return
 
 		status = get_multi_power_fn(tn, options, get_power_fn)
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 2529801..b1c97e4 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -83,22 +83,22 @@ def send_command(opt, command, method = "GET"):
 	url += "//" + opt["--ip"] + ":" + str(opt["--ipport"]) + "/api/" + command
 
 	## send command through pycurl
-	c = pycurl.Curl()
-	b = StringIO.StringIO()
-	c.setopt(pycurl.URL, url)
-	c.setopt(pycurl.HTTPHEADER, [ "Content-type: application/xml", "Accept: application/xml" ])
-	c.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
-	c.setopt(pycurl.USERPWD, opt["--username"] + ":" + opt["--password"])
-	c.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
-	c.setopt(pycurl.SSL_VERIFYPEER, 0)
-	c.setopt(pycurl.SSL_VERIFYHOST, 0)
+	conn = pycurl.Curl()
+	web_buffer = StringIO.StringIO()
+	conn.setopt(pycurl.URL, url)
+	conn.setopt(pycurl.HTTPHEADER, [ "Content-type: application/xml", "Accept: application/xml" ])
+	conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
+	conn.setopt(pycurl.USERPWD, opt["--username"] + ":" + opt["--password"])
+	conn.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
+	conn.setopt(pycurl.SSL_VERIFYPEER, 0)
+	conn.setopt(pycurl.SSL_VERIFYHOST, 0)
 
 	if (method == "POST"):
-		c.setopt(pycurl.POSTFIELDS, "<action />")
+		conn.setopt(pycurl.POSTFIELDS, "<action />")
 
-	c.setopt(pycurl.WRITEFUNCTION, b.write)
-	c.perform()
-	result = b.getvalue()
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
+	conn.perform()
+	result = web_buffer.getvalue()
 
 	if opt["log"] >= LOG_MODE_VERBOSE:
 		opt["debug_fh"].write(command + "\n")
diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py
index 3b6454c..2a52c98 100644
--- a/fence/agents/xenapi/fence_xenapi.py
+++ b/fence/agents/xenapi/fence_xenapi.py
@@ -217,10 +217,10 @@ the status of virtual machines running on the host."
 	docs["vendorurl"] = "http://www.xenproject.org"
 	show_docs(options, docs)
 
-	xenSession = connect_and_login(options)
+	xen_session = connect_and_login(options)
 
 	# Operate the fencing device
-	result = fence_action(xenSession, options, set_power_fn, get_power_fn, get_outlet_list)
+	result = fence_action(xen_session, options, set_power_fn, get_power_fn, get_outlet_list)
 
 	sys.exit(result)
 
-- 
1.9.0




More information about the Cluster-devel mailing list