From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek 'marx' Grac Date: Wed, 2 Apr 2014 13:52:23 +0200 Subject: [Cluster-devel] [PATCH 15/15] [cleanup] Fix invalid names of variables In-Reply-To: <1396439543-29533-1-git-send-email-mgrac@redhat.com> References: <1396439543-29533-1-git-send-email-mgrac@redhat.com> Message-ID: <1396439543-29533-15-git-send-email-mgrac@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit --- 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 " ] + 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("= 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, "") + conn.setopt(pycurl.POSTFIELDS, "") - 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