fence-agents: master - [cleanup] Fix whitespace according to PEP8
Marek GrĂ¡c
marx at fedoraproject.org
Mon May 5 10:29:44 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b54ea9fdabf2132ddbc46d0e65dd6bcf207cf521
Commit: b54ea9fdabf2132ddbc46d0e65dd6bcf207cf521
Parent: 4b05b5ae21409b7c86c32062aa34b93de02c8974
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Wed Apr 23 17:58:31 2014 +0200
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Mon May 5 12:03:08 2014 +0200
[cleanup] Fix whitespace according to PEP8
---
fence/agents/alom/fence_alom.py | 6 +-
fence/agents/amt/fence_amt.py | 8 +-
fence/agents/apc/fence_apc.py | 12 +-
fence/agents/apc_snmp/fence_apc_snmp.py | 10 +-
fence/agents/bladecenter/fence_bladecenter.py | 14 +-
fence/agents/brocade/fence_brocade.py | 6 +-
fence/agents/cisco_mds/fence_cisco_mds.py | 10 +-
fence/agents/cisco_ucs/fence_cisco_ucs.py | 14 +-
fence/agents/drac/fence_drac.py | 8 +-
fence/agents/drac5/fence_drac5.py | 14 +-
fence/agents/dummy/fence_dummy.py | 6 +-
fence/agents/eaton_snmp/fence_eaton_snmp.py | 14 +-
fence/agents/eps/fence_eps.py | 14 +-
fence/agents/hds_cb/fence_hds_cb.py | 10 +-
fence/agents/hpblade/fence_hpblade.py | 12 +-
fence/agents/ibmblade/fence_ibmblade.py | 14 +-
fence/agents/ifmib/fence_ifmib.py | 8 +-
fence/agents/ilo/fence_ilo.py | 8 +-
fence/agents/ilo_mp/fence_ilo_mp.py | 6 +-
fence/agents/intelmodular/fence_intelmodular.py | 10 +-
fence/agents/ipdu/fence_ipdu.py | 10 +-
fence/agents/ipmilan/fence_ipmilan.py | 2 +-
fence/agents/ldom/fence_ldom.py | 16 +-
fence/agents/lib/XenAPI.py.py | 4 +-
fence/agents/lib/check_used_options.py | 2 +-
fence/agents/lib/fencing.py.py | 188 +++++++++++-----------
fence/agents/lib/fencing_snmp.py.py | 20 ++--
fence/agents/lpar/fence_lpar.py | 18 +-
fence/agents/netio/fence_netio.py | 4 +-
fence/agents/ovh/fence_ovh.py | 16 +-
fence/agents/raritan/fence_raritan.py | 4 +-
fence/agents/rhevm/fence_rhevm.py | 14 +-
fence/agents/rsa/fence_rsa.py | 6 +-
fence/agents/rsb/fence_rsb.py | 6 +-
fence/agents/sanbox2/fence_sanbox2.py | 8 +-
fence/agents/virsh/fence_virsh.py | 6 +-
fence/agents/vmware/fence_vmware.py | 16 +-
fence/agents/vmware_soap/fence_vmware_soap.py | 18 +-
fence/agents/wti/fence_wti.py | 12 +-
fence/agents/xenapi/fence_xenapi.py | 6 +-
40 files changed, 290 insertions(+), 290 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index ef418c3..6b0d03d 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -32,17 +32,17 @@ def set_power_status(conn, options):
time.sleep(int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure"]
atexit.register(atexit_handler)
all_opt["secure"]["default"] = "1"
- all_opt["cmd_prompt"]["default"] = [ r"sc\>\ " ]
+ all_opt["cmd_prompt"]["default"] = [r"sc\>\ "]
options = check_input(device_opt, process_input(device_opt))
options["telnet_over_ssh"] = 1
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Sun ALOM"
docs["longdesc"] = "fence_alom is an I/O Fencing \
agent which can be used with ALOM connected machines."
diff --git a/fence/agents/amt/fence_amt.py b/fence/agents/amt/fence_amt.py
index 876a7c9..d1c2b03 100644
--- a/fence/agents/amt/fence_amt.py
+++ b/fence/agents/amt/fence_amt.py
@@ -33,7 +33,7 @@ def reboot_cycle(_, options):
(status, _, _) = run_command(options, create_command(options, "cycle"))
return not bool(status)
-def amt_run_command(options, command, timeout = None):
+def amt_run_command(options, command, timeout=None):
env = os.environ.copy()
env["AMT_PASSWORD"] = quote(options["--password"])
return run_command(options, command, timeout, env)
@@ -89,14 +89,14 @@ def define_new_opts():
def main():
atexit.register(atexit_handler)
- device_opt = [ "ipaddr", "no_login", "passwd", "boot_option", "no_port",
- "sudo", "amttool_path", "method" ]
+ device_opt = ["ipaddr", "no_login", "passwd", "boot_option", "no_port",
+ "sudo", "amttool_path", "method"]
define_new_opts()
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for AMT"
docs["longdesc"] = "fence_amt is an I/O Fencing agent \
which can be used with Intel AMT. This agent calls support software amttool\
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 6047501..83bfe07 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -71,7 +71,7 @@ def get_power_status(conn, options):
while True:
exp_result = conn.log_expect(options,
- ["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
+ ["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 line in lines:
@@ -150,7 +150,7 @@ def set_power_status(conn, options):
conn.send_eol(options["--switch"])
while 0 == conn.log_expect(options,
- [ "Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"])):
+ ["Press <ENTER>"] + options["--command-prompt"], int(options["--shell-timeout"])):
conn.send_eol("")
conn.send_eol(options["--plug"]+"")
@@ -211,17 +211,17 @@ def set_power_status5(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", \
- "port", "switch" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
+ "port", "switch"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "\n>", "\napc>" ]
+ all_opt["cmd_prompt"]["default"] = ["\n>", "\napc>"]
all_opt["ssh_options"]["default"] = "-1 -c blowfish"
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for APC over telnet/ssh"
docs["longdesc"] = "fence_apc is an I/O Fencing agent \
which can be used with the APC network power switch. It logs into device \
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 33f152e..cbb6856 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -99,7 +99,7 @@ def apc_set_device(conn):
# First resolve type of APC
apc_type = conn.walk(OID_SYS_OBJECT_ID)
- if not ((len(apc_type)==1) and (agents_dir.has_key(apc_type[0][1]))):
+ if not ((len(apc_type) == 1) and (agents_dir.has_key(apc_type[0][1]))):
apc_type = [[None, None]]
device = agents_dir[apc_type[0][1]]
@@ -148,7 +148,7 @@ def set_power_status(conn, options):
oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
- conn.set(oid, (options["--action"]=="on" and device.turn_on or device.turn_off))
+ conn.set(oid, (options["--action"] == "on" and device.turn_on or device.turn_off))
def get_outlets_status(conn, options):
@@ -172,8 +172,8 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
@@ -192,7 +192,7 @@ def main():
if not options.has_key("--switch"):
options["--switch"] = "1"
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for APC, Tripplite PDU over SNMP"
docs["longdesc"] = "fence_apc_snmp is an I/O Fencing agent \
which can be used with the APC network power switch or Tripplite PDU devices.\
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 6508012..8bc6949 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -28,7 +28,7 @@ def get_power_status(conn, options):
node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
- i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
+ i = conn.log_expect(options, [node_cmd, "system>"], int(options["--shell-timeout"]))
if i == 1:
## Given blade number does not exist
if options.has_key("--missing-as-off"):
@@ -47,7 +47,7 @@ def set_power_status(conn, options):
node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
- i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
+ i = conn.log_expect(options, [node_cmd, "system>"], int(options["--shell-timeout"]))
if i == 1:
## Given blade number does not exist
if options.has_key("--missing-as-off"):
@@ -61,7 +61,7 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
- outlets = { }
+ outlets = {}
node_cmd = "system>"
@@ -80,17 +80,17 @@ def get_blades_list(conn, options):
return outlets
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", \
- "port", "missing_as_off" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
+ "port", "missing_as_off"]
atexit.register(atexit_handler)
all_opt["power_wait"]["default"] = "10"
- all_opt["cmd_prompt"]["default"] = [ "system>" ]
+ all_opt["cmd_prompt"]["default"] = ["system>"]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IBM BladeCenter"
docs["longdesc"] = "fence_bladecenter is an I/O Fencing agent \
which can be used with IBM Bladecenters with recent enough firmware that \
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
index ac1c0c1..f935280 100644
--- a/fence/agents/brocade/fence_brocade.py
+++ b/fence/agents/brocade/fence_brocade.py
@@ -40,16 +40,16 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "fabric_fencing" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "fabric_fencing"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "> " ]
+ all_opt["cmd_prompt"]["default"] = ["> "]
options = check_input(device_opt, process_input(device_opt))
options["eol"] = "\n"
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for HP Brocade over telnet/ssh"
docs["longdesc"] = "fence_brocade is an I/O Fencing agent which can be used with Brocade FC switches. \
It logs into a Brocade switch via telnet and disables a specified port. Disabling the port which a machine is \
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 22f1143..4d2b40c 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -49,7 +49,7 @@ def get_power_status(conn, options):
return status == "1" and "on" or "off"
def set_power_status(conn, options):
- conn.set(PORT_OID, (options["--action"]=="on" and 1 or 2))
+ conn.set(PORT_OID, (options["--action"] == "on" and 1 or 2))
def get_outlets_status(conn, options):
result = {}
@@ -74,21 +74,21 @@ def get_outlets_status(conn, options):
def main():
global PORT_OID
- device_opt = [ "fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Cisco MDS"
docs["longdesc"] = "fence_cisco_mds is an I/O Fencing agent \
which can be used with any Cisco MDS 9000 series with SNMP enabled device."
docs["vendorurl"] = "http://www.cisco.com"
show_docs(options, docs)
- if not options["--action"] in ["list","monitor"]:
+ if not options["--action"] in ["list", "monitor"]:
PORT_OID = cisco_port2oid(options["--plug"])
# Operate the fencing device
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index b880d8d..f72e696 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -55,7 +55,7 @@ def set_power_status(conn, options):
def get_list(conn, options):
del conn
- outlets = { }
+ outlets = {}
try:
res = send_command(options, "<configResolveClass cookie=\"" + options["cookie"] +
@@ -67,9 +67,9 @@ def get_list(conn, options):
desc = RE_GET_DESC.search(lines[i]).group(1)
outlets[node_name] = (desc, None)
except AttributeError:
- return { }
+ return {}
except IndexError:
- return { }
+ return {}
return outlets
@@ -86,7 +86,7 @@ def send_command(opt, command, timeout):
conn = pycurl.Curl()
web_buffer = StringIO.StringIO()
conn.setopt(pycurl.URL, url)
- conn.setopt(pycurl.HTTPHEADER, [ "Content-type: text/xml" ])
+ 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)
@@ -108,10 +108,10 @@ def define_new_opts():
"required" : "0",
"shortdesc" : "Additional path needed to access suborganization",
"default" : "",
- "order" : 1 }
+ "order" : 1}
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg" ]
+ device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg"]
atexit.register(atexit_handler)
@@ -119,7 +119,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Cisco UCS"
docs["longdesc"] = "fence_cisco_ucs is an I/O Fencing agent which can be \
used with Cisco UCS to fence machines."
diff --git a/fence/agents/drac/fence_drac.py b/fence/agents/drac/fence_drac.py
index 4965779..da522a3 100644
--- a/fence/agents/drac/fence_drac.py
+++ b/fence/agents/drac/fence_drac.py
@@ -27,19 +27,19 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt"]
atexit.register(atexit_handler)
opt = process_input(device_opt)
if "--username" in opt:
- all_opt["cmd_prompt"]["default"] = [ "\\[" + opt["--username"] + "\\]# " ]
+ all_opt["cmd_prompt"]["default"] = ["\\[" + opt["--username"] + "\\]# "]
else:
- all_opt["cmd_prompt"]["default"] = [ "\\[" "username" + "\\]# " ]
+ all_opt["cmd_prompt"]["default"] = ["\\[" "username" + "\\]# "]
options = check_input(device_opt, opt)
- docs = { }
+ docs = {}
docs["shortdesc"] = "I/O Fencing agent for Dell DRAC IV"
docs["longdesc"] = "fence_drac is an I/O Fencing agent which can be used with \
the Dell Remote Access Card (DRAC). This card provides remote access to controlling \
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 7821f00..424fe53 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -65,7 +65,7 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def get_list_devices(conn, options):
- outlets = { }
+ outlets = {}
if options["--drac-version"] == "DRAC CMC":
conn.send_eol("getmodinfo")
@@ -99,22 +99,22 @@ def define_new_opts():
"help" : "-d, --drac-version=[version] Force DRAC version to use (DRAC 5, DRAC CMC, DRAC MC)",
"required" : "0",
"shortdesc" : "Force DRAC version to use (DRAC 5, DRAC CMC, DRAC MC)",
- "choices" : [ "DRAC CMC", "DRAC MC", "DRAC 5" ],
- "order" : 1 }
+ "choices" : ["DRAC CMC", "DRAC MC", "DRAC 5"],
+ "order" : 1}
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", \
- "drac_version", "port", "no_port" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
+ "drac_version", "port", "no_port"]
atexit.register(atexit_handler)
define_new_opts()
- all_opt["cmd_prompt"]["default"] = [ r"\$", r"DRAC\/MC:" ]
+ all_opt["cmd_prompt"]["default"] = [r"\$", r"DRAC\/MC:"]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Dell DRAC CMC/5"
docs["longdesc"] = "fence_drac5 is an I/O Fencing agent \
which can be used with the Dell Remote Access Card v5 or CMC (DRAC). \
diff --git a/fence/agents/dummy/fence_dummy.py b/fence/agents/dummy/fence_dummy.py
index 3bd2b90..9c4c5f1 100644
--- a/fence/agents/dummy/fence_dummy.py
+++ b/fence/agents/dummy/fence_dummy.py
@@ -32,7 +32,7 @@ def get_power_status_file(conn, options):
def set_power_status_file(conn, options):
del conn
- if not (options["--action"] in [ "on", "off" ]):
+ if not (options["--action"] in ["on", "off"]):
return
status_file = open(options["--status-file"], 'w')
@@ -78,7 +78,7 @@ def get_outlets_fail(conn, options):
return result
def main():
- device_opt = [ "no_password", "status_file", "random_sleep_range", "type", "port" ]
+ device_opt = ["no_password", "status_file", "random_sleep_range", "type", "port"]
atexit.register(atexit_handler)
@@ -118,7 +118,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Dummy fence agent"
docs["longdesc"] = "fence_dummy"
docs["vendorurl"] = "http://www.example.com"
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index 59a6147..fd3bbd9 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -71,12 +71,12 @@ def eaton_set_device(conn):
agents_dir = {'.1.3.6.1.4.1.534.6.6.6':EatonManagedePDU,
'.1.3.6.1.4.1.20677.1':EatonSwitchedePDU,
- '.1.3.6.1.4.1.20677.2':EatonSwitchedePDU }
+ '.1.3.6.1.4.1.20677.2':EatonSwitchedePDU}
# First resolve type of Eaton
eaton_type = conn.walk(OID_SYS_OBJECT_ID)
- if not ((len(eaton_type)==1) and (agents_dir.has_key(eaton_type[0][1]))):
+ if not ((len(eaton_type) == 1) and (agents_dir.has_key(eaton_type[0][1]))):
eaton_type = [[None, None]]
device = agents_dir[eaton_type[0][1]]
@@ -134,7 +134,7 @@ def get_power_status(conn, options):
oid = ((device.has_switches) and device.status_oid%(switch_id, port_id) or device.status_oid%(port_id))
try:
- (oid, status)=conn.get(oid)
+ (oid, status) = conn.get(oid)
if status == str(device.state_on):
return "on"
elif status == str(device.state_off):
@@ -158,7 +158,7 @@ def set_power_status(conn, options):
oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
- conn.set(oid,(options["--action"]=="on" and device.turn_on or device.turn_off))
+ conn.set(oid, (options["--action"] == "on" and device.turn_on or device.turn_off))
def get_outlets_status(conn, options):
@@ -200,8 +200,8 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
@@ -217,7 +217,7 @@ def main():
if options.has_key("--plug") and options["--plug"].isdigit():
options["--plug"] = str(int(options["--plug"]) - 1)
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Eaton over SNMP"
docs["longdesc"] = "fence_eaton_snmp is an I/O Fencing agent \
which can be used with the Eaton network power switch. It logs \
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 42dce72..51f4758 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -64,14 +64,14 @@ def eps_run_command(options, params):
def get_power_status(conn, options):
del conn
- ret_val = eps_run_command(options,"")
+ ret_val = eps_run_command(options, "")
result = {}
status = re.findall(r"p(\d{2})=(0|1)\s*\<br\>", ret_val.lower())
for out_num, out_stat in status:
- result[out_num] = ("",(out_stat=="1" and "on" or "off"))
+ result[out_num] = ("", (out_stat == "1" and "on" or "off"))
- if not options["--action"] in ['monitor','list']:
+ if not options["--action"] in ['monitor', 'list']:
if not options["--plug"] in result:
fail_usage("Failed: You have to enter existing physical plug!")
else:
@@ -81,7 +81,7 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
del conn
- eps_run_command(options, "P%s=%s"%(options["--plug"], (options["--action"]=="on" and "1" or "0")))
+ eps_run_command(options, "P%s=%s"%(options["--plug"], (options["--action"] == "on" and "1" or "0")))
# Define new option
def eps_define_new_opts():
@@ -97,8 +97,8 @@ def eps_define_new_opts():
# Starting point of fence agent
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "hidden_page" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "hidden_page"]
atexit.register(atexit_handler)
@@ -106,7 +106,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for ePowerSwitch"
docs["longdesc"] = "fence_eps is an I/O Fencing agent \
which can be used with the ePowerSwitch 8M+ power switch to fence \
diff --git a/fence/agents/hds_cb/fence_hds_cb.py b/fence/agents/hds_cb/fence_hds_cb.py
index 2256d4d..c661fe2 100755
--- a/fence/agents/hds_cb/fence_hds_cb.py
+++ b/fence/agents/hds_cb/fence_hds_cb.py
@@ -84,7 +84,7 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
- outlets = { }
+ outlets = {}
conn.sendline("S") # Enter System Command Mode
conn.log_expect(options, "SVP>", int(options["--shell-timeout"]))
@@ -107,17 +107,17 @@ def get_blades_list(conn, options):
return outlets
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", \
- "port", "missing_as_off" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
+ "port", "missing_as_off"]
atexit.register(atexit_handler)
all_opt["power_wait"]["default"] = "5"
- all_opt["cmd_prompt"]["default"] = [ r"\) :" ]
+ all_opt["cmd_prompt"]["default"] = [r"\) :"]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Hitachi Compute Blade systems"
docs["longdesc"] = "fence_hds_cb is an I/O Fencing agent \
which can be used with Hitachi Compute Blades with recent enough firmware that \
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index 69aa30d..e0b8866 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -20,7 +20,7 @@ BUILD_DATE="March, 2008"
def get_power_status(conn, options):
conn.send_eol("show server status " + options["--plug"])
- conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
+ conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
power_re = re.compile(r"^\s*Power: (.*?)\s*$")
status = "unknown"
@@ -45,9 +45,9 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
- outlets = { }
+ outlets = {}
- conn.send_eol("show server list" )
+ conn.send_eol("show server list")
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
list_re = re.compile(r"^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
@@ -59,15 +59,15 @@ def get_blades_list(conn, options):
return outlets
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "missing_as_off" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "missing_as_off"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "c7000oa>" ]
+ all_opt["cmd_prompt"]["default"] = ["c7000oa>"]
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 f3c810e..a42fd26 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -15,7 +15,7 @@ BUILD_DATE=""
### CONSTANTS ###
# From fence_ibmblade.pl
STATUSES_OID = ".1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4" # remoteControlBladePowerState
-CONTROL_OID = ".1.3.6.1.4.1.2.3.51.2.22.1.6.1.1.7" # powerOnOffBlade
+CONTROL_OID = ".1.3.6.1.4.1.2.3.51.2.22.1.6.1.1.7" # powerOnOffBlade
# Status constants returned as value from SNMP
STATUS_DOWN = 0
@@ -32,8 +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 = {}
@@ -44,7 +44,7 @@ def get_outlets_status(conn, _):
port_num = blade_info[0].split('.')[-1]
port_alias = ""
- port_status = (blade_info[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)
@@ -52,8 +52,8 @@ def get_outlets_status(conn, _):
# Main agent method
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
@@ -61,7 +61,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IBM BladeCenter over SNMP"
docs["longdesc"] = "fence_ibmblade is an I/O Fencing agent \
which can be used with IBM BladeCenter chassis. It issues SNMP Set \
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index e8eff1b..a019cec 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -72,7 +72,7 @@ def set_power_status(conn, options):
if port_num == None:
port_num = port2index(conn, options["--plug"])
- conn.set("%s.%d"%(STATUSES_OID, port_num), (options["--action"]=="on" and STATUS_UP or STATUS_DOWN))
+ conn.set("%s.%d" % (STATUSES_OID, port_num), (options["--action"] == "on" and STATUS_UP or STATUS_DOWN))
def get_outlets_status(conn, options):
result = {}
@@ -92,8 +92,8 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- device_opt = [ "fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
@@ -101,7 +101,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IF MIB"
docs["longdesc"] = "fence_ifmib is an I/O Fencing agent \
which can be used with any SNMP IF-MIB capable device. \
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 766aba9..965aabf 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -62,10 +62,10 @@ def define_new_opts():
"help" : "-r, --ribcl-version=[version] Force ribcl version to use",
"required" : "0",
"shortdesc" : "Force ribcl version to use",
- "order" : 1 }
+ "order" : 1}
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "ribcl" ]
+ device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "ribcl"]
atexit.register(atexit_handler)
@@ -77,7 +77,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for HP iLO"
docs["longdesc"] = "fence_ilo is an I/O Fencing agent \
used for HP servers with the Integrated Light Out (iLO) PCI card.\
@@ -94,7 +94,7 @@ the iLO card through an XML stream."
conn = fence_login(options)
try:
conn.send("<?xml version=\"1.0\"?>\r\n")
- conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["--login-timeout"]))
+ conn.log_expect(options, ["</RIBCL>", "<END_RIBCL/>"], int(options["--login-timeout"]))
version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
if not options.has_key("--ribcl-version"):
options["--ribcl-version"] = float(version)
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 2e70ad3..b84c924 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -35,16 +35,16 @@ def set_power_status(conn, options):
return
def main():
- device_opt = [ "ipaddr", "login", "passwd", "secure", "cmd_prompt" ]
+ device_opt = ["ipaddr", "login", "passwd", "secure", "cmd_prompt"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "MP>", "hpiLO->" ]
+ all_opt["cmd_prompt"]["default"] = ["MP>", "hpiLO->"]
all_opt["power_wait"]["default"] = 5
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for HP iLO MP"
docs["longdesc"] = ""
docs["vendorurl"] = "http://www.hp.com"
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index bdb45b5..bbb7dd1 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -44,7 +44,7 @@ def get_power_status(conn, options):
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))
+ (options["--action"] == "on" and STATUS_SET_ON or STATUS_SET_OFF))
def get_outlets_status(conn, options):
result = {}
@@ -55,7 +55,7 @@ def get_outlets_status(conn, options):
port_num = x[0].split('.')[-1]
port_alias = ""
- port_status = (x[1]==str(STATUS_UP) and "on" or "off")
+ port_status = (x[1] == str(STATUS_UP) and "on" or "off")
result[port_num] = (port_alias, port_status)
@@ -63,14 +63,14 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password",
- "port", "snmp_version", "community" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password",
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Intel Modular"
docs["longdesc"] = "fence_intelmodular is an I/O Fencing agent \
which can be used with Intel Modular device (tested on Intel MFSYS25, should \
diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py
index e17d837..abfbc26 100644
--- a/fence/agents/ipdu/fence_ipdu.py
+++ b/fence/agents/ipdu/fence_ipdu.py
@@ -54,7 +54,7 @@ def ipdu_set_device(conn, options):
# First resolve type of PDU device
pdu_type = conn.walk(OID_SYS_OBJECT_ID)
- if not ((len(pdu_type)==1) and (agents_dir.has_key(pdu_type[0][1]))):
+ if not ((len(pdu_type) == 1) and (agents_dir.has_key(pdu_type[0][1]))):
pdu_type = [[None, None]]
device = agents_dir[pdu_type[0][1]]
@@ -103,7 +103,7 @@ def set_power_status(conn, options):
oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
- conn.set(oid,(options["--action"]=="on" and device.turn_on or device.turn_off))
+ conn.set(oid, (options["--action"] == "on" and device.turn_on or device.turn_off))
def get_outlets_status(conn, options):
@@ -129,8 +129,8 @@ def get_outlets_status(conn, options):
def main():
global device
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "port", "snmp_version", "community"]
atexit.register(atexit_handler)
@@ -141,7 +141,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for iPDU over SNMP"
docs["longdesc"] = "fence_ipdu is an I/O Fencing agent \
which can be used with the IBM iPDU network power switch. It logs \
diff --git a/fence/agents/ipmilan/fence_ipmilan.py b/fence/agents/ipmilan/fence_ipmilan.py
index 9c63242..eaff7b7 100644
--- a/fence/agents/ipmilan/fence_ipmilan.py
+++ b/fence/agents/ipmilan/fence_ipmilan.py
@@ -138,7 +138,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IPMI"
docs["longdesc"] = "fence_ipmilan is an I/O Fencing agent\
which can be used with machines controlled by IPMI.\
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index d58be31..af4e974 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -24,11 +24,11 @@ COMMAND_PROMPT_NEW = "[PEXPECT]"
# Start comunicating after login. Prepare good environment.
def start_communication(conn, options):
- conn.send_eol ("PS1='"+COMMAND_PROMPT_NEW+"'")
+ conn.send_eol("PS1='" + COMMAND_PROMPT_NEW + "'")
res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["--shell-timeout"]))
if res == 0:
#CSH stuff
- conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
+ conn.send_eol("set prompt='" + COMMAND_PROMPT_NEW + "'")
conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
def get_power_status(conn, options):
@@ -50,9 +50,9 @@ def get_power_status(conn, options):
if fa_status == 0 and domain.group(1) == "NAME" and domain.group(2) == "STATE":
fa_status = 1
elif fa_status == 1:
- result[domain.group(1)] = ("", (domain.group(2).lower()=="bound" and "off" or "on"))
+ result[domain.group(1)] = ("", (domain.group(2).lower() == "bound" and "off" or "on"))
- if not options["--action"] in ['monitor','list']:
+ if not options["--action"] in ['monitor', 'list']:
if not options["--plug"] in result:
fail_usage("Failed: You have to enter existing logical domain!")
else:
@@ -63,23 +63,23 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
start_communication(conn, options)
- cmd_line = "ldm "+(options["--action"]=="on" and "start" or "stop -f")+" \""+options["--plug"]+"\""
+ cmd_line = "ldm "+ (options["--action"] == "on" and "start" or "stop -f") + " \"" + options["--plug"] + "\""
conn.send_eol(cmd_line)
conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port"]
atexit.register(atexit_handler)
all_opt["secure"]["default"] = "1"
- all_opt["cmd_prompt"]["default"] = [ r"\ $" ]
+ all_opt["cmd_prompt"]["default"] = [r"\ $"]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for Sun LDOM"
docs["longdesc"] = "fence_ldom is an I/O Fencing agent \
which can be used with LDoms virtual machines. This agent works \
diff --git a/fence/agents/lib/XenAPI.py.py b/fence/agents/lib/XenAPI.py.py
index f9b7687..b91efda 100644
--- a/fence/agents/lib/XenAPI.py.py
+++ b/fence/agents/lib/XenAPI.py.py
@@ -50,7 +50,7 @@ import httplib
import socket
import logging
-translation = gettext.translation('xen-xm', fallback = True)
+translation = gettext.translation('xen-xm', fallback=True)
class Failure(Exception):
def __init__(self, details):
@@ -81,7 +81,7 @@ class Failure(Exception):
for i in range(len(self.details))])
-_RECONNECT_AND_RETRY = (lambda _ : ())
+_RECONNECT_AND_RETRY = (lambda _: ())
class UDSHTTPConnection(httplib.HTTPConnection):
""" Stupid hacked up HTTPConnection subclass to allow HTTP over Unix domain
diff --git a/fence/agents/lib/check_used_options.py b/fence/agents/lib/check_used_options.py
index 7f821b1..0eb19e3 100755
--- a/fence/agents/lib/check_used_options.py
+++ b/fence/agents/lib/check_used_options.py
@@ -13,7 +13,7 @@ from fencing import all_opt
def main():
agent = sys.argv[1]
- available = { }
+ available = {}
## all_opt from fencing library are imported
for k in all_opt.keys():
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 3e5c788..fb9b006 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -16,25 +16,25 @@ REDHAT_COPYRIGHT = ""
BUILD_DATE = "March, 2008"
#END_VERSION_GENERATION
-__all__ = [ 'atexit_handler', 'check_input', 'process_input', 'all_opt', 'show_docs',
- 'fence_login', 'fence_action', 'fence_logout' ]
+__all__ = ['atexit_handler', 'check_input', 'process_input', 'all_opt', 'show_docs',
+ 'fence_login', 'fence_action', 'fence_logout']
-EC_GENERIC_ERROR = 1
-EC_BAD_ARGS = 2
-EC_LOGIN_DENIED = 3
+EC_GENERIC_ERROR = 1
+EC_BAD_ARGS = 2
+EC_LOGIN_DENIED = 3
EC_CONNECTION_LOST = 4
-EC_TIMED_OUT = 5
-EC_WAITING_ON = 6
-EC_WAITING_OFF = 7
-EC_STATUS = 8
-EC_STATUS_HMC = 9
+EC_TIMED_OUT = 5
+EC_WAITING_ON = 6
+EC_WAITING_OFF = 7
+EC_STATUS = 8
+EC_STATUS_HMC = 9
EC_PASSWORD_MISSING = 10
EC_INVALID_PRIVILEGES = 11
TELNET_PATH = "/usr/bin/telnet"
-SSH_PATH = "/usr/bin/ssh"
-SSL_PATH = "@GNUTLSCLI_PATH@"
-SUDO_PATH = "/usr/bin/sudo"
+SSH_PATH = "/usr/bin/ssh"
+SSL_PATH = "@GNUTLSCLI_PATH@"
+SUDO_PATH = "/usr/bin/sudo"
all_opt = {
"help" : {
@@ -43,28 +43,28 @@ all_opt = {
"help" : "-h, --help Display this help and exit",
"required" : "0",
"shortdesc" : "Display help and exit",
- "order" : 54 },
+ "order" : 54},
"version" : {
"getopt" : "V",
"longopt" : "version",
"help" : "-V, --version Output version information and exit",
"required" : "0",
"shortdesc" : "Display version information and exit",
- "order" : 53 },
+ "order" : 53},
"verbose" : {
"getopt" : "v",
"longopt" : "verbose",
"help" : "-v, --verbose Verbose mode",
"required" : "0",
"shortdesc" : "Verbose mode",
- "order" : 51 },
+ "order" : 51},
"debug" : {
"getopt" : "D:",
"longopt" : "debug-file",
"help" : "-D, --debug-file=[debugfile] Debugging to output file",
"required" : "0",
"shortdesc" : "Write debug information to given file",
- "order" : 52 },
+ "order" : 52},
"delay" : {
"getopt" : "f:",
"longopt" : "delay",
@@ -72,15 +72,15 @@ all_opt = {
"required" : "0",
"shortdesc" : "Wait X seconds before fencing is started",
"default" : "0",
- "order" : 200 },
+ "order" : 200},
"agent" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"web" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"action" : {
"getopt" : "o:",
"longopt" : "action",
@@ -88,97 +88,97 @@ all_opt = {
"required" : "1",
"shortdesc" : "Fencing Action",
"default" : "reboot",
- "order" : 1 },
+ "order" : 1},
"fabric_fencing" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"ipaddr" : {
"getopt" : "a:",
"longopt" : "ip",
"help" : "-a, --ip=[ip] IP address or hostname of fencing device",
"required" : "1",
"shortdesc" : "IP Address or Hostname",
- "order" : 1 },
+ "order" : 1},
"ipport" : {
"getopt" : "u:",
"longopt" : "ipport",
"help" : "-u, --ipport=[port] TCP/UDP port to use",
"required" : "0",
"shortdesc" : "TCP/UDP port to use for connection with device",
- "order" : 1 },
+ "order" : 1},
"login" : {
"getopt" : "l:",
"longopt" : "username",
"help" : "-l, --username=[name] Login name",
"required" : "?",
"shortdesc" : "Login Name",
- "order" : 1 },
+ "order" : 1},
"no_login" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"no_password" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"no_port" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"no_status" : {
"getopt" : "",
"help" : "",
- "order" : 1 },
+ "order" : 1},
"passwd" : {
"getopt" : "p:",
"longopt" : "password",
"help" : "-p, --password=[password] Login password or passphrase",
"required" : "0",
"shortdesc" : "Login password or passphrase",
- "order" : 1 },
+ "order" : 1},
"passwd_script" : {
"getopt" : "S:",
"longopt" : "password-script",
"help" : "-S, --password-script=[script] Script to run to retrieve password",
"required" : "0",
"shortdesc" : "Script to retrieve password",
- "order" : 1 },
+ "order" : 1},
"identity_file" : {
"getopt" : "k:",
"longopt" : "identity-file",
"help" : "-k, --identity-file=[filename] Identity file (private key) for ssh ",
"required" : "0",
"shortdesc" : "Identity file for ssh",
- "order" : 1 },
+ "order" : 1},
"cmd_prompt" : {
"getopt" : "c:",
"longopt" : "command-prompt",
"help" : "-c, --command-prompt=[prompt] Force Python regex for command prompt",
"shortdesc" : "Force Python regex for command prompt",
"required" : "0",
- "order" : 1 },
+ "order" : 1},
"secure" : {
"getopt" : "x",
"longopt" : "ssh",
"help" : "-x, --ssh Use ssh connection",
"shortdesc" : "SSH connection",
"required" : "0",
- "order" : 1 },
+ "order" : 1},
"ssh_options" : {
"getopt" : "X:",
"longopt" : "ssh-options",
"help" : "--ssh-options=[options] SSH options to use",
"shortdesc" : "SSH options to use",
"required" : "0",
- "order" : 1 },
+ "order" : 1},
"ssl" : {
"getopt" : "z",
"longopt" : "ssl",
"help" : "-z, --ssl Use ssl connection",
"required" : "0",
"shortdesc" : "SSL connection",
- "order" : 1 },
+ "order" : 1},
"notls" : {
"getopt" : "t",
"longopt" : "notls",
@@ -188,7 +188,7 @@ all_opt = {
"This should only be used for devices that do not support TLS1.0 and up.",
"required" : "0",
"shortdesc" : "Disable TLS negotiation",
- "order" : 1 },
+ "order" : 1},
"port" : {
"getopt" : "n:",
"longopt" : "plug",
@@ -196,43 +196,43 @@ all_opt = {
" identification of machine",
"required" : "1",
"shortdesc" : "Physical plug number, name of virtual machine or UUID",
- "order" : 1 },
+ "order" : 1},
"switch" : {
"getopt" : "s:",
"longopt" : "switch",
"help" : "-s, --switch=[id] Physical switch number on device",
"required" : "0",
"shortdesc" : "Physical switch number on device",
- "order" : 1 },
+ "order" : 1},
"exec" : {
"getopt" : "e:",
"longopt" : "exec",
"help" : "-e, --exec=[command] Command to execute",
"required" : "0",
"shortdesc" : "Command to execute",
- "order" : 1 },
+ "order" : 1},
"vmware_type" : {
"getopt" : "d:",
"longopt" : "vmware_type",
"help" : "-d, --vmware_type=[type] Type of VMware to connect",
"required" : "0",
"shortdesc" : "Type of VMware to connect",
- "order" : 1 },
+ "order" : 1},
"vmware_datacenter" : {
"getopt" : "s:",
"longopt" : "vmware-datacenter",
"help" : "-s, --vmware-datacenter=[dc] VMWare datacenter filter",
"required" : "0",
"shortdesc" : "Show only machines in specified datacenter",
- "order" : 2 },
+ "order" : 2},
"snmp_version" : {
"getopt" : "d:",
"longopt" : "snmp-version",
"help" : "-d, --snmp-version=[version] Specifies SNMP version to use",
"required" : "0",
"shortdesc" : "Specifies SNMP version to use (1,2c,3)",
- "choices" : [ "1", "2c", "3" ],
- "order" : 1 },
+ "choices" : ["1", "2c", "3"],
+ "order" : 1},
"community" : {
"getopt" : "c:",
"longopt" : "community",
@@ -246,7 +246,7 @@ all_opt = {
"help" : "-b, --snmp-auth-prot=[prot] Set authentication protocol (MD5|SHA)",
"required" : "0",
"shortdesc" : "Set authentication protocol (MD5|SHA)",
- "choices" : [ "MD5" , "SHA" ],
+ "choices" : ["MD5", "SHA"],
"order" : 1},
"snmp_sec_level" : {
"getopt" : "E:",
@@ -255,7 +255,7 @@ all_opt = {
" (noAuthNoPriv|authNoPriv|authPriv)",
"required" : "0",
"shortdesc" : "Set security level (noAuthNoPriv|authNoPriv|authPriv)",
- "choices" : [ "noAuthNoPriv", "authNoPriv", "authPriv" ],
+ "choices" : ["noAuthNoPriv", "authNoPriv", "authPriv"],
"order" : 1},
"snmp_priv_prot" : {
"getopt" : "B:",
@@ -263,7 +263,7 @@ all_opt = {
"help" : "-B, --snmp-priv-prot=[prot] Set privacy protocol (DES|AES)",
"required" : "0",
"shortdesc" : "Set privacy protocol (DES|AES)",
- "choices" : [ "DES", "AES" ],
+ "choices" : ["DES", "AES"],
"order" : 1},
"snmp_priv_passwd" : {
"getopt" : "P:",
@@ -285,14 +285,14 @@ all_opt = {
"help" : "-4, --inet4-only Forces agent to use IPv4 addresses only",
"required" : "0",
"shortdesc" : "Forces agent to use IPv4 addresses only",
- "order" : 1 },
+ "order" : 1},
"inet6_only" : {
"getopt" : "6",
"longopt" : "inet6-only",
"help" : "-6, --inet6-only Forces agent to use IPv6 addresses only",
"required" : "0",
"shortdesc" : "Forces agent to use IPv6 addresses only",
- "order" : 1 },
+ "order" : 1},
"separator" : {
"getopt" : "C:",
"longopt" : "separator",
@@ -300,7 +300,7 @@ all_opt = {
"default" : ",",
"required" : "0",
"shortdesc" : "Separator for CSV created by operation list",
- "order" : 100 },
+ "order" : 100},
"login_timeout" : {
"getopt" : "y:",
"longopt" : "login-timeout",
@@ -308,7 +308,7 @@ all_opt = {
"default" : "5",
"required" : "0",
"shortdesc" : "Wait X seconds for cmd prompt after login",
- "order" : 200 },
+ "order" : 200},
"shell_timeout" : {
"getopt" : "Y:",
"longopt" : "shell-timeout",
@@ -316,7 +316,7 @@ all_opt = {
"default" : "3",
"required" : "0",
"shortdesc" : "Wait X seconds for cmd prompt after issuing command",
- "order" : 200 },
+ "order" : 200},
"power_timeout" : {
"getopt" : "g:",
"longopt" : "power-timeout",
@@ -324,7 +324,7 @@ all_opt = {
"default" : "20",
"required" : "0",
"shortdesc" : "Test X seconds for status change after ON/OFF",
- "order" : 200 },
+ "order" : 200},
"power_wait" : {
"getopt" : "G:",
"longopt" : "power-wait",
@@ -332,14 +332,14 @@ all_opt = {
"default" : "0",
"required" : "0",
"shortdesc" : "Wait X seconds after issuing ON/OFF",
- "order" : 200 },
+ "order" : 200},
"missing_as_off" : {
"getopt" : "M",
"longopt" : "missing-as-off",
"help" : "--missing-as-off Missing port returns OFF instead of failure",
"required" : "0",
"shortdesc" : "Missing port returns OFF instead of failure",
- "order" : 200 },
+ "order" : 200},
"retry_on" : {
"getopt" : "F:",
"longopt" : "retry-on",
@@ -347,7 +347,7 @@ all_opt = {
"default" : "1",
"required" : "0",
"shortdesc" : "Count of attempts to retry power on",
- "order" : 201 },
+ "order" : 201},
"session_url" : {
"getopt" : "s:",
"longopt" : "session-url",
@@ -369,7 +369,7 @@ all_opt = {
"required" : "0",
"shortdesc" : "Method to fence (onoff|cycle)",
"default" : "onoff",
- "choices" : [ "onoff", "cycle" ],
+ "choices" : ["onoff", "cycle"],
"order" : 1},
"on_target": {
"getopt" : "",
@@ -379,14 +379,14 @@ all_opt = {
# options which are added automatically if 'key' is encountered ("default" is always added)
DEPENDENCY_OPT = {
- "default" : [ "help", "debug", "verbose", "version", "action", "agent", \
- "power_timeout", "shell_timeout", "login_timeout", "power_wait", "retry_on", "delay" ],
- "passwd" : [ "passwd_script" ],
- "secure" : [ "identity_file", "ssh_options" ],
- "ipaddr" : [ "ipport", "inet4_only", "inet6_only" ],
- "port" : [ "separator" ],
- "community" : [ "snmp_auth_prot", "snmp_sec_level", "snmp_priv_prot", \
- "snmp_priv_passwd", "snmp_priv_passwd_script" ]
+ "default" : ["help", "debug", "verbose", "version", "action", "agent", \
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait", "retry_on", "delay"],
+ "passwd" : ["passwd_script"],
+ "secure" : ["identity_file", "ssh_options"],
+ "ipaddr" : ["ipport", "inet4_only", "inet6_only"],
+ "port" : ["separator"],
+ "community" : ["snmp_auth_prot", "snmp_sec_level", "snmp_priv_prot", \
+ "snmp_priv_passwd", "snmp_priv_passwd_script"]
}
class fspawn(pexpect.spawn):
@@ -425,7 +425,7 @@ def add_dependency_options(options):
added_opt.extend([y for y in DEPENDENCY_OPT[opt] if options.count(y) == 0])
return added_opt
-def fail_usage(message = ""):
+def fail_usage(message=""):
if len(message) > 0:
logging.error("%s\n", message)
logging.error("Please use '-h' for usage\n")
@@ -453,7 +453,7 @@ def usage(avail_opt):
print "\t" + os.path.basename(sys.argv[0]) + " [options]"
print "Options:"
- sorted_list = [ (key, all_opt[key]) for key in avail_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"]))
for key, value in sorted_list:
@@ -462,7 +462,7 @@ def usage(avail_opt):
def metadata(avail_opt, options, docs):
# avail_opt has to be unique, if there are duplicities then they should be removed
- sorted_list = [ (key, all_opt[key]) for key in list(set(avail_opt)) ]
+ sorted_list = [(key, all_opt[key]) for key in list(set(avail_opt))]
sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"]))
print "<?xml version=\"1.0\" ?>"
@@ -494,11 +494,11 @@ def metadata(avail_opt, options, docs):
default = "true"
if default:
- default = default.replace("&", "&" )
- default = default.replace('"', """ )
- default = default.replace('<', "<" )
- default = default.replace('>', ">" )
- default = default.replace("'", "'" )
+ default = default.replace("&", "&")
+ default = default.replace('"', """)
+ default = default.replace('<', "<")
+ default = default.replace('>', ">")
+ default = default.replace("'", "'")
default = "default=\"" + default + "\" "
mixed = all_opt[option]["help"]
@@ -557,7 +557,7 @@ def process_input(avail_opt):
## Prepare list of options for getopt
#####
getopt_string = ""
- longopt_list = [ ]
+ longopt_list = []
for k in avail_opt:
if all_opt.has_key(k):
getopt_string += all_opt[k]["getopt"]
@@ -582,7 +582,7 @@ def process_input(avail_opt):
## Transform short getopt to long one which are used in fencing agents
#####
old_opt = opt
- opt = { }
+ opt = {}
for o in dict(old_opt).keys():
if o.startswith("--"):
for x in all_opt.keys():
@@ -605,7 +605,7 @@ def process_input(avail_opt):
##
#####
else:
- opt = { }
+ opt = {}
name = ""
for line in sys.stdin.readlines():
line = line.strip()
@@ -622,7 +622,7 @@ def process_input(avail_opt):
if all_opt[name]["getopt"].endswith(":"):
opt["--"+all_opt[name]["longopt"].rstrip(":")] = value
- elif value.lower() in [ "1", "yes", "on", "true" ]:
+ elif value.lower() in ["1", "yes", "on", "true"]:
opt["--"+all_opt[name]["longopt"]] = "1"
return opt
@@ -684,7 +684,7 @@ def check_input(device_opt, opt):
#####
for opt in device_opt:
if all_opt[opt].has_key("default"):
- getopt_long = "--" + all_opt[opt]["longopt"]
+ getopt_long = "--" + all_opt[opt]["longopt"]
if not options.has_key(getopt_long):
options[getopt_long] = all_opt[opt]["default"]
@@ -699,7 +699,7 @@ def check_input(device_opt, opt):
if options.has_key("--verbose"):
logging.getLogger().setLevel(logging.DEBUG)
- acceptable_actions = [ "on", "off", "status", "list", "monitor" ]
+ acceptable_actions = ["on", "off", "status", "list", "monitor"]
if 1 == device_opt.count("fabric_fencing"):
## Compatibility layer
#####
@@ -776,7 +776,7 @@ def check_input(device_opt, opt):
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"])))
+ ("--" + all_opt[opt]["longopt"], str(all_opt[opt]["choices"])))
return options
@@ -826,11 +826,11 @@ def set_multi_power_fn(tn, options, set_power_fn):
else:
set_power_fn(tn, options)
-def show_docs(options, docs = None):
+def show_docs(options, docs=None):
device_opt = options["device_opt"]
if docs == None:
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent"
docs["longdesc"] = ""
@@ -849,7 +849,7 @@ def show_docs(options, docs = None):
print __main__.REDHAT_COPYRIGHT
sys.exit(0)
-def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None, reboot_cycle_fn = None):
+def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list=None, reboot_cycle_fn=None):
result = 0
try:
@@ -964,7 +964,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
return result
-def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(username: )|(User Name :)"):
+def fence_login(options, re_login_string=r"(login\s*: )|(Login Name: )|(username: )|(User Name :)"):
force_ipvx = ""
if options.has_key("--inet6-only"):
@@ -977,14 +977,14 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
options["eol"] = "\r\n"
if options.has_key("--command-prompt") and type(options["--command-prompt"]) is not list:
- options["--command-prompt"] = [ options["--command-prompt"] ]
+ options["--command-prompt"] = [options["--command-prompt"]]
## Do the delay of the fence device before logging in
run_delay(options)
try:
re_login = re.compile(re_login_string, re.IGNORECASE)
- re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
+ re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
if options.has_key("--ssl"):
gnutls_opts = ""
@@ -1011,7 +1011,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
# 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)?" ],
+ [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
@@ -1021,7 +1021,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
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)?" ],
+ ["ssword:", "Are you sure you want to continue connecting (yes/no)?"],
int(options["--login-timeout"]))
if result == 1:
conn.sendline("yes")
@@ -1038,13 +1038,13 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
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)?" ] + \
+ 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"]))
if result == 1:
conn.sendline("yes")
result = conn.log_expect(options,
- [ "Enter passphrase for key '" + options["--identity-file"]+"':"] + \
+ ["Enter passphrase for key '" + options["--identity-file"]+"':"] + \
options["--command-prompt"], int(options["--login-timeout"]))
if result == 0:
if options.has_key("--password"):
@@ -1071,7 +1071,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
try:
conn.send_eol(options["--password"])
- valid_password = conn.log_expect(options, [ re_login ] + \
+ 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
@@ -1100,7 +1100,7 @@ def is_executable(path):
return True
return False
-def run_command(options, command, timeout = None, env = None):
+def run_command(options, command, timeout=None, env=None):
if timeout is None and "--power-timeout" in options:
timeout = options["--power-timeout"]
if timeout is not None:
@@ -1113,7 +1113,7 @@ def run_command(options, command, timeout = None, env = None):
except OSError:
fail_usage("Unable to run %s\n" % command)
- thread = threading.Thread(target = process.wait)
+ thread = threading.Thread(target=process.wait)
thread.start()
thread.join(timeout)
if thread.is_alive():
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index a034bd2..5c013d8 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -7,7 +7,7 @@ import logging
from fencing import *
from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
-__all__ = [ 'FencingSnmp' ]
+__all__ = ['FencingSnmp']
## do not add code here.
#BEGIN_VERSION_GENERATION
@@ -26,10 +26,10 @@ class FencingSnmp:
def complete_missed_params(self):
mapping = [[
- ['snmp-priv-passwd','password','!snmp-sec-level'],
+ ['snmp-priv-passwd', 'password', '!snmp-sec-level'],
'self.options["--snmp-sec-level"]="authPriv"'
- ],[
- ['!snmp-version','community','!username','!snmp-priv-passwd','!password'],
+ ], [
+ ['!snmp-version', 'community', '!username', '!snmp-priv-passwd', '!password'],
'self.options["--snmp-version"]="2c"'
]]
@@ -56,7 +56,7 @@ class FencingSnmp:
self.complete_missed_params()
#mapping from our option to snmpcmd option
- mapping = (('snmp-version', 'v'),('community', 'c'))
+ mapping = (('snmp-version', 'v'), ('community', 'c'))
for item in mapping:
if self.options.has_key("--" + item[0]):
@@ -65,8 +65,8 @@ class FencingSnmp:
# Some options make sense only for v3 (and for v1/2c can cause "problems")
if (self.options.has_key("--snmp-version")) and (self.options["--snmp-version"] == "3"):
# Mapping from our options to snmpcmd options for v3
- mapping_v3 = (('snmp-auth-prot','a'), ('snmp-sec-level','l'), ('snmp-priv-prot','x'), \
- ('snmp-priv-passwd','X'),('password','A'),('username','u'))
+ mapping_v3 = (('snmp-auth-prot', 'a'), ('snmp-sec-level', 'l'), ('snmp-priv-prot', 'x'), \
+ ('snmp-priv-passwd', 'X'), ('password', 'A'), ('username', 'u'))
for item in mapping_v3:
if self.options.has_key("--"+item[0]):
cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[0]]))
@@ -80,7 +80,7 @@ class FencingSnmp:
force_ipvx = "udp:"
cmd += " '%s%s%s'"% (force_ipvx, self.quote_for_run(self.options["--ip"]),
- self.options.has_key("--ipport") and self.quote_for_run(":" + str (self.options["--ipport"])) or "")
+ self.options.has_key("--ipport") and self.quote_for_run(":" + str(self.options["--ipport"])) or "")
return cmd
def run_command(self, command, additional_timemout=0):
@@ -97,7 +97,7 @@ class FencingSnmp:
logging.debug("%s\n", res_output)
- if (res_code!=0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
+ if (res_code != 0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
fail_usage("Returned %d: %s"% (res_code, res_output))
except pexpect.ExceptionPexpect:
fail_usage("Cannot run command %s"%(command))
@@ -131,4 +131,4 @@ class FencingSnmp:
output = self.run_command(cmd, additional_timemout).splitlines()
- return [ x.split(None,1) for x in output if x.startswith(".") ]
+ return [x.split(None, 1) for x in output if x.startswith(".")]
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index da99073..31b0521 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -62,14 +62,14 @@ def set_power_status(conn, options):
" -n " + options["--plug"] +
" -f `lssyscfg -r lpar -F curr_profile " +
" -m " + options["--managed"] +
- " --filter \"lpar_names="+ options["--plug"] +"\"`\n" )
+ " --filter \"lpar_names=" + options["--plug"] + "\"`\n")
else:
conn.send("chsysstate -o shutdown -r lpar --immed" +
" -m " + options["--managed"] + " -n " + options["--plug"] + "\n")
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def get_lpar_list(conn, options):
- outlets = { }
+ outlets = {}
if options["--hmc-version"] == "3":
conn.send("query_partition_names -m " + options["--managed"] + "\n")
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
@@ -110,7 +110,7 @@ def define_new_opts():
"help" : "-s, --managed=[id] Name of the managed system",
"required" : "0",
"shortdesc" : "Managed system name",
- "order" : 1 }
+ "order" : 1}
all_opt["hmc_version"] = {
"getopt" : "H:",
"longopt" : "hmc-version",
@@ -118,12 +118,12 @@ def define_new_opts():
"required" : "0",
"shortdesc" : "Force HMC version to use (3 or 4)",
"default" : "4",
- "choices" : [ "3", "4" ],
- "order" : 1 }
+ "choices" : ["3", "4"],
+ "order" : 1}
def main():
- device_opt = [ "ipaddr", "login", "passwd", "secure", "cmd_prompt", \
- "port", "managed", "hmc_version" ]
+ device_opt = ["ipaddr", "login", "passwd", "secure", "cmd_prompt", \
+ "port", "managed", "hmc_version"]
atexit.register(atexit_handler)
@@ -131,11 +131,11 @@ def main():
all_opt["login_timeout"]["default"] = "15"
all_opt["secure"]["default"] = "1"
- all_opt["cmd_prompt"]["default"] = [ r":~>", r"]\$", r"\$ " ]
+ all_opt["cmd_prompt"]["default"] = [r":~>", r"]\$", r"\$ "]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IBM LPAR"
docs["longdesc"] = ""
docs["vendorurl"] = "http://www.ibm.com"
diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
index 6e419a7..b14b454 100755
--- a/fence/agents/netio/fence_netio.py
+++ b/fence/agents/netio/fence_netio.py
@@ -53,7 +53,7 @@ def get_outlet_list(conn, options):
return result
def main():
- device_opt = [ "ipaddr", "login", "passwd", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "port"]
atexit.register(atexit_handler)
@@ -66,7 +66,7 @@ def main():
opt["eol"] = "\r\n"
options = check_input(device_opt, opt)
- docs = { }
+ docs = {}
docs["shortdesc"] = "I/O Fencing agent for Koukaam NETIO-230B"
docs["longdesc"] = "fence_netio is an I/O Fencing agent which can be \
used with the Koukaam NETIO-230B Power Distribution Unit. It logs into \
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index 50980f6..a705913 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -20,7 +20,7 @@ from fencing import *
from fencing import fail, fail_usage, EC_LOGIN_DENIED, run_delay
OVH_RESCUE_PRO_NETBOOT_ID = '28'
-OVH_HARD_DISK_NETBOOT_ID = '1'
+OVH_HARD_DISK_NETBOOT_ID = '1'
STATUS_HARD_DISK_SLEEP = 240 # Wait 4 minutes to SO to boot
STATUS_RESCUE_PRO_SLEEP = 150 # Wait 2 minutes 30 seconds to Rescue-Pro to run
@@ -33,7 +33,7 @@ def define_new_opts():
"required" : "1",
"shortdesc" : "Reboot email",
"default" : "",
- "order" : 1 }
+ "order" : 1}
def netboot_reboot(options, mode):
conn = soap_login(options)
@@ -51,8 +51,8 @@ def reboot_time(options):
conn = soap_login(options)
result = conn.service.dedicatedHardRebootStatus(options["session"], options["--plug"])
- tmpstart = datetime.strptime(result.start,'%Y-%m-%d %H:%M:%S')
- tmpend = datetime.strptime(result.end,'%Y-%m-%d %H:%M:%S')
+ tmpstart = datetime.strptime(result.start, '%Y-%m-%d %H:%M:%S')
+ tmpend = datetime.strptime(result.end, '%Y-%m-%d %H:%M:%S')
result.start = tmpstart
result.end = tmpend
@@ -83,7 +83,7 @@ def remove_tmp_dir(tmp_dir):
shutil.rmtree(tmp_dir)
def main():
- device_opt = [ "login", "passwd", "port", "email", "no_status" ]
+ device_opt = ["login", "passwd", "port", "email", "no_status"]
atexit.register(atexit_handler)
@@ -91,7 +91,7 @@ def main():
all_opt["action"]["help"] = "-o, --action=[action] Action: reboot (default), off or on"
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for OVH"
docs["longdesc"] = "fence_ovh is an Power Fencing agent \
which can be used within OVH datecentre. \
@@ -100,7 +100,7 @@ Poweroff is simulated with a reboot into rescue-pro mode."
docs["vendorurl"] = "http://www.ovh.net"
show_docs(options, docs)
- if options["--action"] in [ "list", "status"]:
+ if options["--action"] in ["list", "status"]:
fail_usage("Action '" + options["--action"] + "' is not supported in this fence agent")
if not options["--plug"].endswith(".ovh.net"):
@@ -118,7 +118,7 @@ Poweroff is simulated with a reboot into rescue-pro mode."
# Reboot in Rescue-pro
netboot_reboot(options, OVH_RESCUE_PRO_NETBOOT_ID)
time.sleep(STATUS_RESCUE_PRO_SLEEP)
- elif options["--action"] in ['on', 'reboot' ]:
+ elif options["--action"] in ['on', 'reboot']:
# Reboot from HD
netboot_reboot(options, OVH_HARD_DISK_NETBOOT_ID)
time.sleep(STATUS_HARD_DISK_SLEEP)
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index b895514..3506e25 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -36,7 +36,7 @@ def set_power_status(conn, options):
conn.send_eol("set %s powerState=%s" % (options["--plug"], action))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "port"]
atexit.register(atexit_handler)
@@ -47,7 +47,7 @@ def main():
opt["eol"] = "\r\n"
options = check_input(device_opt, opt)
- docs = { }
+ docs = {}
docs["shortdesc"] = "I/O Fencing agent for Raritan Dominion PX"
docs["longdesc"] = "fence_raritan is an I/O Fencing agent which can be \
used with the Raritan DPXS12-20 Power Distribution Unit. It logs into \
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index f8c834d..a0d8d59 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -58,7 +58,7 @@ def set_power_status(conn, options):
def get_list(conn, options):
del conn
- outlets = { }
+ outlets = {}
try:
res = send_command(options, "vms")
@@ -68,13 +68,13 @@ def get_list(conn, options):
name = RE_GET_NAME.search(lines[i]).group(1)
outlets[name] = ("", None)
except AttributeError:
- return { }
+ return {}
except IndexError:
- return { }
+ return {}
return outlets
-def send_command(opt, command, method = "GET"):
+def send_command(opt, command, method="GET"):
## setup correct URL
if opt.has_key("--ssl"):
url = "https:"
@@ -87,7 +87,7 @@ def send_command(opt, command, method = "GET"):
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.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"]))
@@ -107,7 +107,7 @@ def send_command(opt, command, method = "GET"):
return result
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "web", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "ssl", "notls", "web", "port"]
atexit.register(atexit_handler)
@@ -115,7 +115,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for RHEV-M REST API"
docs["longdesc"] = "fence_rhevm is an I/O Fencing agent which can be \
used with RHEV-M REST API to fence virtual machines."
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 7e38aea..fcf5fb9 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -35,18 +35,18 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure"]
atexit.register(atexit_handler)
all_opt["login_timeout"]["default"] = 10
- all_opt["cmd_prompt"]["default"] = [ ">" ]
+ all_opt["cmd_prompt"]["default"] = [">"]
# This device will not allow us to login even with LANG=C
all_opt["ssh_options"]["default"] = "-F /dev/null"
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for IBM RSA"
docs["longdesc"] = "fence_rsa is an I/O Fencing agent \
which can be used with the IBM RSA II management interface. It \
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 415de10..9c1df5f 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -38,11 +38,11 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "secure", "cmd_prompt" ]
+ device_opt = ["ipaddr", "login", "passwd", "secure", "cmd_prompt"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "to quit:" ]
+ all_opt["cmd_prompt"]["default"] = ["to quit:"]
opt = process_input(device_opt)
@@ -52,7 +52,7 @@ def main():
options = check_input(device_opt, opt)
- docs = { }
+ docs = {}
docs["shortdesc"] = "I/O Fencing agent for Fujitsu-Siemens RSB"
docs["longdesc"] = "fence_rsb is an I/O Fencing agent \
which can be used with the Fujitsu-Siemens RSB management interface. It logs \
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 996a501..2b385b7 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -77,7 +77,7 @@ def set_power_status(conn, options):
fail(EC_TIMED_OUT)
def get_list_devices(conn, options):
- outlets = { }
+ outlets = {}
try:
conn.send_eol("show port")
@@ -104,15 +104,15 @@ def get_list_devices(conn, options):
return outlets
def main():
- device_opt = [ "fabric_fencing", "ipaddr", "login", "passwd", "cmd_prompt", "port" ]
+ device_opt = ["fabric_fencing", "ipaddr", "login", "passwd", "cmd_prompt", "port"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ " #> " ]
+ all_opt["cmd_prompt"]["default"] = [" #> "]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for QLogic SANBox2 FC switches"
docs["longdesc"] = "fence_sanbox2 is an I/O Fencing agent which can be used with \
QLogic SANBox2 FC switches. It logs into a SANBox2 switch via telnet and disables a specified \
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 5de395c..d92134c 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -68,17 +68,17 @@ def set_power_status(conn, options):
time.sleep(int(options["--power-wait"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "sudo" ]
+ device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "sudo"]
atexit.register(atexit_handler)
all_opt["secure"]["default"] = "1"
- all_opt["cmd_prompt"]["default"] = [ r"\[EXPECT\]#\ " ]
+ all_opt["cmd_prompt"]["default"] = [r"\[EXPECT\]#\ "]
all_opt["ssh_options"]["default"] = "-t '/bin/bash -c \"" + r"PS1=\[EXPECT\]#\ " + "/bin/bash --noprofile --norc\"'"
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for virsh"
docs["longdesc"] = "fence_virsh is an I/O Fencing agent \
which can be used with the virtual machines managed by libvirt. \
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 96aafb6..e252fe3 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -112,15 +112,15 @@ def vmware_prepare_command(options, add_login_params, additional_params):
res = options["--exec"]
if add_login_params:
- if vmware_internal_type==VMWARE_TYPE_ESX:
+ if vmware_internal_type == VMWARE_TYPE_ESX:
res += " --server '%s' --username '%s' --password '%s' "% (quote_for_run(options["--ip"]),
quote_for_run(options["--username"]),
quote_for_run(options["--password"]))
- elif vmware_internal_type==VMWARE_TYPE_SERVER2:
+ elif vmware_internal_type == VMWARE_TYPE_SERVER2:
res += " -h 'https://%s/sdk' -u '%s' -p '%s' -T server "% (quote_for_run(options["--ip"]),
quote_for_run(options["--username"]),
quote_for_run(options["--password"]))
- elif vmware_internal_type==VMWARE_TYPE_SERVER1:
+ elif vmware_internal_type == VMWARE_TYPE_SERVER1:
host_name_array = options["--ip"].split(':')
res += " -h '%s' -u '%s' -p '%s' -T server1 "% (quote_for_run(host_name_array[0]),
@@ -184,7 +184,7 @@ def vmware_get_outlets_vi(options, add_vm_name):
if vmware_disconnected_hack:
outlets[machine_array[0]] = ("", (
((machine_array[2].lower() in ["poweredon"]) and
- (machine_array[3].lower()=="connected"))
+ (machine_array[3].lower() == "connected"))
and "on" or "off"))
else:
outlets[machine_array[0]] = ("", ((machine_array[2].lower() in ["poweredon"]) and "on" or "off"))
@@ -236,10 +236,10 @@ 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"]))
+ ((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"]))
+ ((options["--action"] == "on" and "start" or "stop"), quote_for_run(options["--plug"]))
if options["--action"] == "off":
additional_params += " hard"
@@ -286,7 +286,7 @@ def vmware_check_vmware_type(options):
# Main agent method
def main():
- device_opt = [ "ipaddr", "login", "passwd", "secure",
+ device_opt = ["ipaddr", "login", "passwd", "secure",
"exec", "vmware_type", "vmware_datacenter"]
atexit.register(atexit_handler)
@@ -296,7 +296,7 @@ def main():
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for VMWare"
docs["longdesc"] = "fence_vmware is an I/O Fencing agent \
which can be used with the VMware ESX, VMware ESXi or VMware Server \
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index d9e5ff2..53fd9ea 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -34,7 +34,7 @@ def soap_login(options):
try:
conn = Client(url + "/vimService.wsdl")
- conn.set_options(location = url)
+ conn.set_options(location=url)
mo_ServiceInstance = Property('ServiceInstance')
mo_ServiceInstance._type = 'ServiceInstance'
@@ -74,8 +74,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"
@@ -87,7 +87,7 @@ def get_power_status(conn, options):
objSpec = conn.factory.create('ns0:ObjectSpec')
objSpec.obj = mo_ContainerView
- objSpec.selectSet = [ FolderTraversalSpec ]
+ objSpec.selectSet = [FolderTraversalSpec]
objSpec.skip = True
propSpec = conn.factory.create('ns0:PropertySpec')
@@ -96,8 +96,8 @@ def get_power_status(conn, options):
propSpec.type = "VirtualMachine"
propFilterSpec = conn.factory.create('ns0:PropertyFilterSpec')
- propFilterSpec.propSet = [ propSpec ]
- propFilterSpec.objectSet = [ objSpec ]
+ propFilterSpec.propSet = [propSpec]
+ propFilterSpec.objectSet = [objSpec]
try:
raw_machines = conn.service.RetrievePropertiesEx(mo_PropertyCollector, propFilterSpec)
@@ -158,7 +158,7 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
mo_SearchIndex._type = "SearchIndex"
- vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch = 1, uuid = options["--uuid"])
+ vm = conn.service.FindByUuid(mo_SearchIndex, vmSearch=1, uuid=options["--uuid"])
mo_machine = Property(vm.value)
mo_machine._type = "VirtualMachine"
@@ -181,7 +181,7 @@ def remove_tmp_dir(tmp_dir):
shutil.rmtree(tmp_dir)
def main():
- device_opt = [ "ipaddr", "login", "passwd", "web", "ssl", "notls", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "web", "ssl", "notls", "port"]
atexit.register(atexit_handler)
@@ -190,7 +190,7 @@ def main():
##
## Fence agent specific defaults
#####
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for VMWare over SOAP API"
docs["longdesc"] = "fence_vmware_soap is an I/O Fencing agent \
which can be used with the virtual machines managed by VMWare products \
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index de692f0..78cd4e1 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -178,16 +178,16 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
def main():
- device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
- "cmd_prompt", "secure", "port" ]
+ device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
+ "cmd_prompt", "secure", "port"]
atexit.register(atexit_handler)
- all_opt["cmd_prompt"]["default"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>" ]
+ all_opt["cmd_prompt"]["default"] = ["RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>"]
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "Fence agent for WTI"
docs["longdesc"] = "fence_wti is an I/O Fencing agent \
which can be used with the WTI Network Power Switch (NPS). It logs \
@@ -214,11 +214,11 @@ is running because the connection will block any necessary fencing actions."
re_login = re.compile("(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
re_prompt = re.compile("|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
+ result = conn.log_expect(options, [re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
if result == 0:
if options.has_key("--username"):
conn.send(options["--username"]+"\r\n")
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
+ result = conn.log_expect(options, [re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
else:
fail_usage("Failed: You have to set login name")
diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py
index 958b006..afe2054 100644
--- a/fence/agents/xenapi/fence_xenapi.py
+++ b/fence/agents/xenapi/fence_xenapi.py
@@ -44,7 +44,7 @@ REDHAT_COPYRIGHT=""
BUILD_DATE=""
#END_VERSION_GENERATION
-EC_BAD_SESSION = 1
+EC_BAD_SESSION = 1
# Find the status of the port given in the -U flag of options.
def get_power_fn(session, options):
if options.has_key("--verbose"):
@@ -199,13 +199,13 @@ def return_vm_reference(session, options):
def main():
- device_opt = [ "login", "passwd", "port", "no_login", "no_password", "session_url" ]
+ device_opt = ["login", "passwd", "port", "no_login", "no_password", "session_url"]
atexit.register(atexit_handler)
options = check_input(device_opt, process_input(device_opt))
- docs = { }
+ docs = {}
docs["shortdesc"] = "XenAPI based fencing for the Citrix XenServer virtual machines."
docs["longdesc"] = "\
fence_cxs is an I/O Fencing agent used on Citrix XenServer hosts. \
More information about the cluster-commits
mailing list