Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=614e01...
Commit: 614e01c03d5ff5356caf0652baf9898f3c882d6f
Parent: db1d7376180a0d4329a8ab5fe78690b0c77fa2c3
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Nov 5 14:52:37 2012 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Nov 5 14:53:23 2012 +0100
code cleanup: Fix warnings according to pylint and typos
* remove unused 'global'
* typos
* start with renaming global variables from foo to FOO (python convention)
---
fence/agents/apc/fence_apc.py | 1 +
fence/agents/apc_snmp/fence_apc_snmp.py | 8 +---
fence/agents/bladecenter/fence_bladecenter.py | 4 +-
fence/agents/cisco_mds/fence_cisco_mds.py | 14 ++----
fence/agents/cisco_ucs/fence_cisco_ucs.py | 32 ++++++++----
fence/agents/eaton_snmp/fence_eaton_snmp.py | 8 +--
fence/agents/hpblade/fence_hpblade.py | 8 ++--
fence/agents/ibmblade/fence_ibmblade.py | 12 ++--
fence/agents/ifmib/fence_ifmib.py | 2 -
fence/agents/intelmodular/fence_intelmodular.py | 2 -
fence/agents/ipdu/fence_ipdu.py | 10 +---
fence/agents/lib/fencing.py.py | 58 ++++++++++------------
fence/agents/lpar/fence_lpar.py | 10 ++--
fence/agents/rhevm/fence_rhevm.py | 13 ++---
fence/agents/vmware/fence_vmware.py | 2 +-
fence/agents/wti/fence_wti.py | 1 -
16 files changed, 83 insertions(+), 102 deletions(-)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index d0ed9b6..fa1c3a6 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -153,6 +153,7 @@ def set_power_status(conn, options):
while 1 == conn.log_expect(options, [ options["-c"], "Press
<ENTER>" ], int(options["-Y"])):
conn.send_eol("")
+
conn.send_eol(options["-n"]+"")
conn.log_expect(options, options["-c"], int(options["-Y"]))
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py
b/fence/agents/apc_snmp/fence_apc_snmp.py
index cc624a1..6f95f37 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -88,7 +88,7 @@ def apc_set_device(conn, options):
conn.log_command("Trying %s"%(device.ident_str))
def apc_resolv_port_id(conn, options):
- global port_id, switch_id, device
+ global port_id, switch_id
if (device == None):
apc_set_device(conn, options)
@@ -115,8 +115,6 @@ def apc_resolv_port_id(conn, options):
fail_usage("Can't find port with name %s!"%(options["-n"]))
def get_power_status(conn, options):
- global port_id, switch_id, device
-
if (port_id == None):
apc_resolv_port_id(conn, options)
@@ -126,8 +124,6 @@ def get_power_status(conn, options):
return (status==str(device.state_on) and "on" or "off")
def set_power_status(conn, options):
- global port_id, switch_id, device
-
if (port_id == None):
apc_resolv_port_id(conn, options)
@@ -137,8 +133,6 @@ def set_power_status(conn, options):
def get_outlets_status(conn, options):
- global device
-
result = {}
if (device == None):
diff --git a/fence/agents/bladecenter/fence_bladecenter.py
b/fence/agents/bladecenter/fence_bladecenter.py
index 49a3b5b..2825dbe 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -80,8 +80,8 @@ def get_blades_list(conn, options):
lines = conn.before.split("\r\n")
filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
- for x in lines:
- res = filter_re.search(x)
+ for blade_line in lines:
+ res = filter_re.search(blade_line)
if res != None:
outlets[res.group(1)] = (res.group(2), "")
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py
b/fence/agents/cisco_mds/fence_cisco_mds.py
index 8f3ef9d..8ebce8a 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -27,7 +27,7 @@ PORTS_OID = ".1.3.6.1.2.1.2.2.1.2"
### GLOBAL VARIABLES ###
# OID converted from fc port name (fc(x)/(y))
-port_oid = ""
+PORT_OID = ""
### FUNCTIONS ###
@@ -43,15 +43,11 @@ def cisco_port2oid(port):
fail_usage("Mangled port number: %s"%(port))
def get_power_status(conn, options):
- global port_oid
-
- (oid, status) = conn.get(port_oid)
+ (oid, status) = conn.get(PORT_OID)
return (status=="1" and "on" or "off")
def set_power_status(conn, options):
- global port_oid
-
- conn.set(port_oid,(options["-o"]=="on" and 1 or 2))
+ conn.set(PORT_OID, (options["-o"]=="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
@@ -79,7 +75,7 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- global port_oid
+ global PORT_OID
device_opt = [ "fabric_fencing", "ipaddr", "login",
"passwd", "passwd_script",
"test", "port", "separator", "no_login",
"no_password",
@@ -101,7 +97,7 @@ which can be used with any Cisco MDS 9000 series with SNMP enabled
device."
show_docs(options, docs)
if (not (options["-o"] in ["list","monitor"])):
- port_oid = cisco_port2oid(options["-n"])
+ PORT_OID = cisco_port2oid(options["-n"])
# Operate the fencing device
result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status,
get_outlets_status)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py
b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index a34a580..d1d5f2b 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -11,19 +11,22 @@ REDHAT_COPYRIGHT=""
BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
-re_cookie = re.compile("<aaaLogin .* outCookie=\"(.*?)\"",
re.IGNORECASE)
-re_status = re.compile("<lsPower .*? state=\"(.*?)\"",
re.IGNORECASE)
-re_get_dn = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
-re_get_desc = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
+RE_COOKIE = re.compile("<aaaLogin .* outCookie=\"(.*?)\"",
re.IGNORECASE)
+RE_STATUS = re.compile("<lsPower .*? state=\"(.*?)\"",
re.IGNORECASE)
+RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
+RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
def get_power_status(conn, options):
try:
- res = send_command(options, "<configResolveDn cookie=\"" +
options["cookie"] + "\" inHierarchical=\"false\"
dn=\"org-root" + options["-s"] + "/ls-" +
options["-n"] + "/power\"/>", int(options["-Y"]))
+ res = send_command(options, \
+ "<configResolveDn cookie=\"" + options["cookie"] +
"\" inHierarchical=\"false\" dn=\"org-root" +
options["-s"] + \
+ "/ls-" + options["-n"] + "/power\"/>", \
+ int(options["-Y"]))
except pycurl.error, e:
sys.stderr.write(e[1] + "\n")
fail(EC_TIMED_OUT)
- result = re_status.search(res)
+ result = RE_STATUS.search(res)
if (result == None):
fail(EC_STATUS)
else:
@@ -41,7 +44,12 @@ def set_power_status(conn, options):
}[options["-o"]]
try:
- 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\"
/></pair></inConfigs></configConfMos>",
int(options["-Y"]))
+ 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\" />" + \
+ "</pair></inConfigs></configConfMos>", \
+ int(options["-Y"]))
except pycurl.error, e:
sys.stderr.write(e[1] + "\n")
fail(EC_TIMED_OUT)
@@ -53,15 +61,17 @@ def get_list(conn, options):
try:
try:
- res = send_command(options, "<configResolveClass cookie=\"" +
options["cookie"] + "\" inHierarchical=\"false\"
classId=\"lsServer\"/>", int(options["-Y"]))
+ res = send_command(options, \
+ "<configResolveClass cookie=\"" + options["cookie"] +
"\" inHierarchical=\"false\"
classId=\"lsServer\"/>", \
+ int(options["-Y"]))
except pycurl.error, e:
sys.stderr.write(e[1] + "\n")
fail(EC_TIMED_OUT)
lines = res.split("<lsServer ")
for i in range(1, len(lines)):
- dn = re_get_dn.search(lines[i]).group(1)
- desc = re_get_desc.search(lines[i]).group(1)
+ dn = RE_GET_DN.search(lines[i]).group(1)
+ desc = RE_GET_DESC.search(lines[i]).group(1)
outlets[dn] = (desc, None)
except AttributeError:
return { }
@@ -116,7 +126,7 @@ used with Cisco UCS to fence machines."
### Login
res = send_command(options, "<aaaLogin inName=\"" +
options["-l"] + "\" inPassword=\"" + options["-p"]
+ "\" />", int(options["-y"]))
- result = re_cookie.search(res)
+ result = RE_COOKIE.search(res)
if (result == None):
## Cookie is absenting in response
fail(EC_LOGIN_DENIED)
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py
b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index 24e29fe..2c5017b 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -82,7 +82,7 @@ def eaton_set_device(conn, options):
conn.log_command("Trying %s"%(device.ident_str))
def eaton_resolv_port_id(conn, options):
- global port_id, switch_id, device
+ global port_id, switch_id
if (device==None):
eaton_set_device(conn, options)
@@ -119,7 +119,7 @@ def eaton_resolv_port_id(conn, options):
fail_usage("Can't find port with name %s!"%(options["-n"]))
def get_power_status(conn, options):
- global port_id, switch_id, device, after_set
+ global port_id, after_set
if (port_id==None):
eaton_resolv_port_id(conn, options)
@@ -143,7 +143,7 @@ def get_power_status(conn, options):
return None
def set_power_status(conn, options):
- global port_id, switch_id, device, after_set
+ global port_id, after_set
after_set = True
@@ -160,8 +160,6 @@ def set_power_status(conn, options):
def get_outlets_status(conn, options):
- global device
-
outletCount = 0
result = {}
diff --git a/fence/agents/hpblade/fence_hpblade.py
b/fence/agents/hpblade/fence_hpblade.py
index 2953ddc..c7ceb19 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -60,9 +60,9 @@ def get_blades_list(conn, options):
list_re = re.compile("^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
for line in conn.before.splitlines():
- res = list_re.search(line)
- if res != None:
- outlets[res.group(1)] = (res.group(2), res.group(4).lower())
+ res = list_re.search(line)
+ if res != None:
+ outlets[res.group(1)] = (res.group(2), res.group(4).lower())
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -81,7 +81,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = { }
docs["shortdesc"] = "Fence agent for HP BladeSystem"
docs["longdesc"] = "fence_hpblade is an I/O Fencing agent \
which can be used with HP BladeSystem. It logs into an enclosure via telnet or ssh \
diff --git a/fence/agents/ibmblade/fence_ibmblade.py
b/fence/agents/ibmblade/fence_ibmblade.py
index f9ee955..ceb747d 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -27,22 +27,22 @@ STATUS_SET_ON = 1
### FUNCTIONS ###
def get_power_status(conn, options):
- (oid,status) = conn.get("%s.%s"%(STATUSES_OID, options["-n"]))
- return (status==str(STATUS_UP) and "on" or "off")
+ (_, status) = conn.get("%s.%s"% (STATUSES_OID, options["-n"]))
+ 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))
-def get_outlets_status(conn, options):
+def get_outlets_status(conn, _):
result = {}
res_blades = conn.walk(STATUSES_OID, 30)
- for x in res_blades:
- port_num = x[0].split('.')[-1]
+ for blade_info in res_blades:
+ port_num = blade_info[0].split('.')[-1]
port_alias = ""
- port_status = (x[1]==str(STATUS_UP) and "on" or "off")
+ port_status = (blade_info[1]==str(STATUS_UP) and "on" or "off")
result[port_num] = (port_alias, port_status)
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index fc96fb3..170134e 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -95,8 +95,6 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- global port_oid
-
device_opt = [ "fabric_fencing", "ipaddr", "login",
"passwd", "passwd_script",
"test", "port", "separator", "no_login",
"no_password",
"snmp_version", "community", "snmp_auth_prot",
"snmp_sec_level",
diff --git a/fence/agents/intelmodular/fence_intelmodular.py
b/fence/agents/intelmodular/fence_intelmodular.py
index 32d8449..3fd9822 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -61,8 +61,6 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- global port_oid
-
device_opt = [ "ipaddr", "login", "passwd",
"passwd_script",
"test", "port", "separator", "no_login",
"no_password",
"snmp_version", "community", "snmp_auth_prot",
"snmp_sec_level",
diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py
index 354a037..da7f192 100644
--- a/fence/agents/ipdu/fence_ipdu.py
+++ b/fence/agents/ipdu/fence_ipdu.py
@@ -60,7 +60,7 @@ def ipdu_set_device(conn, options):
conn.log_command("Trying %s"%(device.ident_str))
def ipdu_resolv_port_id(conn, options):
- global port_id, switch_id, device
+ global port_id, switch_id
if (device==None):
ipdu_set_device(conn, options)
@@ -87,8 +87,6 @@ def ipdu_resolv_port_id(conn, options):
fail_usage("Can't find port with name %s!"%(options["-n"]))
def get_power_status(conn, options):
- global port_id, switch_id, device
-
if (port_id==None):
ipdu_resolv_port_id(conn, options)
@@ -98,8 +96,6 @@ def get_power_status(conn, options):
return (status==str(device.state_on) and "on" or "off")
def set_power_status(conn, options):
- global port_id, switch_id, device
-
if (port_id==None):
ipdu_resolv_port_id(conn, options)
@@ -109,11 +105,9 @@ def set_power_status(conn, options):
def get_outlets_status(conn, options):
- global device
-
result = {}
- if (device==None):
+ if (device == None):
ipdu_set_device(conn, options)
res_ports = conn.walk(device.outlet_table_oid, 30)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index ea0ca09..af21696 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,9 +1,7 @@
#!/usr/bin/python
import sys, getopt, time, os
-import pexpect, re
-import telnetlib
-import atexit
+import pexpect, re, atexit
import __main__
## do not add code here.
@@ -403,7 +401,7 @@ all_opt = {
"order" : 205}
}
-common_opt = [ "help", "debug", "verbose",
"quiet", "version", "action", "agent",
+COMMON_OPT = [ "help", "debug", "verbose",
"quiet", "version", "action", "agent",
"power_timeout", "shell_timeout", "login_timeout",
"power_wait", "retry_on", "delay" ]
class fspawn(pexpect.spawn):
@@ -448,15 +446,14 @@ 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 obtaion 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"
}[error_code] + "\n"
sys.stderr.write(message)
sys.exit(EC_GENERIC_ERROR)
def usage(avail_opt):
- global all_opt
-
print "Usage:"
print "\t" + os.path.basename(sys.argv[0]) + " [options]"
print "Options:"
@@ -469,8 +466,6 @@ def usage(avail_opt):
print " " + value["help"]
def metadata(avail_opt, options, docs):
- global all_opt
-
sorted_list = [ (key, all_opt[key]) for key in avail_opt ]
sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"]))
@@ -483,7 +478,7 @@ def metadata(avail_opt, options, docs):
if docs.has_key("vendorurl"):
print "<vendor-url>" + docs["vendorurl"] +
"</vendor-url>"
print "<parameters>"
- for option, value in sorted_list:
+ for option, _value in sorted_list:
if all_opt[option].has_key("shortdesc"):
print "\t<parameter name=\"" + option + "\"
unique=\"0\" required=\"" + all_opt[option]["required"] +
"\">"
@@ -532,13 +527,10 @@ def metadata(avail_opt, options, docs):
print "</resource-agent>"
def process_input(avail_opt):
- global all_opt
- global common_opt
-
##
## Add options which are available for every fence agent
#####
- avail_opt.extend(common_opt)
+ avail_opt.extend(COMMON_OPT)
##
## Set standard environment
@@ -573,7 +565,7 @@ def process_input(avail_opt):
#####
if len(sys.argv) > 1:
try:
- opt, args = getopt.gnu_getopt(sys.argv[1:], getopt_string, longopt_list)
+ opt, _args = getopt.gnu_getopt(sys.argv[1:], getopt_string, longopt_list)
except getopt.GetoptError, error:
fail_usage("Parse error: " + error.msg)
@@ -644,13 +636,10 @@ def process_input(avail_opt):
## password script to set a correct password
######
def check_input(device_opt, opt):
- global all_opt
- global common_opt
-
##
## Add options which are available for every fence agent
#####
- device_opt.extend([x for x in common_opt if device_opt.count(x) == 0])
+ device_opt.extend([x for x in COMMON_OPT if device_opt.count(x) == 0])
options = dict(opt)
options["device_opt"] = device_opt
@@ -665,15 +654,15 @@ 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("-h") or options.has_key("-V") or
(options.has_key("-o") and options["-o"].lower() ==
"metadata"):
- return options;
+ return options
## Set default values
#####
for opt in device_opt:
if all_opt[opt].has_key("default"):
- getopt = "-" + all_opt[opt]["getopt"].rstrip(":")
- if 0 == options.has_key(getopt):
- options[getopt] = all_opt[opt]["default"]
+ getopt_short = "-" + all_opt[opt]["getopt"].rstrip(":")
+ if 0 == options.has_key(getopt_short):
+ options[getopt_short] = all_opt[opt]["default"]
options["-o"] = options["-o"].lower()
@@ -721,7 +710,8 @@ def check_input(device_opt, opt):
if 0 == os.path.isfile(options["-k"]):
fail_usage("Failed: Identity file " + options["-k"] + " does
not exist")
- if (0 == ["list", "monitor"].count(options["-o"].lower()))
and (0 == options.has_key("-n") and 0 == options.has_key("-U")) and
(device_opt.count("port")):
+ if (0 == ["list", "monitor"].count(options["-o"].lower()))
and \
+ (0 == options.has_key("-n") and 0 == options.has_key("-U")) and
(device_opt.count("port")):
fail_usage("Failed: You have to enter plug number")
if options.has_key("-S"):
@@ -787,7 +777,9 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
## Process options that manipulate fencing device
#####
- if (options["-o"] == "list") and (0 ==
options["device_opt"].count("port")) and (0 ==
options["device_opt"].count("partition") and 0 ==
options["device_opt"].count("uuid") and 0 ==
options["device_opt"].count("module_name")):
+ if (options["-o"] == "list") and \
+ 0 == options["device_opt"].count("port") and 0 ==
options["device_opt"].count("partition") and \
+ 0 == options["device_opt"].count("uuid") and 0 ==
options["device_opt"].count("module_name"):
print "N/A"
return
elif (options["-o"] == "list" and get_outlet_list == None):
@@ -816,7 +808,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
print "Success: Already ON"
else:
power_on = False
- for i in range(1, 1 + int(options["-F"])):
+ for _ in range(1, 1 + int(options["-F"])):
set_power_fn(tn, options)
time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn):
@@ -847,7 +839,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
options["-o"] = "on"
power_on = False
- for i in range(1, 1 + int(options["-F"])):
+ for _ in range(1, 1 + int(options["-F"])):
set_power_fn(tn, options)
time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn) == 1:
@@ -855,7 +847,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
break
if power_on == False:
- # this should not fail as not was fenced succesfully
+ # this should not fail as node was fenced succesfully
sys.stderr.write('Timed out waiting to power ON\n')
print "Success: Rebooted"
@@ -864,7 +856,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
if status.upper() == "OFF":
result = 2
elif options["-o"] == "monitor":
- 1
+ pass
return result
@@ -895,8 +887,8 @@ def fence_login(options):
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
## SSL telnet is part of the fencing package
- sys.stderr.write(str(ex) + "\n")
- sys.exit(EC_GENERIC_ERROR)
+ sys.stderr.write(str(ex) + "\n")
+ sys.exit(EC_GENERIC_ERROR)
elif options.has_key("-x") and 0 == options.has_key("-k"):
command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx,
options["-l"], options["-a"], options["-u"])
if options.has_key("ssh_options"):
@@ -938,7 +930,9 @@ def fence_login(options):
"are not in the spec file and must be installed separately." +
"\n")
sys.exit(EC_GENERIC_ERROR)
- result = conn.log_expect(options, [ options["-c"], "Are you sure you
want to continue connecting (yes/no)?", "Enter passphrase for key
'"+options["-k"]+"':" ], int(options["-y"]))
+ result = conn.log_expect(options, [ options["-c"], \
+ "Are you sure you want to continue connecting (yes/no)?", \
+ "Enter passphrase for key '" + options["-k"] +
"':" ], int(options["-y"]))
if result == 1:
conn.sendline("yes")
conn.log_expect(options, [ options["-c"], "Enter passphrase for key
'"+options["-k"]+"':"] , int(options["-y"]))
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index df4f1ef..5a14d56 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -99,8 +99,8 @@ def get_lpar_list(conn, options):
fail_usage("Unable to parse output of list command")
lines = res.group(2).split("\n")
- for x in lines:
- outlets[x.rstrip()] = ("", "")
+ for outlet_line in lines:
+ outlets[outlet_line.rstrip()] = ("", "")
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -119,9 +119,9 @@ def get_lpar_list(conn, options):
fail_usage("Unable to parse output of list command")
lines = res.group(1).split("\n")
- for x in lines:
- s = x.split(":")
- outlets[s[0]] = ("", s[1])
+ for outlet_line in lines:
+ (port, status) = outlet_line.split(":")
+ outlets[port] = ("", status)
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 78eb300..e1de315 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -12,9 +12,9 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
-re_get_id = re.compile("<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
-re_status = re.compile("<state>(.*?)</state>", re.IGNORECASE)
-re_get_name = re.compile("<name>(.*?)</name>", re.IGNORECASE)
+RE_GET_ID = re.compile("<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
+RE_STATUS = re.compile("<state>(.*?)</state>", re.IGNORECASE)
+RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
def get_power_status(conn, options):
### Obtain real ID from name
@@ -24,15 +24,14 @@ def get_power_status(conn, options):
sys.stderr.write(e[1] + "\n")
fail(EC_TIMED_OUT)
- result = re_get_id.search(res)
+ result = RE_GET_ID.search(res)
if (result == None):
# Unable to obtain ID needed to access virtual machine
fail(EC_STATUS)
options["id"] = result.group(2)
- re_status.search(res)
- result = re_status.search(res)
+ result = RE_STATUS.search(res)
if (result == None):
# We were able to parse ID so output is correct
# in some cases it is possible that RHEV-M output does not
@@ -73,7 +72,7 @@ def get_list(conn, options):
lines = res.split("<vm ")
for i in range(1, len(lines)):
- name = re_get_name.search(lines[i]).group(1)
+ name = RE_GET_NAME.search(lines[i]).group(1)
outlets[name] = ("", None)
except AttributeError:
return { }
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 2ec2c3c..6e3f394 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -244,7 +244,7 @@ def vmware_is_supported_vmrun_version(options):
vmware_help_str = vmware_run_command(options, False, "", 0)
version_re = re.search("vmrun version (\d\.(\d[\.]*)*)",
vmware_help_str.lower())
if (version_re==None):
- return False # Looks like this "vmrun" is not real vmrun
+ return False # Looks like this "vmrun" is not real vmrun
version_array = version_re.group(1).split(".")
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 1f353be..b1fdd05 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -58,7 +58,6 @@ 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
- pass
if ["list", "monitor"].count(options["-o"]) == 0 and
options["-n"].lower() == plug_line[plug_index]:
return plug_line[status_index]
else: