[Cluster-devel] [PATCH 1/2] code cleanup: Fix minor warning according to pylint

Marek 'marx' Grac mgrac at redhat.com
Mon Oct 29 12:10:38 UTC 2012


    * space / tab issue
    * missing space after operators
    * additional semicolons
    * unused import of modules
    * unused variable
---
 fence/agents/alom/fence_alom.py                 |   14 +-
 fence/agents/apc/fence_apc.py                   |   12 +-
 fence/agents/apc_snmp/fence_apc_snmp.py         |  158 +++++++-------
 fence/agents/bladecenter/fence_bladecenter.py   |    5 -
 fence/agents/cisco_mds/fence_cisco_mds.py       |   42 ++--
 fence/agents/cisco_ucs/fence_cisco_ucs.py       |    8 +-
 fence/agents/drac5/fence_drac5.py               |    7 +-
 fence/agents/eaton_snmp/fence_eaton_snmp.py     |  140 ++++++------
 fence/agents/eps/fence_eps.py                   |   44 ++--
 fence/agents/hpblade/fence_hpblade.py           |   16 +-
 fence/agents/ibmblade/fence_ibmblade.py         |   38 ++--
 fence/agents/ifmib/fence_ifmib.py               |   56 +++---
 fence/agents/ilo/fence_ilo.py                   |    2 +-
 fence/agents/ilo_mp/fence_ilo_mp.py             |    2 +-
 fence/agents/intelmodular/fence_intelmodular.py |   32 ++--
 fence/agents/ipdu/fence_ipdu.py                 |   94 ++++----
 fence/agents/ldom/fence_ldom.py                 |   34 ++--
 fence/agents/lib/XenAPI.py.py                   |  272 +++++++++++-----------
 fence/agents/lib/fencing.py.py                  |   12 +-
 fence/agents/lib/fencing_snmp.py.py             |   80 ++++----
 fence/agents/lpar/fence_lpar.py                 |    4 +-
 fence/agents/rhevm/fence_rhevm.py               |   10 +-
 fence/agents/sanbox2/fence_sanbox2.py           |    6 +-
 fence/agents/virsh/fence_virsh.py               |   28 ++--
 fence/agents/vmware/fence_vmware.py             |  160 +++++++-------
 fence/agents/vmware_soap/fence_vmware_soap.py   |    3 +-
 fence/agents/wti/fence_wti.py                   |    1 -
 fence/agents/xenapi/fence_xenapi.py             |   35 ++--
 28 files changed, 656 insertions(+), 659 deletions(-)

diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index 0f68050..8d5a4bd 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -5,7 +5,7 @@
 # Sun(tm) Advanced Lights Out Manager CMT v1.6.1
 # as found on SUN T2000 Niagara
 
-import sys, re, pexpect, time
+import sys, re, pexpect, time, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
@@ -19,9 +19,9 @@ def get_power_status(conn, options):
 	result = ""
 	try:
 		conn.send_eol("showplatform")
-                conn.log_expect(options, options["-c"], int(options["-Y"]))
-		status = re.search("standby",conn.before.lower())
-		result=(status!=None and "off" or "on")
+		conn.log_expect(options, options["-c"], int(options["-Y"]))
+		status = re.search("standby", conn.before.lower())
+		result = (status!=None and "off" or "on")
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
 	except pexpect.TIMEOUT:
@@ -31,9 +31,9 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	try:
-		cmd_line=(options["-o"]=="on" and "poweron" or "poweroff -f -y")
+		cmd_line = (options["-o"]=="on" and "poweron" or "poweroff -f -y")
 		conn.send_eol(cmd_line)
-		conn.log_expect(options, options["-c"],int(options["-g"]))
+		conn.log_expect(options, options["-c"], int(options["-g"]))
 		#Get the machine some time between poweron and poweroff
 		time.sleep(int(options["-g"]))
 		
@@ -63,7 +63,7 @@ agent which can be used with ALOM connected machines."
 		
 	# Operate the fencing device
 	conn = fence_login(options)
-	result = fence_action(conn, options, set_power_status, get_power_status,None)
+	result = fence_action(conn, options, set_power_status, get_power_status, None)
 
 	# Logout from system
 	try:
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 0406955..d0ed9b6 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -33,10 +33,10 @@ def get_power_status(conn, options):
 
 		version = 0
 		admin = 0
-		switch = 0;
+		switch = 0
 
 		if (None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before)):
-			switch = 1;
+			switch = 1
 			if (None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before)):
 				if (0 == options.has_key("-s")):
 					fail_usage("Failed: You have to enter physical switch number")
@@ -69,7 +69,7 @@ def get_power_status(conn, options):
 			
 		while True:
 			exp_result = conn.log_expect(options, [ options["-c"],  "Press <ENTER>" ], int(options["-Y"]))
-			lines = conn.before.split("\n");
+			lines = conn.before.split("\n")
 			show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
 			for x in lines:
 				res = show_re.search(x)
@@ -111,7 +111,7 @@ def set_power_status(conn, options):
 		switch = 0
 
 		if (None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before)):
-			switch = 1;
+			switch = 1
 			## MasterSwitch has different schema for on/off actions
 			action = {
 				'on' : "1",
@@ -206,8 +206,8 @@ will block any necessary fencing actions."
 	## Support for -n [switch]:[plug] notation that was used before
 	if (options.has_key("-n") == 1) and (-1 != options["-n"].find(":")):
 		(switch, plug) = options["-n"].split(":", 1)
-		options["-s"] = switch;
-		options["-n"] = plug;
+		options["-s"] = switch
+		options["-n"] = plug
 
 	##
 	## Operate the fencing device
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 660eaf7..cc624a1 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -8,7 +8,7 @@
 # - APC Switched Rack PDU (MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin
 #    MN:AP7951 HR:B2) - SNMP v1
 
-import sys, re, pexpect
+import sys
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -21,146 +21,146 @@ BUILD_DATE=""
 
 ### CONSTANTS ###
 # oid defining fence device
-OID_SYS_OBJECT_ID='.1.3.6.1.2.1.1.2.0'
+OID_SYS_OBJECT_ID = '.1.3.6.1.2.1.1.2.0'
 
 ### GLOBAL VARIABLES ###
 # Device - see ApcRPDU, ApcMSP, ApcMS
-device=None
+device = None
 
 # Port ID
-port_id=None
+port_id = None
 # Switch ID
-switch_id=None
+switch_id = None
 
 # Classes describing Device params
 class ApcRPDU:
 	# Rack PDU
-	status_oid=      '.1.3.6.1.4.1.318.1.1.12.3.5.1.1.4.%d'
-	control_oid=     '.1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.%d'
-	outlet_table_oid='.1.3.6.1.4.1.318.1.1.12.3.5.1.1.2'
-	ident_str="APC rPDU"
-	state_on=1
-	state_off=2
-	turn_on=1
-	turn_off=2
-	has_switches=False
+	status_oid =       '.1.3.6.1.4.1.318.1.1.12.3.5.1.1.4.%d'
+	control_oid =      '.1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.318.1.1.12.3.5.1.1.2'
+	ident_str = "APC rPDU"
+	state_on = 1
+	state_off = 2
+	turn_on = 1
+	turn_off = 2
+	has_switches = False
 
 class ApcMSP:
 	# Master Switch+
-	status_oid=      '.1.3.6.1.4.1.318.1.1.6.7.1.1.5.%d.1.%d'
-	control_oid=     '.1.3.6.1.4.1.318.1.1.6.5.1.1.5.%d.1.%d'
-	outlet_table_oid='.1.3.6.1.4.1.318.1.1.6.7.1.1.4'
-	ident_str="APC Master Switch+"
-	state_on=1
-	state_off=2
-	turn_on=1
-	turn_off=3
-	has_switches=True
+	status_oid =       '.1.3.6.1.4.1.318.1.1.6.7.1.1.5.%d.1.%d'
+	control_oid =      '.1.3.6.1.4.1.318.1.1.6.5.1.1.5.%d.1.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.318.1.1.6.7.1.1.4'
+	ident_str = "APC Master Switch+"
+	state_on = 1
+	state_off = 2
+	turn_on = 1
+	turn_off = 3
+	has_switches = True
 
 class ApcMS:
 	# Master Switch - seems oldest, but supported on every APC PDU
-	status_oid=      '.1.3.6.1.4.1.318.1.1.4.4.2.1.3.%d'
-	control_oid=     '.1.3.6.1.4.1.318.1.1.4.4.2.1.3.%d'
-	outlet_table_oid='.1.3.6.1.4.1.318.1.1.4.4.2.1.4'
-	ident_str="APC Master Switch (fallback)"
-	state_on=1
-	state_off=2
-	turn_on=1
-	turn_off=2
-	has_switches=False
+	status_oid =       '.1.3.6.1.4.1.318.1.1.4.4.2.1.3.%d'
+	control_oid =      '.1.3.6.1.4.1.318.1.1.4.4.2.1.3.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.318.1.1.4.4.2.1.4'
+	ident_str = "APC Master Switch (fallback)"
+	state_on = 1
+	state_off = 2
+	turn_on = 1
+	turn_off = 2
+	has_switches = False
 
 ### FUNCTIONS ###
-def apc_set_device(conn,options):
+def apc_set_device(conn, options):
 	global device
 
-	agents_dir={'.1.3.6.1.4.1.318.1.3.4.5':ApcRPDU,
-		    '.1.3.6.1.4.1.318.1.3.4.4':ApcMSP,
-		    None:ApcMS}
+	agents_dir = {'.1.3.6.1.4.1.318.1.3.4.5':ApcRPDU,
+		     '.1.3.6.1.4.1.318.1.3.4.4':ApcMSP,
+		     None:ApcMS}
 
 	# First resolve type of APC
-	apc_type=conn.walk(OID_SYS_OBJECT_ID)
+	apc_type = conn.walk(OID_SYS_OBJECT_ID)
 
 	if (not ((len(apc_type)==1) and (agents_dir.has_key(apc_type[0][1])))):
-		apc_type=[[None,None]]
+		apc_type = [[None, None]]
 
-	device=agents_dir[apc_type[0][1]]
+	device = agents_dir[apc_type[0][1]]
 
 	conn.log_command("Trying %s"%(device.ident_str))
 
-def apc_resolv_port_id(conn,options):
-	global port_id,switch_id,device
+def apc_resolv_port_id(conn, options):
+	global port_id, switch_id, device
 
-	if (device==None):
-		apc_set_device(conn,options)
+	if (device == None):
+		apc_set_device(conn, options)
 
 	# Now we resolv port_id/switch_id
 	if ((options["-n"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
-		port_id=int(options["-n"])
+		port_id = int(options["-n"])
 
 		if (device.has_switches):
-			switch_id=int(options["-s"])
+			switch_id = int(options["-s"])
 	else:
-		table=conn.walk(device.outlet_table_oid,30)
+		table = conn.walk(device.outlet_table_oid, 30)
 
 		for x in table:
-			if (x[1].strip('"')==options["-n"]):
-				t=x[0].split('.')
+			if (x[1].strip('"') == options["-n"]):
+				t = x[0].split('.')
 				if (device.has_switches):
-					port_id=int(t[len(t)-1])
-					switch_id=int(t[len(t)-3])
+					port_id = int(t[len(t)-1])
+					switch_id = int(t[len(t)-3])
 				else:
-					port_id=int(t[len(t)-1])
+					port_id = int(t[len(t)-1])
 
-	if (port_id==None):
+	if (port_id == None):
 		fail_usage("Can't find port with name %s!"%(options["-n"]))
 
-def get_power_status(conn,options):
-	global port_id,switch_id,device
+def get_power_status(conn, options):
+	global port_id, switch_id, device
 
-	if (port_id==None):
-		apc_resolv_port_id(conn,options)
+	if (port_id == None):
+		apc_resolv_port_id(conn, options)
 
-	oid=((device.has_switches) and device.status_oid%(switch_id,port_id) or device.status_oid%(port_id))
+	oid = ((device.has_switches) and device.status_oid%(switch_id, port_id) or device.status_oid%(port_id))
 
-	(oid,status)=conn.get(oid)
+	(oid, status) = conn.get(oid)
 	return (status==str(device.state_on) and "on" or "off")
 
 def set_power_status(conn, options):
-	global port_id,switch_id,device
+	global port_id, switch_id, device
 
-	if (port_id==None):
-		apc_resolv_port_id(conn,options)
+	if (port_id == None):
+		apc_resolv_port_id(conn, options)
 
-	oid=((device.has_switches) and device.control_oid%(switch_id,port_id) or device.control_oid%(port_id))
+	oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
 
-	conn.set(oid,(options["-o"]=="on" and device.turn_on or device.turn_off))
+	conn.set(oid, (options["-o"]=="on" and device.turn_on or device.turn_off))
 
 
 def get_outlets_status(conn, options):
 	global device
 
-	result={}
+	result = {}
 
-	if (device==None):
-		apc_set_device(conn,options)
+	if (device == None):
+		apc_set_device(conn, options)
 
-	res_ports=conn.walk(device.outlet_table_oid,30)
+	res_ports = conn.walk(device.outlet_table_oid, 30)
 
 	for x in res_ports:
-		t=x[0].split('.')
+		t = x[0].split('.')
 
-		port_num=((device.has_switches) and "%s:%s"%(t[len(t)-3],t[len(t)-1]) or "%s"%(t[len(t)-1]))
+		port_num = ((device.has_switches) and "%s:%s"%(t[len(t)-3], t[len(t)-1]) or "%s"%(t[len(t)-1]))
 
-                port_name=x[1].strip('"')
-                port_status=""
-                result[port_num]=(port_name,port_status)
+		port_name = x[1].strip('"')
+		port_status = ""
+		result[port_num] = (port_name, port_status)
 
-        return result
+	return result
 
 # Define new options
 def apc_snmp_define_defaults():
-	all_opt["snmp_version"]["default"]="1"
-	all_opt["community"]["default"]="private"
+	all_opt["snmp_version"]["default"] = "1"
+	all_opt["community"]["default"] = "private"
 
 # Main agent method
 def main():
@@ -168,24 +168,24 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport","inet4_only","inet6_only" ]
+		       "udpport", "inet4_only", "inet6_only" ]
 
 	atexit.register(atexit_handler)
 
 	snmp_define_defaults ()
 	apc_snmp_define_defaults()
 
-	options=check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
         ## Support for -n [switch]:[plug] notation that was used before
 	if ((options.has_key("-n")) and (-1 != options["-n"].find(":"))):
 		(switch, plug) = options["-n"].split(":", 1)
 		if ((switch.isdigit()) and (plug.isdigit())):
-		        options["-s"] = switch
+			options["-s"] = switch
 			options["-n"] = plug
 
 	if (not (options.has_key("-s"))):
-		options["-s"]="1"
+		options["-s"] = "1"
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for APC over SNMP"
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index ab06b27..49a3b5b 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -47,11 +47,6 @@ def get_power_status(conn, options):
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	action = {
-		'on' : "powerup",
-		'off': "powerdown"
-	}[options["-o"]]
-
 	try:
 		node_cmd = "system:blade\[" + options["-n"] + "\]>"
 
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index e2a1e91..8f3ef9d 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -6,7 +6,7 @@
 # - Cisco MDS 9124 (1 Slot) Chassis ("1/2/4 Gbps FC/Supervisor-2") Motorola, e500
 #   with BIOS 1.0.16, kickstart 4.1(1c), system 4.1(1c)
 
-import sys, re, pexpect
+import sys, re
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -19,33 +19,33 @@ BUILD_DATE=""
 
 ### CONSTANTS ###
 # Cisco admin status
-PORT_ADMIN_STATUS_OID=".1.3.6.1.2.1.75.1.2.2.1.1"
+PORT_ADMIN_STATUS_OID = ".1.3.6.1.2.1.75.1.2.2.1.1"
 
 # IF-MIB trees for alias, status and port
-ALIASES_OID=".1.3.6.1.2.1.31.1.1.1.18"
-PORTS_OID=".1.3.6.1.2.1.2.2.1.2"
+ALIASES_OID = ".1.3.6.1.2.1.31.1.1.1.18"
+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 ###
 
 # Convert cisco port name (fc(x)/(y)) to OID
 def cisco_port2oid(port):
-	port=port.lower()
+	port = port.lower()
 
-	nums=re.match('^fc(\d+)/(\d+)$',port)
+	nums = re.match('^fc(\d+)/(\d+)$', port)
 
 	if ((nums) and (len(nums.groups()))==2):
-		return "%s.%d.%d"%(PORT_ADMIN_STATUS_OID,int(nums.group(1))+21,int(nums.group(2))-1)
+		return "%s.%d.%d"% (PORT_ADMIN_STATUS_OID, int(nums.group(1))+21, int(nums.group(2))-1)
 	else:
 		fail_usage("Mangled port number: %s"%(port))
 
-def get_power_status(conn,options):
+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):
@@ -56,24 +56,24 @@ def set_power_status(conn, options):
 # 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
 def array_to_dict(ar):
-	return dict(map(lambda y:[y[0].split('.')[-1],y[1]],ar))
+	return dict(map(lambda y:[y[0].split('.')[-1], y[1]], ar))
 
 def get_outlets_status(conn, options):
-	result={}
+	result = {}
 
-	res_fc=conn.walk(PORTS_OID,30)
-	res_aliases=array_to_dict(conn.walk(ALIASES_OID,30))
+	res_fc = conn.walk(PORTS_OID, 30)
+	res_aliases = array_to_dict(conn.walk(ALIASES_OID, 30))
 
-	fc_re=re.compile('^"fc\d+/\d+"$')
+	fc_re = re.compile('^"fc\d+/\d+"$')
 
 	for x in res_fc:
 		if fc_re.match(x[1]):
-			port_num=x[0].split('.')[-1]
+			port_num = x[0].split('.')[-1]
 
-			port_name=x[1].strip('"')
-			port_alias=(res_aliases.has_key(port_num) and res_aliases[port_num].strip('"') or "")
-			port_status=""
-			result[port_name]=(port_alias,port_status)
+			port_name = x[1].strip('"')
+			port_alias = (res_aliases.has_key(port_num) and res_aliases[port_num].strip('"') or "")
+			port_status = ""
+			result[port_name] = (port_alias, port_status)
 
 	return result
 
@@ -101,7 +101,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 84cb4fd..a34a580 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, socket
+import sys, re
 import pycurl, StringIO
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
@@ -11,8 +11,8 @@ 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_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)
 
@@ -121,7 +121,7 @@ used with Cisco UCS to fence machines."
 		## Cookie is absenting in response
 		fail(EC_LOGIN_DENIED)
 
-	options["cookie"] = result.group(1);
+	options["cookie"] = result.group(1)
 
 	##
 	## Modify suborg to format /suborg
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index b261e50..d8f4bb8 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -76,7 +76,6 @@ def get_list_devices(conn, options):
 			## when some fence devices supported by fence agent
 			## works with 'list' and other should returns 'N/A'
 			print "N/A"
-			pass
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
 	except pexpect.TIMEOUT:
@@ -114,12 +113,12 @@ By default, the telnet interface is not  enabled."
 		if 0 == options.has_key("-m") and 0 == ["monitor", "list"].count(options["-o"].lower()):
 			fail_usage("Failed: You have to enter module name (-m)")
 			
-		options["model"]="DRAC CMC"		
+		options["model"] = "DRAC CMC"
 	elif conn.before.find("DRAC 5") >= 0:
-		options["model"]="DRAC 5"
+		options["model"] = "DRAC 5"
 	else:
 		## Assume this is DRAC 5 by default as we don't want to break anything
-		options["model"]="DRAC 5"
+		options["model"] = "DRAC 5"
 
 	result = fence_action(conn, options, set_power_status, get_power_status, get_list_devices)
 
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index e4c3ea3..24e29fe 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -6,7 +6,7 @@
 # - Eaton ePDU Switched - SNMP v1
 #   EATON | Powerware ePDU model: Switched ePDU (IPV3600), firmware: 2.0.K
 
-import sys, re, pexpect
+import sys
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -19,73 +19,73 @@ BUILD_DATE=""
 
 ### CONSTANTS ###
 # oid defining fence device
-OID_SYS_OBJECT_ID='.1.3.6.1.2.1.1.2.0'
+OID_SYS_OBJECT_ID = '.1.3.6.1.2.1.1.2.0'
 
 ### GLOBAL VARIABLES ###
 # Device - see EatonManagedePDU, EatonSwitchedePDU
-device=None
+device = None
 
 # Port ID
-port_id=None
+port_id = None
 # Switch ID
-switch_id=None
+switch_id = None
 
 # Did we issue a set before get (to adjust OID with Switched ePDU)
-after_set=False
+after_set = False
 
 # Classes describing Device params
 # Managed ePDU
 class EatonManagedePDU:
-	status_oid=      '.1.3.6.1.4.1.534.6.6.6.1.2.2.1.3.%d'
-	control_oid=     '.1.3.6.1.4.1.534.6.6.6.1.2.2.1.3.%d'
-	outlet_table_oid='.1.3.6.1.4.1.534.6.6.6.1.2.2.1.1'
-	ident_str="Eaton Managed ePDU"
-	state_off=0
-	state_on=1
-	state_cycling=2	# FIXME: not usable with fence-agents
-	turn_off=0
-	turn_on=1
-	turn_cycle=2	# FIXME: not usable with fence-agents
-	has_switches=False
+	status_oid =       '.1.3.6.1.4.1.534.6.6.6.1.2.2.1.3.%d'
+	control_oid =      '.1.3.6.1.4.1.534.6.6.6.1.2.2.1.3.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.534.6.6.6.1.2.2.1.1'
+	ident_str = "Eaton Managed ePDU"
+	state_off = 0
+	state_on = 1
+	state_cycling = 2	# FIXME: not usable with fence-agents
+	turn_off = 0
+	turn_on = 1
+	turn_cycle = 2		# FIXME: not usable with fence-agents
+	has_switches = False
 
 # Switched ePDU (Pulizzi 2)
 # NOTE: sysOID reports "20677.1", while data are actually at "20677.2"
 class EatonSwitchedePDU:
-	status_oid=      '.1.3.6.1.4.1.20677.2.6.3.%d.0'
-	control_oid=     '.1.3.6.1.4.1.20677.2.6.2.%d.0'
-	outlet_table_oid='.1.3.6.1.4.1.20677.2.6.3'
-	ident_str="Eaton Switched ePDU"
-	state_off=2
-	state_on=1
-	state_cycling=0 # Note: this status doesn't exist on this device
-	turn_off=2
-	turn_on=1
-	turn_cycle=3	# FIXME: not usable with fence-agents
-	has_switches=False
+	status_oid =       '.1.3.6.1.4.1.20677.2.6.3.%d.0'
+	control_oid =      '.1.3.6.1.4.1.20677.2.6.2.%d.0'
+	outlet_table_oid = '.1.3.6.1.4.1.20677.2.6.3'
+	ident_str = "Eaton Switched ePDU"
+	state_off = 2
+	state_on = 1
+	state_cycling = 0 # Note: this status doesn't exist on this device
+	turn_off = 2
+	turn_on = 1
+	turn_cycle = 3	# FIXME: not usable with fence-agents
+	has_switches = False
 
 ### FUNCTIONS ###
-def eaton_set_device(conn,options):
+def eaton_set_device(conn, options):
 	global device
 
-	agents_dir={'.1.3.6.1.4.1.534.6.6.6':EatonManagedePDU,
+	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 }
 
 	# First resolve type of Eaton
-	eaton_type=conn.walk(OID_SYS_OBJECT_ID)
+	eaton_type = conn.walk(OID_SYS_OBJECT_ID)
 
 	if (not ((len(eaton_type)==1) and (agents_dir.has_key(eaton_type[0][1])))):
-		eaton_type=[[None,None]]
+		eaton_type = [[None, None]]
 
-	device=agents_dir[eaton_type[0][1]]
+	device = agents_dir[eaton_type[0][1]]
 
 	conn.log_command("Trying %s"%(device.ident_str))
 
-def eaton_resolv_port_id(conn,options):
-	global port_id,switch_id,device
+def eaton_resolv_port_id(conn, options):
+	global port_id, switch_id, device
 
 	if (device==None):
-		eaton_set_device(conn,options)
+		eaton_set_device(conn, options)
 
 	# Restore the increment, that was removed in main for ePDU Managed
 	if (device.ident_str == "Eaton Switched ePDU"):
@@ -93,24 +93,24 @@ def eaton_resolv_port_id(conn,options):
 
 	# Now we resolv port_id/switch_id
 	if ((options["-n"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
-		port_id=int(options["-n"])
+		port_id = int(options["-n"])
 
 		if (device.has_switches):
-			switch_id=int(options["-s"])
+			switch_id = int(options["-s"])
 	else:
-		table=conn.walk(device.outlet_table_oid,30)
+		table = conn.walk(device.outlet_table_oid, 30)
 
 		for x in table:
 			if (x[1].strip('"')==options["-n"]):
-				t=x[0].split('.')
+				t = x[0].split('.')
 				if (device.has_switches):
-					port_id=int(t[len(t)-1])
-					switch_id=int(t[len(t)-3])
+					port_id = int(t[len(t)-1])
+					switch_id = int(t[len(t)-3])
 				else:
 					if (device.ident_str == "Eaton Switched ePDU"):
-						port_id=int(t[len(t)-3])
+						port_id = int(t[len(t)-3])
 					else:
-						port_id=int(t[len(t)-1])
+						port_id = int(t[len(t)-1])
 
 	if (port_id==None):
 		# Restore index offset, to provide a valid error output on Managed ePDU
@@ -118,21 +118,21 @@ def eaton_resolv_port_id(conn,options):
 			options["-n"] = str(int(options["-n"]) + 1)
 		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
+def get_power_status(conn, options):
+	global port_id, switch_id, device, after_set
 
 	if (port_id==None):
-		eaton_resolv_port_id(conn,options)
+		eaton_resolv_port_id(conn, options)
 
 	# Ajust OID for Switched ePDU when the get is after a set
 	if ((after_set == True) and (device.ident_str == "Eaton Switched ePDU")):
-		port_id-=1
-		after_set=False
+		port_id -= 1
+		after_set = False
 
-	oid=((device.has_switches) and device.status_oid%(switch_id,port_id) or device.status_oid%(port_id))
+	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)):
@@ -143,18 +143,18 @@ 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, switch_id, device, after_set
 
 	after_set = True
 
 	if (port_id==None):
-		eaton_resolv_port_id(conn,options)
+		eaton_resolv_port_id(conn, options)
 
 	# Controls start at #2 on Switched ePDU, since #1 is the global command
 	if (device.ident_str == "Eaton Switched ePDU"):
-		port_id=int(port_id)+1
+		port_id = int(port_id)+1
 
-	oid=((device.has_switches) and device.control_oid%(switch_id,port_id) or device.control_oid%(port_id))
+	oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
 
 	conn.set(oid,(options["-o"]=="on" and device.turn_on or device.turn_off))
 
@@ -163,37 +163,37 @@ def get_outlets_status(conn, options):
 	global device
 
 	outletCount = 0
-	result={}
+	result = {}
 
 	if (device==None):
-		eaton_set_device(conn,options)
+		eaton_set_device(conn, options)
 
-	res_ports=conn.walk(device.outlet_table_oid,30)
+	res_ports = conn.walk(device.outlet_table_oid, 30)
 
 	for x in res_ports:
-		outletCount+=1
-		status=x[1]
-		t=x[0].split('.')
+		outletCount += 1
+		status = x[1]
+		t = x[0].split('.')
 
 		# Plug indexing start from zero, so we substract '1' from the
 		# user's given plug number
 		if (device.ident_str == "Eaton Managed ePDU"):
-			port_num=str(int(((device.has_switches) and "%s:%s"%(t[len(t)-3],t[len(t)-1]) or "%s"%(t[len(t)-1]))) + 1)
+			port_num = str(int(((device.has_switches) and "%s:%s"%(t[len(t)-3], t[len(t)-1]) or "%s"%(t[len(t)-1]))) + 1)
 
 			# Plug indexing start from zero, so we add '1'
 			# for the user's exposed plug number
-			port_name=str(int(x[1].strip('"')) + 1)
-			port_status=""
-			result[port_num]=(port_name,port_status)
+			port_name = str(int(x[1].strip('"')) + 1)
+			port_status = ""
+			result[port_num] = (port_name, port_status)
 		else:
 			# Switched ePDU do not propose an outletCount OID!
 			# Invalid status (ie value == '0'), retrieved via the walk,
 			# means the outlet is absent
-			port_num=str(outletCount)
-			port_name=str(outletCount)
-			port_status=""
+			port_num = str(outletCount)
+			port_name = str(outletCount)
+			port_status = ""
 			if (status != '0'):
-				result[port_num]=(port_name,port_status)
+				result[port_num] = (port_name, port_status)
 
 	return result
 
@@ -213,7 +213,7 @@ def main():
 	all_opt["power_wait"]["default"] = 2
 	all_opt["snmp_version"]["default"] = "1"
 	all_opt["community"]["default"] = "private"
-	options=check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
 	# Plug indexing start from zero on ePDU Managed, so we substract '1' from
 	# the user's given plug number.
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 106fd1c..e1b8696 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -3,8 +3,8 @@
 # The Following Agent Has Been Tested On:
 # ePowerSwitch 8M+ version 1.0.0.4
 
-import sys, re, time
-import httplib, base64, string,socket
+import sys, re
+import httplib, base64, string, socket
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
@@ -15,8 +15,8 @@ BUILD_DATE=""
 #END_VERSION_GENERATION
 
 # Log actions and results from EPS device
-def eps_log(options,str):
-	if options["log"]>=LOG_MODE_VERBOSE:
+def eps_log(options, str):
+	if options["log"] >= LOG_MODE_VERBOSE:
 		options["debug_fh"].write(str)
 
 # Run command on EPS device.
@@ -27,35 +27,35 @@ def eps_run_command(options, params):
 		# New http connection
 		conn = httplib.HTTPConnection(options["-a"])
 
-		request_str="/"+options["-c"]
+		request_str = "/"+options["-c"]
 
 		if (params!=""):
-			request_str+="?"+params
+			request_str += "?"+params
 
-		eps_log(options,"GET "+request_str+"\n")
+		eps_log(options, "GET "+request_str+"\n")
 		conn.putrequest('GET', request_str)
 
 		if (options.has_key("-l")):
 			if (not options.has_key("-p")):
-				options["-p"]="" # Default is empty password
+				options["-p"] = "" # Default is empty password
 				
 			# String for Authorization header
 			auth_str = 'Basic ' + string.strip(base64.encodestring(options["-l"]+':'+options["-p"]))
-			eps_log(options,"Authorization:"+auth_str+"\n")
-			conn.putheader('Authorization',auth_str)
+			eps_log(options, "Authorization:"+auth_str+"\n")
+			conn.putheader('Authorization', auth_str)
 
 		conn.endheaders()
 
 		response = conn.getresponse()
 
-		eps_log(options,"%d %s\n"%(response.status,response.reason))
+		eps_log(options, "%d %s\n"%(response.status, response.reason))
 
 		#Response != OK -> couldn't login
 		if (response.status!=200):
 			fail(EC_LOGIN_DENIED)
 
-		result=response.read()
-		eps_log(options,result+"\n")
+		result = response.read()
+		eps_log(options, result+"\n")
 		conn.close()
 
 	except socket.timeout:
@@ -66,12 +66,12 @@ def eps_run_command(options, params):
 	return result
 
 def get_power_status(conn, options):
-	ret_val=eps_run_command(options,"")
+	ret_val = eps_run_command(options,"")
 
-	result={}
-	status=re.findall("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 = {}
+	status = re.findall("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"))
 
 	if (not (options["-o"] in ['monitor','list'])):
 		if (not (options["-n"] in result)):
@@ -82,11 +82,11 @@ def get_power_status(conn, options):
 		return result
 
 def set_power_status(conn, options):
-	ret_val=eps_run_command(options,"P%s=%s"%(options["-n"],(options["-o"]=="on" and "1" or "0")))
+	ret_val = eps_run_command(options, "P%s=%s"%(options["-n"], (options["-o"]=="on" and "1" or "0")))
 
 # Define new option
 def eps_define_new_opts():
-	all_opt["hidden_page"]={
+	all_opt["hidden_page"] = {
 		"getopt" : "c:",
 		"longopt" : "page",
 		"help":"-c, --page=<page>              Name of hidden page (default hidden.htm)",
@@ -105,7 +105,7 @@ def main():
 
 	eps_define_new_opts()
 
-	options = check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }           
 	docs["shortdesc"] = "Fence agent for ePowerSwitch" 
@@ -121,7 +121,7 @@ page feature must be enabled and properly configured."
 	show_docs(options, docs)
 
 	#Run fence action. Conn is None, beacause we always need open new http connection
-	result = fence_action(None, options, set_power_status, get_power_status,get_power_status)
+	result = fence_action(None, options, set_power_status, get_power_status, get_power_status)
 
 	sys.exit(result)
 
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index 4e125c1..2953ddc 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -24,11 +24,11 @@ def get_power_status(conn, options):
 		power_re = re.compile("^\s*Power: (.*?)\s*$")
 		status = "unknown"
 		for line in conn.before.splitlines():
-		        res = power_re.search(line)
-		        if res != None:
-		                status = res.group(1)
+			res = power_re.search(line)
+			if res != None:
+				status = res.group(1)
 
-                if status == "unknown":
+		if status == "unknown":
 			if options.has_key("-M"):
 				return "off"
 			else:
@@ -42,10 +42,10 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	try:
-	        if options["-o"] == "on":
-	                conn.send_eol("poweron server " + options["-n"])
-                elif options["-o"] == "off":
-                        conn.send_eol("poweroff server " + options["-n"] + " force")
+		if options["-o"] == "on":
+			conn.send_eol("poweron server " + options["-n"])
+		elif options["-o"] == "off":
+			conn.send_eol("poweroff server " + options["-n"] + " force")
 		conn.log_expect(options, options["-c"], int(options["-Y"]))
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index ec992f4..9805036 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect
+import sys
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -13,38 +13,38 @@ 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
+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
 
 # Status constants returned as value from SNMP
-STATUS_DOWN=0
-STATUS_UP=1
+STATUS_DOWN = 0
+STATUS_UP = 1
 
 # Status constants to set as value to SNMP
-STATUS_SET_OFF=0
-STATUS_SET_ON=1
+STATUS_SET_OFF = 0
+STATUS_SET_ON = 1
 
 ### FUNCTIONS ###
 
-def get_power_status(conn,options):
-	(oid,status)=conn.get("%s.%s"%(STATUSES_OID,options["-n"]))
+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")
 
 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))
+	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):
-	result={}
+	result = {}
 
-	res_blades=conn.walk(STATUSES_OID,30)
+	res_blades = conn.walk(STATUSES_OID, 30)
 
 	for x in res_blades:
-		port_num=x[0].split('.')[-1]
+		port_num = x[0].split('.')[-1]
 
-		port_alias=""
-		port_status=(x[1]==str(STATUS_UP) and "on" or "off")
+		port_alias = ""
+		port_status = (x[1]==str(STATUS_UP) and "on" or "off")
 
-		result[port_num]=(port_alias,port_status)
+		result[port_num] = (port_alias, port_status)
 
 	return result
 
@@ -60,10 +60,10 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-	all_opt["snmp_version"]["default"]="1"
+	snmp_define_defaults()
+	all_opt["snmp_version"]["default"] = "1"
 
-	options=check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for IBM BladeCenter over SNMP"
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index 0b0a71d..fc96fb3 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -8,7 +8,7 @@
 # - Partially with APC PDU (Network Management Card AOS v2.7.0, Rack PDU APP v2.7.3)
 #   Only lance if is visible
 
-import sys, re, pexpect
+import sys
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -21,33 +21,33 @@ BUILD_DATE=""
 
 ### CONSTANTS ###
 # IF-MIB trees for alias, status and port
-ALIASES_OID=".1.3.6.1.2.1.31.1.1.1.18"
-PORTS_OID=".1.3.6.1.2.1.2.2.1.2"
-STATUSES_OID=".1.3.6.1.2.1.2.2.1.7"
+ALIASES_OID = ".1.3.6.1.2.1.31.1.1.1.18"
+PORTS_OID = ".1.3.6.1.2.1.2.2.1.2"
+STATUSES_OID = ".1.3.6.1.2.1.2.2.1.7"
 
 # Status constants returned as value from SNMP
-STATUS_UP=1
-STATUS_DOWN=2
-STATUS_TESTING=3
+STATUS_UP = 1
+STATUS_DOWN = 2
+STATUS_TESTING = 3
 
 ### GLOBAL VARIABLES ###
 # Port number converted from port name or index
-port_num=None
+port_num = None
 
 ### FUNCTIONS ###
 
 # Convert port index or name to port index
-def port2index(conn,port):
-	res=None
+def port2index(conn, port):
+	res = None
 
 	if (port.isdigit()):
-		res=int(port)
+		res = int(port)
 	else:
-		ports=conn.walk(PORTS_OID,30)
+		ports = conn.walk(PORTS_OID, 30)
 
 		for x in ports:
 			if (x[1].strip('"')==port):
-				res=int(x[0].split('.')[-1])
+				res = int(x[0].split('.')[-1])
 				break
 
 	if (res==None):
@@ -55,41 +55,41 @@ def port2index(conn,port):
 
 	return res
 
-def get_power_status(conn,options):
+def get_power_status(conn, options):
 	global port_num
 
 	if (port_num==None):
-		port_num=port2index(conn,options["-n"])
+		port_num = port2index(conn, options["-n"])
 
-	(oid,status)=conn.get("%s.%d"%(STATUSES_OID,port_num))
+	(oid, status) = conn.get("%s.%d"%(STATUSES_OID, port_num))
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
 	global port_num
 
 	if (port_num==None):
-		port_num=port2index(conn,options["-n"])
+		port_num = port2index(conn, options["-n"])
 
-	conn.set("%s.%d"%(STATUSES_OID,port_num),(options["-o"]=="on" and STATUS_UP or STATUS_DOWN))
+	conn.set("%s.%d"%(STATUSES_OID, port_num), (options["-o"]=="on" and STATUS_UP or STATUS_DOWN))
 
 # 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
 def array_to_dict(ar):
-	return dict(map(lambda y:[y[0].split('.')[-1],y[1]],ar))
+	return dict(map(lambda y:[y[0].split('.')[-1], y[1]], ar))
 
 def get_outlets_status(conn, options):
-	result={}
+	result = {}
 
-	res_fc=conn.walk(PORTS_OID,30)
-	res_aliases=array_to_dict(conn.walk(ALIASES_OID,30))
+	res_fc = conn.walk(PORTS_OID, 30)
+	res_aliases = array_to_dict(conn.walk(ALIASES_OID, 30))
 
 	for x in res_fc:
-		port_num=x[0].split('.')[-1]
+		port_num = x[0].split('.')[-1]
 
-		port_name=x[1].strip('"')
-		port_alias=(res_aliases.has_key(port_num) and res_aliases[port_num].strip('"') or "")
-		port_status=""
-		result[port_name]=(port_alias,port_status)
+		port_name = x[1].strip('"')
+		port_alias = (res_aliases.has_key(port_num) and res_aliases[port_num].strip('"') or "")
+		port_status = ""
+		result[port_name] = (port_alias, port_status)
 
 	return result
 
@@ -106,7 +106,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	snmp_define_defaults ()
-	all_opt["snmp_version"]["default"]="2c"
+	all_opt["snmp_version"]["default"] = "2c"
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index fca72a7..715b163 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -11,7 +11,7 @@
 ##  iLO2 / firmware 1.50 / RIBCL 2.22
 #####
 
-import sys, re, pexpect, socket
+import sys, re, pexpect
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 9ac8701..9c18336 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, socket
+import sys, re, pexpect, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index 52dd27f..32d8449 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -11,7 +11,7 @@
 #
 # Thanks Matthew Kent for original agent and testing.
 
-import sys, re, pexpect
+import sys
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
@@ -25,37 +25,37 @@ BUILD_DATE=""
 ### CONSTANTS ###
 # From INTELCORPORATION-MULTI-FLEX-SERVER-BLADES-MIB.my that ships with
 # firmware updates
-STATUSES_OID=".1.3.6.1.4.1.343.2.19.1.2.10.202.1.1.6"
+STATUSES_OID = ".1.3.6.1.4.1.343.2.19.1.2.10.202.1.1.6"
 
 # Status constants returned as value from SNMP
-STATUS_UP=2
-STATUS_DOWN=0
+STATUS_UP = 2
+STATUS_DOWN = 0
 
 # Status constants to set as value to SNMP
-STATUS_SET_ON=2
-STATUS_SET_OFF=3
+STATUS_SET_ON = 2
+STATUS_SET_OFF = 3
 
 ### FUNCTIONS ###
 
-def get_power_status(conn,options):
-	(oid,status)=conn.get("%s.%s"%(STATUSES_OID,options["-n"]))
+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")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(STATUSES_OID,options["-n"]),(options["-o"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
+	conn.set("%s.%s"%(STATUSES_OID, options["-n"]), (options["-o"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
 
 def get_outlets_status(conn, options):
-	result={}
+	result = {}
 
-	res_blades=conn.walk(STATUSES_OID,30)
+	res_blades = conn.walk(STATUSES_OID, 30)
 
 	for x in res_blades:
-		port_num=x[0].split('.')[-1]
+		port_num = x[0].split('.')[-1]
 
-		port_alias=""
-		port_status=(x[1]==str(STATUS_UP) and "on" or "off")
+		port_alias = ""
+		port_status = (x[1]==str(STATUS_UP) and "on" or "off")
 
-		result[port_num]=(port_alias,port_status)
+		result[port_num] = (port_alias, port_status)
 
 	return result
 
@@ -73,7 +73,7 @@ def main():
 
 	snmp_define_defaults ()
 
-	options=check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for Intel Modular"
diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py
index 0243afd..354a037 100644
--- a/fence/agents/ipdu/fence_ipdu.py
+++ b/fence/agents/ipdu/fence_ipdu.py
@@ -5,7 +5,7 @@
 #   Firmware release OPDP_sIBM_v01.2_1
 #
 
-import sys, re, pexpect
+import sys
 sys.path.append("/usr/share/fence")
 from fencing import *
 from fencing_snmp import *
@@ -18,92 +18,92 @@ BUILD_DATE=""
 
 ### CONSTANTS ###
 # oid defining fence device
-OID_SYS_OBJECT_ID='.1.3.6.1.2.1.1.2.0'
+OID_SYS_OBJECT_ID = '.1.3.6.1.2.1.1.2.0'
 
 ### GLOBAL VARIABLES ###
 # Device - see IBM iPDU
-device=None
+device = None
 
 # Port ID
-port_id=None
+port_id = None
 # Switch ID
-switch_id=None
+switch_id = None
 
 # Classes describing Device params
 class IBMiPDU:
 	# iPDU
-	status_oid=      '.1.3.6.1.4.1.2.6.223.8.2.2.1.11.%d'
-	control_oid=     '.1.3.6.1.4.1.2.6.223.8.2.2.1.11.%d'
-	outlet_table_oid='.1.3.6.1.4.1.2.6.223.8.2.2.1.2'
-	ident_str="IBM iPDU"
-	state_on=1
-	state_off=0
-	turn_on=1
-	turn_off=0
-	has_switches=False
+	status_oid =       '.1.3.6.1.4.1.2.6.223.8.2.2.1.11.%d'
+	control_oid =      '.1.3.6.1.4.1.2.6.223.8.2.2.1.11.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.2.6.223.8.2.2.1.2'
+	ident_str = "IBM iPDU"
+	state_on = 1
+	state_off = 0
+	turn_on = 1
+	turn_off = 0
+	has_switches = False
 
 ### FUNCTIONS ###
-def ipdu_set_device(conn,options):
+def ipdu_set_device(conn, options):
 	global device
 
-	agents_dir={'.1.3.6.1.4.1.2.6.223':IBMiPDU,
+	agents_dir = {'.1.3.6.1.4.1.2.6.223':IBMiPDU,
 		    None:IBMiPDU}
 
 	# First resolve type of PDU device
-	pdu_type=conn.walk(OID_SYS_OBJECT_ID)
+	pdu_type = conn.walk(OID_SYS_OBJECT_ID)
 
 	if (not ((len(pdu_type)==1) and (agents_dir.has_key(pdu_type[0][1])))):
-		pdu_type=[[None,None]]
+		pdu_type = [[None, None]]
 
-	device=agents_dir[pdu_type[0][1]]
+	device = agents_dir[pdu_type[0][1]]
 
 	conn.log_command("Trying %s"%(device.ident_str))
 
-def ipdu_resolv_port_id(conn,options):
-	global port_id,switch_id,device
+def ipdu_resolv_port_id(conn, options):
+	global port_id, switch_id, device
 
 	if (device==None):
-		ipdu_set_device(conn,options)
+		ipdu_set_device(conn, options)
 
 	# Now we resolv port_id/switch_id
 	if ((options["-n"].isdigit()) and ((not device.has_switches) or (options["-s"].isdigit()))):
-		port_id=int(options["-n"])
+		port_id = int(options["-n"])
 
 		if (device.has_switches):
-			switch_id=int(options["-s"])
+			switch_id = int(options["-s"])
 	else:
-		table=conn.walk(device.outlet_table_oid,30)
+		table = conn.walk(device.outlet_table_oid, 30)
 
 		for x in table:
 			if (x[1].strip('"')==options["-n"]):
-				t=x[0].split('.')
+				t = x[0].split('.')
 				if (device.has_switches):
-					port_id=int(t[len(t)-1])
-					switch_id=int(t[len(t)-3])
+					port_id = int(t[len(t)-1])
+					switch_id = int(t[len(t)-3])
 				else:
-					port_id=int(t[len(t)-1])
+					port_id = int(t[len(t)-1])
 
 	if (port_id==None):
 		fail_usage("Can't find port with name %s!"%(options["-n"]))
 
-def get_power_status(conn,options):
-	global port_id,switch_id,device
+def get_power_status(conn, options):
+	global port_id, switch_id, device
 
 	if (port_id==None):
-		ipdu_resolv_port_id(conn,options)
+		ipdu_resolv_port_id(conn, options)
 
-	oid=((device.has_switches) and device.status_oid%(switch_id,port_id) or device.status_oid%(port_id))
+	oid = ((device.has_switches) and device.status_oid%(switch_id, port_id) or device.status_oid%(port_id))
 
-	(oid,status)=conn.get(oid)
+	(oid, status) = conn.get(oid)
 	return (status==str(device.state_on) and "on" or "off")
 
 def set_power_status(conn, options):
-	global port_id,switch_id,device
+	global port_id, switch_id, device
 
 	if (port_id==None):
-		ipdu_resolv_port_id(conn,options)
+		ipdu_resolv_port_id(conn, options)
 
-	oid=((device.has_switches) and device.control_oid%(switch_id,port_id) or device.control_oid%(port_id))
+	oid = ((device.has_switches) and device.control_oid%(switch_id, port_id) or device.control_oid%(port_id))
 
 	conn.set(oid,(options["-o"]=="on" and device.turn_on or device.turn_off))
 
@@ -111,23 +111,23 @@ def set_power_status(conn, options):
 def get_outlets_status(conn, options):
 	global device
 
-	result={}
+	result = {}
 
 	if (device==None):
-		ipdu_set_device(conn,options)
+		ipdu_set_device(conn, options)
 
-	res_ports=conn.walk(device.outlet_table_oid,30)
+	res_ports = conn.walk(device.outlet_table_oid, 30)
 
 	for x in res_ports:
-		t=x[0].split('.')
+		t = x[0].split('.')
 
-		port_num=((device.has_switches) and "%s:%s"%(t[len(t)-3],t[len(t)-1]) or "%s"%(t[len(t)-1]))
+		port_num = ((device.has_switches) and "%s:%s"%(t[len(t)-3], t[len(t)-1]) or "%s"%(t[len(t)-1]))
 
-                port_name=x[1].strip('"')
-                port_status=""
-                result[port_num]=(port_name,port_status)
+		port_name = x[1].strip('"')
+		port_status = ""
+		result[port_num] = (port_name, port_status)
 
-        return result
+	return result
 
 # Main agent method
 def main():
@@ -145,7 +145,7 @@ def main():
 	all_opt["switch"]["default"] = "1"
 	device = IBMiPDU
 
-	options = check_input(device_opt,process_input(device_opt))
+	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for iPDU over SNMP"
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 498d0d7..edbb2bf 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -7,7 +7,7 @@
 ## 
 #####
 
-import sys, re, pexpect
+import sys, re, pexpect, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
@@ -17,40 +17,40 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE=""
 #END_VERSION_GENERATION
 
-COMMAND_PROMPT_REG="\[PEXPECT\]$"
-COMMAND_PROMPT_NEW="[PEXPECT]"
+COMMAND_PROMPT_REG = "\[PEXPECT\]$"
+COMMAND_PROMPT_NEW = "[PEXPECT]"
 
 # Start comunicating after login. Prepare good environment.
 def start_communication(conn, options):
 	conn.send_eol ("PS1='"+COMMAND_PROMPT_NEW+"'")
-	res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],int(options["-Y"]))
-	if res==0:
+	res = conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG], int(options["-Y"]))
+	if res == 0:
 		#CSH stuff
 		conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
-		conn.log_expect(options, COMMAND_PROMPT_REG,int(options["-Y"]))
+		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
 	
 
 def get_power_status(conn, options):
 	try:
-		start_communication(conn,options)
+		start_communication(conn, options)
 		
 		conn.send_eol("ldm ls")
 		    
-		conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-Y"]))
+		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-Y"]))
 
-		result={}
+		result = {}
 
 		#This is status of mini finite automata. 0 = we didn't found NAME and STATE, 1 = we did
-		fa_status=0
+		fa_status = 0
 		
 		for line in conn.before.splitlines():
-			domain=re.search("^(\S+)\s+(\S+)\s+.*$",line)
+			domain = re.search("^(\S+)\s+(\S+)\s+.*$", line)
 
 			if (domain!=None):
 				if ((fa_status==0) and (domain.group(1)=="NAME") and (domain.group(2)=="STATE")):
-					fa_status=1
+					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"))
 
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
@@ -67,13 +67,13 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	try:
-		start_communication(conn,options)
+		start_communication(conn, options)
          	
-		cmd_line="ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
+		cmd_line = "ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
             	
 		conn.send_eol(cmd_line)
 		    
-		conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-g"]))
+		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["-g"]))
 		
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
@@ -113,7 +113,7 @@ root. Than prompt is $, so again, you must use parameter -c."
 	## Operate the fencing device
 	####
 	conn = fence_login(options)
-	result = fence_action(conn, options, set_power_status, get_power_status,get_power_status)
+	result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
 
 	##
 	## Logout from system
diff --git a/fence/agents/lib/XenAPI.py.py b/fence/agents/lib/XenAPI.py.py
index 4f27ef5..ce905fd 100644
--- a/fence/agents/lib/XenAPI.py.py
+++ b/fence/agents/lib/XenAPI.py.py
@@ -52,158 +52,158 @@ import socket
 translation = gettext.translation('xen-xm', fallback = True)
 
 class Failure(Exception):
-    def __init__(self, details):
-        try:
-            # If this failure is MESSAGE_PARAMETER_COUNT_MISMATCH, then we
-            # correct the return values here, to account for the fact that we
-            # transparently add the session handle as the first argument.
-            if details[0] == 'MESSAGE_PARAMETER_COUNT_MISMATCH':
-                details[2] = str(int(details[2]) - 1)
-                details[3] = str(int(details[3]) - 1)
-
-            self.details = details
-        except Exception, exn:
-            self.details = ['INTERNAL_ERROR', 'Client-side: ' + str(exn)]
-
-    def __str__(self):
-        try:
-            return translation.ugettext(self.details[0]) % self._details_map()
-        except TypeError, exn:
-            return "Message database broken: %s.\nXen-API failure: %s" % \
-                   (exn, str(self.details))
-        except Exception, exn:
-            import sys
-            print >>sys.stderr, exn
-            return "Xen-API failure: %s" % str(self.details)
-
-    def _details_map(self):
-        return dict([(str(i), self.details[i])
-                     for i in range(len(self.details))])
+	def __init__(self, details):
+		try:
+			# If this failure is MESSAGE_PARAMETER_COUNT_MISMATCH, then we
+			# correct the return values here, to account for the fact that we
+			# transparently add the session handle as the first argument.
+			if details[0] == 'MESSAGE_PARAMETER_COUNT_MISMATCH':
+				details[2] = str(int(details[2]) - 1)
+				details[3] = str(int(details[3]) - 1)
+
+			self.details = details
+		except Exception, exn:
+			self.details = ['INTERNAL_ERROR', 'Client-side: ' + str(exn)]
+
+	def __str__(self):
+		try:
+			return translation.ugettext(self.details[0]) % self._details_map()
+		except TypeError, exn:
+			return "Message database broken: %s.\nXen-API failure: %s" % \
+				   (exn, str(self.details))
+		except Exception, exn:
+			import sys
+			print >> sys.stderr, exn
+			return "Xen-API failure: %s" % str(self.details)
+
+	def _details_map(self):
+		return dict([(str(i), self.details[i])
+					 for i in range(len(self.details))])
 
 
 _RECONNECT_AND_RETRY = (lambda _ : ())
 
 class UDSHTTPConnection(httplib.HTTPConnection):
-    """ Stupid hacked up HTTPConnection subclass to allow HTTP over Unix domain
-    sockets. """
-    def connect(self):
-        path = self.host.replace("_", "/")
-        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-        self.sock.connect(path)
+	""" Stupid hacked up HTTPConnection subclass to allow HTTP over Unix domain
+	sockets. """
+	def connect(self):
+		path = self.host.replace("_", "/")
+		self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+		self.sock.connect(path)
 
 class UDSHTTP(httplib.HTTP):
-    _connection_class = UDSHTTPConnection
+	_connection_class = UDSHTTPConnection
 
 class UDSTransport(xmlrpclib.Transport):
-    def make_connection(self, host):
-        return UDSHTTP(host)
+	def make_connection(self, host):
+		return UDSHTTP(host)
 
 class Session(xmlrpclib.ServerProxy):
-    """A server proxy and session manager for communicating with Xend using
-    the Xen-API.
-
-    Example:
-
-    session = Session('http://localhost:9363/')
-    session.login_with_password('me', 'mypassword')
-    session.xenapi.VM.start(vm_uuid)
-    session.xenapi.session.logout()
-
-    For now, this class also supports the legacy XML-RPC API, using
-    session.xend.domain('Domain-0') and similar.  This support will disappear
-    once there is a working Xen-API replacement for every call in the legacy
-    API.
-    """
-
-    def __init__(self, uri, transport=None, encoding=None, verbose=0,
-                 allow_none=1):
-        xmlrpclib.ServerProxy.__init__(self, uri, transport, encoding,
-                                       verbose, allow_none)
-        self._session = None
-        self.last_login_method = None
-        self.last_login_params = None
-
-
-    def xenapi_request(self, methodname, params):
-        if methodname.startswith('login'):
-            self._login(methodname, params)
-            return None
-        else:
-            retry_count = 0
-            while retry_count < 3:
-                full_params = (self._session,) + params
-                result = _parse_result(getattr(self, methodname)(*full_params))
-                if result == _RECONNECT_AND_RETRY:
-                    retry_count += 1
-                    if self.last_login_method:
-                        self._login(self.last_login_method,
-                                    self.last_login_params)
-                    else:
-                        raise xmlrpclib.Fault(401, 'You must log in')
-                else:
-                    return result
-            raise xmlrpclib.Fault(
-                500, 'Tried 3 times to get a valid session, but failed')
-
-
-    def _login(self, method, params):
-        result = _parse_result(getattr(self, 'session.%s' % method)(*params))
-        if result == _RECONNECT_AND_RETRY:
-            raise xmlrpclib.Fault(
-                500, 'Received SESSION_INVALID when logging in')
-        self._session = result
-        self.last_login_method = method
-        self.last_login_params = params
-
-
-    def __getattr__(self, name):
-        if name == 'xenapi':
-            return _Dispatcher(self.xenapi_request, None)
-        elif name.startswith('login'):
-            return lambda *params: self._login(name, params)
-        else:
-            return xmlrpclib.ServerProxy.__getattr__(self, name)
+	"""A server proxy and session manager for communicating with Xend using
+	the Xen-API.
+
+	Example:
+
+	session = Session('http://localhost:9363/')
+	session.login_with_password('me', 'mypassword')
+	session.xenapi.VM.start(vm_uuid)
+	session.xenapi.session.logout()
+
+	For now, this class also supports the legacy XML-RPC API, using
+	session.xend.domain('Domain-0') and similar.  This support will disappear
+	once there is a working Xen-API replacement for every call in the legacy
+	API.
+	"""
+
+	def __init__(self, uri, transport=None, encoding=None, verbose=0,
+				 allow_none=1):
+		xmlrpclib.ServerProxy.__init__(self, uri, transport, encoding,
+									   verbose, allow_none)
+		self._session = None
+		self.last_login_method = None
+		self.last_login_params = None
+
+
+	def xenapi_request(self, methodname, params):
+		if methodname.startswith('login'):
+			self._login(methodname, params)
+			return None
+		else:
+			retry_count = 0
+			while retry_count < 3:
+				full_params = (self._session,) + params
+				result = _parse_result(getattr(self, methodname)(*full_params))
+				if result == _RECONNECT_AND_RETRY:
+					retry_count += 1
+					if self.last_login_method:
+						self._login(self.last_login_method,
+									self.last_login_params)
+					else:
+						raise xmlrpclib.Fault(401, 'You must log in')
+				else:
+					return result
+			raise xmlrpclib.Fault(
+				500, 'Tried 3 times to get a valid session, but failed')
+
+
+	def _login(self, method, params):
+		result = _parse_result(getattr(self, 'session.%s' % method)(*params))
+		if result == _RECONNECT_AND_RETRY:
+			raise xmlrpclib.Fault(
+				500, 'Received SESSION_INVALID when logging in')
+		self._session = result
+		self.last_login_method = method
+		self.last_login_params = params
+
+
+	def __getattr__(self, name):
+		if name == 'xenapi':
+			return _Dispatcher(self.xenapi_request, None)
+		elif name.startswith('login'):
+			return lambda *params: self._login(name, params)
+		else:
+			return xmlrpclib.ServerProxy.__getattr__(self, name)
 
 def xapi_local():
-    return Session("http://_var_xapi_xapi/", transport=UDSTransport())
+	return Session("http://_var_xapi_xapi/", transport=UDSTransport())
 
 def _parse_result(result):
-    if type(result) != dict or 'Status' not in result:
-        raise xmlrpclib.Fault(500, 'Missing Status in response from server' + result)
-    if result['Status'] == 'Success':
-        if 'Value' in result:
-            return result['Value']
-        else:
-            raise xmlrpclib.Fault(500,
-                                  'Missing Value in response from server')
-    else:
-        if 'ErrorDescription' in result:
-            if result['ErrorDescription'][0] == 'SESSION_INVALID':
-                return _RECONNECT_AND_RETRY
-            else:
-                raise Failure(result['ErrorDescription'])
-        else:
-            raise xmlrpclib.Fault(
-                500, 'Missing ErrorDescription in response from server')
+	if type(result) != dict or 'Status' not in result:
+		raise xmlrpclib.Fault(500, 'Missing Status in response from server' + result)
+	if result['Status'] == 'Success':
+		if 'Value' in result:
+			return result['Value']
+		else:
+			raise xmlrpclib.Fault(500,
+								  'Missing Value in response from server')
+	else:
+		if 'ErrorDescription' in result:
+			if result['ErrorDescription'][0] == 'SESSION_INVALID':
+				return _RECONNECT_AND_RETRY
+			else:
+				raise Failure(result['ErrorDescription'])
+		else:
+			raise xmlrpclib.Fault(
+				500, 'Missing ErrorDescription in response from server')
 
 
 # Based upon _Method from xmlrpclib.
 class _Dispatcher:
-    def __init__(self, send, name):
-        self.__send = send
-        self.__name = name
-
-    def __repr__(self):
-        if self.__name:
-            return '<XenAPI._Dispatcher for %s>' % self.__name
-        else:
-            return '<XenAPI._Dispatcher>'
-
-    def __getattr__(self, name):
-        if self.__name is None:
-            return _Dispatcher(self.__send, name)
-        else:
-            return _Dispatcher(self.__send, "%s.%s" % (self.__name, name))
-
-    def __call__(self, *args):
-        return self.__send(self.__name, args)
+	def __init__(self, send, name):
+		self.__send = send
+		self.__name = name
+
+	def __repr__(self):
+		if self.__name:
+			return '<XenAPI._Dispatcher for %s>' % self.__name
+		else:
+			return '<XenAPI._Dispatcher>'
+
+	def __getattr__(self, name):
+		if self.__name is None:
+			return _Dispatcher(self.__send, name)
+		else:
+			return _Dispatcher(self.__send, "%s.%s" % (self.__name, name))
+
+	def __call__(self, *args):
+		return self.__send(self.__name, args)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index c1851d1..ea0ca09 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -477,7 +477,7 @@ def metadata(avail_opt, options, docs):
 	print "<?xml version=\"1.0\" ?>"
 	print "<resource-agent name=\"" + os.path.basename(sys.argv[0]) + "\" shortdesc=\"" + docs["shortdesc"] + "\" >"
 	if "symlink" in docs:
-		for (symlink,desc) in docs["symlink"]:
+		for (symlink, desc) in docs["symlink"]:
 			print "<symlink name=\"" + symlink + "\" shortdesc=\"" + desc + "\"/>"
 	print "<longdesc>" + docs["longdesc"] + "</longdesc>"
 	if docs.has_key("vendorurl"):
@@ -816,7 +816,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 i 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 +847,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 i 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:
@@ -869,13 +869,13 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 	return result
 
 def fence_login(options):
-	force_ipvx=""
+	force_ipvx = ""
 
 	if (options.has_key("-6")):
-		force_ipvx="-6 "
+		force_ipvx = "-6 "
 
 	if (options.has_key("-4")):
-		force_ipvx="-4 "
+		force_ipvx = "-4 "
 
 	if (options.has_key("eol") == False):
 		options["eol"] = "\r\n"
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 4f55795..f478c53 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -2,7 +2,7 @@
 
 # For example of use please see fence_cisco_mds
 
-import re,pexpect
+import re, pexpect
 from fencing import *
 
 ## do not add code here.
@@ -14,81 +14,81 @@ BUILD_DATE = ""
 
 # Fix for RHBZ#527844
 def snmp_define_defaults ():
-	all_opt["udpport"]["default"]="161"
-	all_opt["ipport"]["default"]="161"
+	all_opt["udpport"]["default"] = "161"
+	all_opt["ipport"]["default"] = "161"
 
 class FencingSnmp:
-	def __init__(self,options):
-		self.options=options
+	def __init__(self, options):
+		self.options = options
 
 	# Log message if user set verbose option
 	def log_command(self, message):
 		if self.options["log"] >= LOG_MODE_VERBOSE:
 			self.options["debug_fh"].write(message+"\n")
 
-	def quote_for_run(self,str):
-		return ''.join(map(lambda x:x==r"'" and "'\\''" or x,str))
+	def quote_for_run(self, str):
+		return ''.join(map(lambda x:x==r"'" and "'\\''" or x, str))
 
 	def complete_missed_params(self):
-		mapping=[
+		mapping = [
 			[['P','p','!E'],'self.options["-E"]="authPriv"'],
 			[['!d','c','!l','!P','!p'],'self.options["-d"]="2c"']
 			]
 
 		for val in mapping:
-			e=val[0]
+			e = val[0]
 
-			res=True
+			res = True
 
 			for item in e:
 				if ((item[0]=='!') and (self.options.has_key("-"+item[1]))):
-					res=False
+					res = False
 					break
 
 				if ((item[0]!='!') and (not self.options.has_key("-"+item[0]))):
-					res=False
+					res = False
 					break
 
 			if res:
 				exec(val[1])
 
-	def prepare_cmd(self,command):
-		cmd="@SNMPBIN@/%s -m '' -Oeqn "%(command)
+	def prepare_cmd(self, command):
+		cmd = "@SNMPBIN@/%s -m '' -Oeqn "% (command)
 
 		self.complete_missed_params()
 
 		#mapping from our option to snmpcmd option
-		mapping=(('d','v'),('c','c'))
+		mapping = (('d', 'v'),('c', 'c'))
 
 		for item in mapping:
 			if (self.options.has_key("-"+item[0])):
-				cmd+=" -%s '%s'"%(item[1],self.quote_for_run(self.options["-"+item[0]]))
+				cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["-" + item[0]]))
 
 		# Some options make sense only for v3 (and for v1/2c can cause "problems")
 		if (self.options.has_key("-d")) and (self.options["-d"] == "3"):
 			# Mapping from our options to snmpcmd options for v3
-			mapping_v3=(('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','u'))
+			mapping_v3 = (('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','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]]))
+					cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["-" + item[0]]))
 
-		force_ipvx=""
+		force_ipvx = ""
 
 		if (self.options.has_key("-6")):
-			force_ipvx="udp6:"
+			force_ipvx = "udp6:"
 
 		if (self.options.has_key("-4")):
-			force_ipvx="udp:"
+			force_ipvx = "udp:"
 
-		cmd+=" '%s%s%s'"%(force_ipvx, self.quote_for_run(self.options["-a"]),
+		cmd += " '%s%s%s'"% (force_ipvx, self.quote_for_run(self.options["-a"]),
 				self.options.has_key("-u") and self.quote_for_run(":" + str (self.options["-u"])) or "")
 		return cmd
 
-	def run_command(self,command,additional_timemout=0):
+	def run_command(self, command, additional_timemout=0):
 		try:
 			self.log_command(command)
 
-			(res_output,res_code)=pexpect.run(command,int(self.options["-Y"])+int(self.options["-y"])+additional_timemout,True)
+			(res_output, res_code) = pexpect.run(command, int(self.options["-Y"]) + int(self.options["-y"]) + additional_timemout, True)
 
 			if (res_code==None):
 				fail(EC_TIMED_OUT)
@@ -96,36 +96,36 @@ class FencingSnmp:
 			self.log_command(res_output)
 
 			if (res_code!=0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
-				fail_usage("Returned %d: %s"%(res_code,res_output))
+				fail_usage("Returned %d: %s"% (res_code, res_output))
 		except pexpect.ExceptionPexpect:
 			fail_usage("Cannot run command %s"%(command))
 
 		return res_output
 
-	def get(self,oid,additional_timemout=0):
-		cmd="%s '%s'"%(self.prepare_cmd("snmpget"),self.quote_for_run(oid))
+	def get(self, oid, additional_timemout=0):
+		cmd = "%s '%s'"% (self.prepare_cmd("snmpget"), self.quote_for_run(oid))
 
-		output=self.run_command(cmd,additional_timemout).splitlines()
+		output = self.run_command(cmd, additional_timemout).splitlines()
 
-		return output[len(output)-1].split(None,1)
+		return output[len(output)-1].split(None, 1)
 
-	def set(self,oid,value,additional_timemout=0):
-		mapping=((int,'i'),(str,'s'))
+	def set(self, oid, value, additional_timemout=0):
+		mapping = ((int, 'i'), (str, 's'))
 
-		type=''
+		type = ''
 
 		for item in mapping:
-			if (isinstance(value,item[0])):
-				type=item[1]
+			if (isinstance(value, item[0])):
+				type = item[1]
 				break
 
-		cmd="%s '%s' %s '%s'"%(self.prepare_cmd("snmpset"),self.quote_for_run(oid),type,self.quote_for_run(str(value)))
+		cmd = "%s '%s' %s '%s'"% (self.prepare_cmd("snmpset"), self.quote_for_run(oid), type, self.quote_for_run(str(value)))
 
-		self.run_command(cmd,additional_timemout)
+		self.run_command(cmd, additional_timemout)
 
-	def walk(self,oid,additional_timemout=0):
-		cmd="%s '%s'"%(self.prepare_cmd("snmpwalk"),self.quote_for_run(oid))
+	def walk(self, oid, additional_timemout=0):
+		cmd = "%s '%s'"% (self.prepare_cmd("snmpwalk"), self.quote_for_run(oid))
 
-		output=self.run_command(cmd,additional_timemout).splitlines()
+		output = self.run_command(cmd, additional_timemout).splitlines()
 
-		return map(lambda x:x.split(None,1),filter(lambda y:len(y)>0 and y[0]=='.',output))
+		return map(lambda x:x.split(None, 1), filter(lambda y:len(y)>0 and y[0]=='.', output))
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index a5d4195..df4f1ef 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -150,8 +150,8 @@ def main():
 	if 0 == options.has_key("-s"):
 		fail_usage("Failed: You have to enter name of managed system")
 
-        if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")):
-                fail_usage("Failed: You have to enter name of the partition")
+	if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")):
+		fail_usage("Failed: You have to enter name of the partition")
 
 	if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"):
 		fail_usage("Failed: You have to enter valid version number: 3 or 4")
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index 9bb9581..c6f16ff 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, socket
+import sys, re
 import pycurl, StringIO
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
@@ -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
@@ -29,7 +29,7 @@ def get_power_status(conn, options):
 		# Unable to obtain ID needed to access virtual machine
 		fail(EC_STATUS)
 
-	options["id"] = result.group(2);
+	options["id"] = result.group(2)
 	
 	re_status.search(res)
 	result = re_status.search(res)
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 51781f9..1ed71cf 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -8,7 +8,7 @@
 ## +-----------------+---------------------------+
 #####
 
-import sys, re, pexpect
+import sys, re, pexpect, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
@@ -50,8 +50,8 @@ def set_power_status(conn, options):
 		'off' : "offline"
 	}[options["-o"]]
 
-        try:
-        	conn.send_eol("set port " + options["-n"] + " state " + action)
+	try:
+		conn.send_eol("set port " + options["-n"] + " state " + action)
 		conn.log_expect(options, options["-c"], int(options["-g"]))
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index ebf6666..cb33a56 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -30,28 +30,28 @@ def get_outlets_status(conn, options):
 	except pexpect.TIMEOUT:
 		fail(EC_TIMED_OUT)
 
-	result={}
+	result = {}
 
         #This is status of mini finite automata. 0 = we didn't found Id and Name, 1 = we did
-        fa_status=0
+	fa_status = 0
 
-        for line in conn.before.splitlines():
-	        domain=re.search("^\s*(\S+)\s+(\S+)\s+(\S+).*$",line)
+	for line in conn.before.splitlines():
+		domain = re.search("^\s*(\S+)\s+(\S+)\s+(\S+).*$", line)
 
-                if (domain!=None):
+		if (domain!=None):
 			if ((fa_status==0) and (domain.group(1).lower()=="id") and (domain.group(2).lower()=="name")):
-				fa_status=1
+				fa_status = 1
 			elif (fa_status==1):
-				result[domain.group(2)]=("",(domain.group(3).lower() in ["running","blocked","idle","no state","paused"] and "on" or "off"))
+				result[domain.group(2)] = ("", (domain.group(3).lower() in ["running", "blocked", "idle", "no state", "paused"] and "on" or "off"))
 	return result
 
 def get_power_status(conn, options):
-	outlets=get_outlets_status(conn,options)
+	outlets = get_outlets_status(conn, options)
 
-        if (not (options["-n"] in outlets)):
-                fail_usage("Failed: You have to enter existing name of virtual machine!")
-        else:
-                return outlets[options["-n"]][1]
+	if (not (options["-n"] in outlets)):
+		fail_usage("Failed: You have to enter existing name of virtual machine!")
+	else:
+		return outlets[options["-n"]][1]
 
 def set_power_status(conn, options):
 	if options.has_key("-d"):
@@ -63,7 +63,7 @@ def set_power_status(conn, options):
 		conn.sendline(prefix + "virsh %s "%(options["-o"] == "on" and "start" or "destroy")+options["-n"])
 
 		conn.log_expect(options, options["-c"], int(options["-g"]))
-                time.sleep(1)
+		time.sleep(1)
 
 	except pexpect.EOF:
 		fail(EC_CONNECTION_LOST)
@@ -82,7 +82,7 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash --noprofile --norc\"'"
+	options["ssh_options"] = "-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash --noprofile --norc\"'"
 
 	docs = { }
 	docs["shortdesc"] = "Fence agent for virsh"
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 885a876..2ec2c3c 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -34,59 +34,59 @@ BUILD_DATE=""
 
 ### CONSTANTS ####
 # VMware type is ESX/ESXi/VC
-VMWARE_TYPE_ESX=0
+VMWARE_TYPE_ESX = 0
 # VMware type is Server 1.x
-VMWARE_TYPE_SERVER1=1
+VMWARE_TYPE_SERVER1 = 1
 # VMware type is Server 2.x and/or ESX 3.5 up2, ESXi 3.5 up2, VC 2.5 up2
-VMWARE_TYPE_SERVER2=2
+VMWARE_TYPE_SERVER2 = 2
 
 # Minimum required version of vmrun command
-VMRUN_MINIMUM_REQUIRED_VERSION=2
+VMRUN_MINIMUM_REQUIRED_VERSION = 2
 
 # Default path to vmhelper command
-VMHELPER_COMMAND="fence_vmware_helper"
+VMHELPER_COMMAND = "fence_vmware_helper"
 # Default path to vmrun command
-VMRUN_COMMAND="/usr/bin/vmrun"
+VMRUN_COMMAND = "/usr/bin/vmrun"
 # Default type of vmware
-VMWARE_DEFAULT_TYPE="esx"
+VMWARE_DEFAULT_TYPE = "esx"
 
 #### GLOBAL VARIABLES ####
 # Internal type. One of VMWARE_TYPE_, set by #vmware_check_vmware_type
-vmware_internal_type=VMWARE_TYPE_ESX
+vmware_internal_type = VMWARE_TYPE_ESX
 
 # If ESX is disconnected, say, that VM is off (don't return previous state)
-vmware_disconnected_hack=False
+vmware_disconnected_hack = False
 
 ### FUNCTIONS ####
 
 #Split string in simplified DSV format to array of items
 def dsv_split(dsv_str):
-	delimiter_c=':'
-	escape_c='\\'
+	delimiter_c = ':'
+	escape_c = '\\'
 
-	res=[]
-	status=0
-	tmp_str=""
+	res = []
+	status = 0
+	tmp_str = ""
 
 	for x in dsv_str:
 		if (status==0):
 			if (x==delimiter_c):
 				res.append(tmp_str)
-				tmp_str=""
+				tmp_str = ""
 			elif (x==escape_c):
-				status=1
+				status = 1
 			else:
-				tmp_str+=x
+				tmp_str += x
 		elif (status==1):
 			if (x==delimiter_c):
-				tmp_str+=delimiter_c
+				tmp_str += delimiter_c
 			elif (x==escape_c):
-				tmp_str+=escape_c
+				tmp_str += escape_c
 			else:
-				tmp_str+=escape_c+x
-			status=0
+				tmp_str += escape_c+x
+			status = 0
 
-	if (tmp_str!=""):
+	if (tmp_str != ""):
 		res.append(tmp_str)
 
 	return res
@@ -94,43 +94,43 @@ def dsv_split(dsv_str):
 # Quote string for proper existence in quoted string used for pexpect.run function
 # Ex. test'this will return test'\''this. So pexpect run will really pass ' to argument
 def quote_for_run(str):
-	dstr=''
+	dstr = ''
 
 	for c in str:
-		if c==r"'":
-			dstr+="'\\''"
+		if c == r"'":
+			dstr += "'\\''"
 		else:
-			dstr+=c
+			dstr += c
 
 	return dstr
 
 # Return string with command and additional parameters (something like vmrun -h 'host'
-def vmware_prepare_command(options,add_login_params,additional_params):
-	res=options["-e"]
+def vmware_prepare_command(options, add_login_params, additional_params):
+	res = options["-e"]
 
 	if (add_login_params):
 		if (vmware_internal_type==VMWARE_TYPE_ESX):
-			res+=" --server '%s' --username '%s' --password '%s' "%(quote_for_run(options["-a"]),
+			res += " --server '%s' --username '%s' --password '%s' "% (quote_for_run(options["-a"]),
 										quote_for_run(options["-l"]),
 										quote_for_run(options["-p"]))
 		elif (vmware_internal_type==VMWARE_TYPE_SERVER2):
-			res+=" -h 'https://%s/sdk' -u '%s' -p '%s' -T server "%(quote_for_run(options["-a"]),
+			res += " -h 'https://%s/sdk' -u '%s' -p '%s' -T server "% (quote_for_run(options["-a"]),
 										quote_for_run(options["-l"]),
 										quote_for_run(options["-p"]))
 		elif (vmware_internal_type==VMWARE_TYPE_SERVER1):
-			host_name_array=options["-a"].split(':')
+			host_name_array = options["-a"].split(':')
 
-			res+=" -h '%s' -u '%s' -p '%s' -T server1 "%(quote_for_run(host_name_array[0]),
+			res += " -h '%s' -u '%s' -p '%s' -T server1 "% (quote_for_run(host_name_array[0]),
 								     quote_for_run(options["-l"]),
 								     quote_for_run(options["-p"]))
 			if (len(host_name_array)>1):
-				res+="-P '%s' "%(quote_for_run(host_name_array[1]))
+				res += "-P '%s' "% (quote_for_run(host_name_array[1]))
 
 	if ((options.has_key("-s")) and (vmware_internal_type==VMWARE_TYPE_ESX)):
-		res+="--datacenter '%s' "%(quote_for_run(options["-s"]))
+		res += "--datacenter '%s' "% (quote_for_run(options["-s"]))
 
-	if (additional_params!=""):
-		res+=additional_params
+	if (additional_params != ""):
+		res += additional_params
 
 	return res
 
@@ -142,84 +142,84 @@ def vmware_log(options, message):
 # Run command with timeout and parameters. Internaly uses vmware_prepare_command. Returns string
 # with output from vmrun command. If something fails (command not found, exit code is not 0), fail_usage
 # function is called (and never return).
-def vmware_run_command(options,add_login_params,additional_params,additional_timeout):
-	command=vmware_prepare_command(options,add_login_params,additional_params)
+def vmware_run_command(options, add_login_params, additional_params, additional_timeout):
+	command = vmware_prepare_command(options, add_login_params, additional_params)
 
 	try:
-		vmware_log(options,command)
+		vmware_log(options, command)
 
-		(res_output,res_code)=pexpect.run(command,int(options["-Y"])+int(options["-y"])+additional_timeout,True)
+		(res_output, res_code) = pexpect.run(command, int(options["-Y"])+int(options["-y"])+additional_timeout, True)
 
 		if (res_code==None):
 			fail(EC_TIMED_OUT)
 		if ((res_code!=0) and (add_login_params)):
-			vmware_log(options,res_output)
-			fail_usage("%s returned %s"%(options["-e"],res_output))
+			vmware_log(options, res_output)
+			fail_usage("%s returned %s"% (options["-e"], res_output))
 		else:
-			vmware_log(options,res_output)
+			vmware_log(options, res_output)
 
 	except pexpect.ExceptionPexpect:
-		fail_usage("Cannot run command %s"%(options["-e"]))
+		fail_usage("Cannot run command %s"% (options["-e"]))
 
 	return res_output
 
 # Get outlet list with status as hash table. If you will use add_vm_name, only VM with vmname is
 # returned. This is used in get_status function
 def vmware_get_outlets_vi(conn, options, add_vm_name):
-	outlets={}
+	outlets = {}
 
 	if (add_vm_name):
-		all_machines=vmware_run_command(options,True,("--operation status --vmname '%s'"%(quote_for_run(options["-n"]))),0)
+		all_machines = vmware_run_command(options, True, ("--operation status --vmname '%s'"% (quote_for_run(options["-n"]))), 0)
 	else:
-		all_machines=vmware_run_command(options,True,"--operation list",int(options["-g"]))
+		all_machines = vmware_run_command(options, True, "--operation list", int(options["-g"]))
 
-	all_machines_array=all_machines.splitlines()
+	all_machines_array = all_machines.splitlines()
 
 	for machine in all_machines_array:
-		machine_array=dsv_split(machine)
-		if (len(machine_array)==4):
+		machine_array = dsv_split(machine)
+		if (len(machine_array) == 4):
 			if (machine_array[0] in outlets):
 				fail_usage("Failed. More machines with same name %s found!"%(machine_array[0]))
 
 			if (vmware_disconnected_hack):
-				outlets[machine_array[0]]=("",(
+				outlets[machine_array[0]] = ("", (
 						((machine_array[2].lower() in ["poweredon"]) and
 						 (machine_array[3].lower()=="connected"))
 						and "on" or "off"))
 			else:
-				outlets[machine_array[0]]=("",((machine_array[2].lower() in ["poweredon"]) and "on" or "off"))
+				outlets[machine_array[0]] = ("", ((machine_array[2].lower() in ["poweredon"]) and "on" or "off"))
 	return outlets
 
 # Get outlet list with status as hash table.
-def vmware_get_outlets_vix(conn,options):
-	outlets={}
+def vmware_get_outlets_vix(conn, options):
+	outlets = {}
 
-	running_machines=vmware_run_command(options,True,"list",0)
-	running_machines_array=running_machines.splitlines()[1:]
+	running_machines = vmware_run_command(options, True, "list", 0)
+	running_machines_array = running_machines.splitlines()[1:]
 
 	if (vmware_internal_type==VMWARE_TYPE_SERVER2):
-		all_machines=vmware_run_command(options,True,"listRegisteredVM",0)
-		all_machines_array=all_machines.splitlines()[1:]
+		all_machines = vmware_run_command(options, True, "listRegisteredVM", 0)
+		all_machines_array = all_machines.splitlines()[1:]
 	elif (vmware_internal_type==VMWARE_TYPE_SERVER1):
-		all_machines_array=running_machines_array
+		all_machines_array = running_machines_array
 
 	for machine in all_machines_array:
 		if (machine!=""):
-			outlets[machine]=("",((machine in running_machines_array) and "on" or "off"))
+			outlets[machine] = ("", ((machine in running_machines_array) and "on" or "off"))
 
 	return outlets
 
 def get_outlets_status(conn, options):
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
-		return vmware_get_outlets_vi(conn,options,False)
+		return vmware_get_outlets_vi(conn, options, False)
 	if ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
-		return vmware_get_outlets_vix(conn,options)
+		return vmware_get_outlets_vix(conn, options)
 
-def get_power_status(conn,options):
+def get_power_status(conn, options):
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
-		outlets=vmware_get_outlets_vi(conn,options,True)
+		outlets = vmware_get_outlets_vi(conn, options, True)
 	else:
-		outlets=get_outlets_status(conn,options)
+		outlets = get_outlets_status(conn, options)
 
 	if ((vmware_internal_type==VMWARE_TYPE_SERVER2) or (vmware_internal_type==VMWARE_TYPE_ESX)):
 		if (not (options["-n"] in outlets)):
@@ -231,25 +231,25 @@ def get_power_status(conn,options):
 
 def set_power_status(conn, options):
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
-		additional_params="--operation %s --vmname '%s'"%((options["-o"]=="on" and "on" or "off"),quote_for_run(options["-n"]))
+		additional_params = "--operation %s --vmname '%s'"% ((options["-o"]=="on" and "on" or "off"), quote_for_run(options["-n"]))
 	elif ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
-		additional_params="%s '%s'"%((options["-o"]=="on" and "start" or "stop"),quote_for_run(options["-n"]))
+		additional_params = "%s '%s'"% ((options["-o"]=="on" and "start" or "stop"), quote_for_run(options["-n"]))
 		if (options["-o"]=="off"):
-			additional_params+=" hard"
+			additional_params += " hard"
 
-	vmware_run_command(options,True,additional_params,int(options["-g"]))
+	vmware_run_command(options, True, additional_params, int(options["-g"]))
 
 # Returns True, if user uses supported vmrun version (currently >=2.0.0) otherwise False.
 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())
+	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
 
-	version_array=version_re.group(1).split(".")
+	version_array = version_re.group(1).split(".")
 
 	try:
-		if (int(version_array[0])<VMRUN_MINIMUM_REQUIRED_VERSION):
+		if (int(version_array[0]) < VMRUN_MINIMUM_REQUIRED_VERSION):
 			return False
 	except Exception:
 		return False
@@ -261,20 +261,20 @@ def vmware_is_supported_vmrun_version(options):
 def vmware_check_vmware_type(options):
 	global vmware_internal_type
 
-	options["-d"]=options["-d"].lower()
+	options["-d"] = options["-d"].lower()
 
 	if (options["-d"]=="esx"):
-		vmware_internal_type=VMWARE_TYPE_ESX
+		vmware_internal_type = VMWARE_TYPE_ESX
 		if (not options.has_key("-e")):
-			options["-e"]=VMHELPER_COMMAND
+			options["-e"] = VMHELPER_COMMAND
 	elif (options["-d"]=="server2"):
-		vmware_internal_type=VMWARE_TYPE_SERVER2
+		vmware_internal_type = VMWARE_TYPE_SERVER2
 		if (not options.has_key("-e")):
-			options["-e"]=VMRUN_COMMAND
+			options["-e"] = VMRUN_COMMAND
 	elif (options["-d"]=="server1"):
-		vmware_internal_type=VMWARE_TYPE_SERVER1
+		vmware_internal_type = VMWARE_TYPE_SERVER1
 		if (not options.has_key("-e")):
-			options["-e"]=VMRUN_COMMAND
+			options["-e"] = VMRUN_COMMAND
 	else:
 		fail_usage("vmware_type can be esx,server2 or server1!")
 
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 21dad66..41da8c0 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -1,10 +1,9 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 
 from suds.client import Client
-from suds import WebFault
 from suds.sudsobject import Property
 from fencing import *
 
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 9aa9959..555fb98 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -62,7 +62,6 @@ def get_power_status(conn, options):
 					outlets[plug_line[0]] = (plug_line[name_index], plug_line[status_index])
 		elif (plug_section == 1):
 			plug_section = 2
-			pass
 		elif (line.upper().startswith("PLUG")):
 			plug_section = 1
 			plug_header = [x.strip().lower() for x in line.split("|")]
diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py
index 017908f..f583ea5 100644
--- a/fence/agents/xenapi/fence_xenapi.py
+++ b/fence/agents/xenapi/fence_xenapi.py
@@ -54,12 +54,13 @@ def get_power_fn(session, options):
 		# Get a reference to the vm specified in the UUID or vm_name/port parameter
 		vm = return_vm_reference(session, options)
 		# Query the VM for its' associated parameters
-		record = session.xenapi.VM.get_record(vm);
+		record = session.xenapi.VM.get_record(vm)
 		# Check that we are not trying to manipulate a template or a control
 		# domain as they show up as VM's with specific properties.
 		if not(record["is_a_template"]) and not(record["is_control_domain"]):
 			status = record["power_state"]
-			if verbose: print "UUID:", record["uuid"], "NAME:", record["name_label"], "POWER STATUS:", record["power_state"]
+			if verbose:
+				print "UUID:", record["uuid"], "NAME:", record["name_label"], "POWER STATUS:", record["power_state"]
 			# Note that the VM can be in the following states (from the XenAPI document)
 			# Halted: VM is offline and not using any resources.
 			# Paused: All resources have been allocated but the VM itself is paused and its vCPUs are not running
@@ -100,7 +101,7 @@ def set_power_fn(session, options):
 				# Force reboot the VM
 				session.xenapi.VM.hard_reboot(vm)
 	except Exception, exn:
-		print str(exn);
+		print str(exn)
 
 # Function to populate an array of virtual machines and their status
 def get_outlet_list(session, options):
@@ -115,7 +116,7 @@ def get_outlet_list(session, options):
 		vms = session.xenapi.VM.get_all()
 		for vm in vms:
 			# Query the VM for its' associated parameters
-			record = session.xenapi.VM.get_record(vm);
+			record = session.xenapi.VM.get_record(vm)
 			# Check that we are not trying to manipulate a template or a control
 			# domain as they show up as VM's with specific properties.
 			if not(record["is_a_template"]) and not(record["is_control_domain"]):
@@ -123,9 +124,10 @@ def get_outlet_list(session, options):
 				uuid = record["uuid"]
 				status = record["power_state"]
 				result[uuid] = (name, status)
-				if verbose: print "UUID:", record["uuid"], "NAME:", name, "POWER STATUS:", record["power_state"]
+				if verbose:
+					print "UUID:", record["uuid"], "NAME:", name, "POWER STATUS:", record["power_state"]
 	except Exception, exn:
-		print str(exn);
+		print str(exn)
 
 	return result
 
@@ -137,18 +139,18 @@ def connect_and_login(options):
 
 	try:
 		# Create the XML RPC session to the specified URL.
-		session = XenAPI.Session(url);
+		session = XenAPI.Session(url)
 		# Login using the supplied credentials.
-		session.xenapi.login_with_password(username, password);
+		session.xenapi.login_with_password(username, password)
 	except Exception, exn:
-		print str(exn);
+		print str(exn)
 		# http://sources.redhat.com/cluster/wiki/FenceAgentAPI says that for no connectivity
 		# the exit value should be 1. It doesn't say anything about failed logins, so 
 		# until I hear otherwise it is best to keep this exit the same to make sure that
 		# anything calling this script (that uses the same information in the web page
 		# above) knows that this is an error condition, not a msg signifying a down port.
-		sys.exit(EC_BAD_SESSION); 
-	return session;
+		sys.exit(EC_BAD_SESSION) 
+	return session
 
 # return a reference to the VM by either using the UUID or the vm_name/port. If the UUID is set then
 # this is tried first as this is the only properly unique identifier.
@@ -167,8 +169,9 @@ def return_vm_reference(session, options):
 		# need to catch and re-raise the exception produced by get_by_uuid.
 		try:
 			return session.xenapi.VM.get_by_uuid(uuid)
-		except Exception,exn:
-			if verbose: print "No VM's found with a UUID of \"%s\"" %uuid
+		except Exception, exn:
+			if verbose:
+				print "No VM's found with a UUID of \"%s\"" % uuid
 			raise
 		
 
@@ -182,13 +185,15 @@ def return_vm_reference(session, options):
 			return vm_arr[0]
 		else:
 			if len(vm_arr) == 0:
-				if verbose: print "No VM's found with a name of \"%s\"" %vm_name
+				if verbose:
+					print "No VM's found with a name of \"%s\"" % vm_name
 				# NAME_INVALID used as the XenAPI throws a UUID_INVALID if it can't find
 				# a VM with the specified UUID. This should make the output look fairly
 				# consistent.
 				raise Exception("NAME_INVALID")
 			else:
-				if verbose: print "Multiple VM's have the name \"%s\", use UUID instead" %vm_name
+				if verbose:
+					print "Multiple VM's have the name \"%s\", use UUID instead" % vm_name
 				raise Exception("MULTIPLE_VMS_FOUND")
 
 	# We should never get to this case as the input processing checks that either the UUID or
-- 
1.7.7.6




More information about the Cluster-devel mailing list