Skip to contentSkip to conversation

code cleanup: Fix minor warning according to pylint

PATCH New Marek 'marx' Grac 2 participants 2 messages Oct 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 code cleanup: Fix minor warning according to pylint

* 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(-)
fence/agents/alom/fence_alom.py +7 -7
index 0f68050..8d5a4bd 100644
@@ -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:
fence/agents/apc/fence_apc.py +6 -6
index 0406955..d0ed9b6 100644
@@ -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
fence/agents/apc_snmp/fence_apc_snmp.py +79 -79

256 lines not on this page · raw message

fence/agents/bladecenter/fence_bladecenter.py +0 -5
index ab06b27..49a3b5b 100644
@@ -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"] + "\]>"
 
fence/agents/cisco_mds/fence_cisco_mds.py +21 -21

92 lines not on this page · raw message

fence/agents/cisco_ucs/fence_cisco_ucs.py +4 -4
index 84cb4fd..a34a580 100644
@@ -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
fence/agents/drac5/fence_drac5.py +3 -4
index b261e50..d8f4bb8 100644
@@ -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)
 
fence/agents/eaton_snmp/fence_eaton_snmp.py +70 -70

257 lines not on this page · raw message

fence/agents/eps/fence_eps.py +22 -22

110 lines not on this page · raw message

fence/agents/hpblade/fence_hpblade.py +8 -8
index 4e125c1..2953ddc 100644
@@ -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)
fence/agents/ibmblade/fence_ibmblade.py +19 -19
index ec992f4..9805036 100644
@@ -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"
fence/agents/ifmib/fence_ifmib.py +28 -28

116 lines not on this page · raw message

fence/agents/ilo/fence_ilo.py +1 -1
index fca72a7..715b163 100644
@@ -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 *
 
fence/agents/ilo_mp/fence_ilo_mp.py +1 -1
index 9ac8701..9c18336 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, socket
+import sys, re, pexpect, exceptions
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/intelmodular/fence_intelmodular.py +16 -16
index 52dd27f..32d8449 100644
@@ -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"
fence/agents/ipdu/fence_ipdu.py +47 -47

176 lines not on this page · raw message

fence/agents/ldom/fence_ldom.py +17 -17
index 498d0d7..edbb2bf 100644
@@ -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
fence/agents/lib/XenAPI.py.py +136 -136

294 lines not on this page · raw message

fence/agents/lib/fencing.py.py +6 -6
index c1851d1..ea0ca09 100644
@@ -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"
fence/agents/lib/fencing_snmp.py.py +40 -40

164 lines not on this page · raw message

fence/agents/lpar/fence_lpar.py +2 -2
index a5d4195..df4f1ef 100644
@@ -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")
fence/agents/rhevm/fence_rhevm.py +5 -5
index 9bb9581..c6f16ff 100644
@@ -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)
fence/agents/sanbox2/fence_sanbox2.py +3 -3
index 51781f9..1ed71cf 100644
@@ -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)
fence/agents/virsh/fence_virsh.py +14 -14
index ebf6666..cb33a56 100644
@@ -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"
fence/agents/vmware/fence_vmware.py +80 -80

311 lines not on this page · raw message

fence/agents/vmware_soap/fence_vmware_soap.py +1 -2
index 21dad66..41da8c0 100644
@@ -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 *
 
fence/agents/wti/fence_wti.py +0 -1
index 9aa9959..555fb98 100644
@@ -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("|")]
fence/agents/xenapi/fence_xenapi.py +20 -15
index 017908f..f583ea5 100644
@@ -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
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 1/2 code cleanup: Fix minor warning according to pylint

Hello Marx,

Quoted 5 lines · Marek 'marx' Grac
fence/agents/rhevm/fence_rhevm.py +0 -0
index 9bb9581..c6f16ff 100644

fence/agents/rhevm/fence_rhevm.py BUILD_DATE="March, 2008" · line 17

Quoted 9 lines
fence/agents/rhevm/fence_rhevm.py +3 -3
@@ -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) 

3rd line keeps the trailing white-space (might be fixed as well)

Quoted 15 lines
fence/agents/xenapi/fence_xenapi.py +2 -3
index 017908f..f583ea5 100644
@@ -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);

fence/agents/xenapi/fence_xenapi.py def connect_and_login(options): · line 153

Quoted 10 lines
fence/agents/xenapi/fence_xenapi.py +3 -2
+		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

sys.exit line ditto

BTW. pylint should be capable of trailing whitespace detection (W291?).

Signature · 1 line
Jan