Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b88f2dd77... Commit: b88f2dd7729bf5a29dd8619be9412e0f47454e91 Parent: f7b40acb66cd75d459331223d69e006bc2da24ec Author: Marek 'marx' Grac mgrac@redhat.com AuthorDate: Wed Apr 2 13:44:08 2014 +0200 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Wed Apr 9 16:30:25 2014 +0200
[cleanup] Fix invalid names of variables
--- 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 a9ca8fe..3ef7c7b 100644 --- a/fence/agents/cisco_ucs/fence_cisco_ucs.py +++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py @@ -64,9 +64,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: @@ -84,17 +84,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()
logging.debug("%s\n" % command) logging.debug("%s\n" % results) 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 d5c9986..11985d2 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -409,11 +409,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 = ""): @@ -863,10 +863,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 8efdc45..767c098 100644 --- a/fence/agents/rhevm/fence_rhevm.py +++ b/fence/agents/rhevm/fence_rhevm.py @@ -84,22 +84,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()
logging.debug("%s\n" % command) logging.debug("%s\n" % result) 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)
cluster-commits@lists.fedorahosted.org