Skip to contentSkip to conversation

Add missing spaces and fix tab/spaces indentation

PATCH New Marek 'marx' Grac 1 participant 15 messages Apr 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/15 Add missing spaces and fix tab/spaces indentation

---
 fence/agents/alom/fence_alom.py                 |   8 +-
 fence/agents/amt/fence_amt.py                   | 202 +++++++++--------
 fence/agents/apc/fence_apc.py                   |  18 +-
 fence/agents/apc_snmp/fence_apc_snmp.py         |  18 +-
 fence/agents/bladecenter/fence_bladecenter.py   |   8 +-
 fence/agents/brocade/fence_brocade.py           |   6 +-
 fence/agents/cisco_mds/fence_cisco_mds.py       |   4 +-
 fence/agents/cisco_ucs/fence_cisco_ucs.py       |  10 +-
 fence/agents/drac/fence_drac.py                 |   8 +-
 fence/agents/drac5/fence_drac5.py               |  14 +-
 fence/agents/dummy/fence_dummy.py               |   6 +-
 fence/agents/eps/fence_eps.py                   |   6 +-
 fence/agents/hds_cb/fence_hds_cb.py             |   7 +-
 fence/agents/hpblade/fence_hpblade.py           |   8 +-
 fence/agents/ifmib/fence_ifmib.py               |   2 +-
 fence/agents/ilo/fence_ilo.py                   |   4 +-
 fence/agents/ilo_mp/fence_ilo_mp.py             |  12 +-
 fence/agents/intelmodular/fence_intelmodular.py |   2 +-
 fence/agents/ipmilan/fence_ipmilan.py           | 274 ++++++++++++------------
 fence/agents/ldom/fence_ldom.py                 |  21 +-
 fence/agents/lib/check_used_options.py          |   2 +-
 fence/agents/lib/fencing.py.py                  |  64 +++---
 fence/agents/lpar/fence_lpar.py                 |  18 +-
 fence/agents/ovh/fence_ovh.py                   |  18 +-
 fence/agents/rhevm/fence_rhevm.py               |   6 +-
 fence/agents/rsa/fence_rsa.py                   |   6 +-
 fence/agents/rsb/fence_rsb.py                   |   6 +-
 fence/agents/sanbox2/fence_sanbox2.py           |   6 +-
 fence/agents/vmware/fence_vmware.py             |   2 +-
 fence/agents/vmware_soap/fence_vmware_soap.py   |  16 +-
 fence/agents/wti/fence_wti.py                   |  24 +--
 fence/agents/xenapi/fence_xenapi.py             |  19 +-
 32 files changed, 409 insertions(+), 416 deletions(-)
fence/agents/alom/fence_alom.py +4 -4
index ef2db3c..7a7e38e 100644
@@ -29,7 +29,7 @@ def set_power_status(conn, options):
 	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	# Get the machine some time between poweron and poweroff
 	time.sleep(int(options["--power-timeout"]))
-		
+
 def main():
 	device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure" ]
 
@@ -40,14 +40,14 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 	options["telnet_over_ssh"] = 1
-	
+
 	docs = { }
 	docs["shortdesc"] = "Fence agent for Sun ALOM"
 	docs["longdesc"] = "fence_alom is an I/O Fencing \
 agent which can be used with ALOM connected machines."
 	docs["vendorurl"] = "http://www.sun.com"
 	show_docs(options, docs)
-		
+
 	# Operate the fencing device
 	conn = fence_login(options)
 	result = fence_action(conn, options, set_power_status, get_power_status, None)
@@ -57,7 +57,7 @@ agent which can be used with ALOM connected machines."
 		conn.send_eol("logout")
 		conn.close()
 	except:
-		pass	                                         
+		pass
 
 	sys.exit(result)
 
fence/agents/amt/fence_amt.py +99 -103

239 lines not on this page · raw message

fence/agents/apc/fence_apc.py +9 -9
index 24ab5ee..da1b6b8 100644
@@ -10,7 +10,7 @@
 ##  AP7941      AOS v3.5.7, PDU APP v3.5.6
 ##  AP9606	AOS v2.5.4, PDU APP v2.7.3
 ##
-## @note: ssh is very slow on AP79XX devices protocol (1) and 
+## @note: ssh is very slow on AP79XX devices protocol (1) and
 ##        cipher (des/blowfish) have to be defined
 #####
 
@@ -66,7 +66,7 @@ def get_power_status(conn, options):
 			conn.send_eol("1")
 	else:
 		conn.send_eol(options["--switch"])
-			
+
 	while True:
 		exp_result = conn.log_expect(options, ["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
@@ -78,7 +78,7 @@ def get_power_status(conn, options):
 		conn.send_eol("")
 		if exp_result != 0:
 			break
-	conn.send(chr(03))		
+	conn.send(chr(03))
 	conn.log_expect(options, "- Logout", int(options["--shell-timeout"]))
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
@@ -162,7 +162,7 @@ def set_power_status(conn, options):
 	else:
 		conn.send_eol("1")
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-		
+
 	conn.send_eol(action)
 	conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", int(options["--shell-timeout"]))
 	conn.send_eol("YES")
@@ -181,9 +181,9 @@ def get_power_status5(conn, options):
 
 	exp_result = conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	lines = conn.before.split("\n")
-		
+
 	show_re = re.compile('^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
-	
+
 	for x in lines:
 		res = show_re.search(x)
 		if (res != None):
@@ -252,8 +252,8 @@ will block any necessary fencing actions."
 	##
 	## Logout from system
 	##
-	## In some special unspecified cases it is possible that 
-	## connection will be closed before we run close(). This is not 
+	## In some special unspecified cases it is possible that
+	## connection will be closed before we run close(). This is not
 	## a problem because everything is checked before.
 	######
 	try:
@@ -261,7 +261,7 @@ will block any necessary fencing actions."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/apc_snmp/fence_apc_snmp.py +9 -9
index da02066..1e44ae6 100644
@@ -36,15 +36,15 @@ switch_id = None
 # Classes describing Device params
 class TripplitePDU:
         # Rack PDU
-        status_oid=      '.1.3.6.1.4.1.850.10.2.3.5.1.2.1.%d'
-        control_oid=     '.1.3.6.1.4.1.850.10.2.3.5.1.4.1.%d'
-        outlet_table_oid='.1.3.6.1.4.1.850.10.2.3.5.1.5'
-        ident_str="Tripplite"
-        state_on=2
-        state_off=1
-        turn_on=2
-        turn_off=1
-        has_switches=False
+	status_oid =       '.1.3.6.1.4.1.850.10.2.3.5.1.2.1.%d'
+	control_oid =      '.1.3.6.1.4.1.850.10.2.3.5.1.4.1.%d'
+	outlet_table_oid = '.1.3.6.1.4.1.850.10.2.3.5.1.5'
+	ident_str = "Tripplite"
+	state_on = 2
+	state_off = 1
+	turn_on = 2
+	turn_off = 1
+	has_switches = False
 
 class ApcRPDU:
 	# Rack PDU
fence/agents/bladecenter/fence_bladecenter.py +4 -4
index 14a152b..6eeaeb4 100644
@@ -6,7 +6,7 @@
 ##
 ##  Model                 Firmware
 ## +--------------------+---------------------------+
-## (1) Main application	  BRET85K, rev 16  
+## (1) Main application	  BRET85K, rev 16
 ##     Boot ROM           BRBR67D, rev 16
 ##     Remote Control     BRRG67D, rev 16
 ##
@@ -88,7 +88,7 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	docs = { }        
+	docs = { }
 	docs["shortdesc"] = "Fence agent for IBM BladeCenter"
 	docs["longdesc"] = "fence_bladecenter is an I/O Fencing agent \
 which can be used with IBM Bladecenters with recent enough firmware that \
@@ -96,7 +96,7 @@ includes telnet support. It logs into a Brocade chasis via telnet or ssh \
 and uses the command line interface to power on and off blades."
 	docs["vendorurl"] = "http://www.ibm.com"
 	show_docs(options, docs)
-	
+
 	##
 	## Operate the fencing device
 	######
@@ -111,7 +111,7 @@ and uses the command line interface to power on and off blades."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/brocade/fence_brocade.py +3 -3
index 25581fd..53b4573 100644
@@ -70,8 +70,8 @@ FC switch needs to be enabled. This can be done by running fence_brocade and spe
 	##
 	## Logout from system
 	##
-	## In some special unspecified cases it is possible that 
-	## connection will be closed before we run close(). This is not 
+	## In some special unspecified cases it is possible that
+	## connection will be closed before we run close(). This is not
 	## a problem because everything is checked before.
 	######
 	try:
@@ -79,7 +79,7 @@ FC switch needs to be enabled. This can be done by running fence_brocade and spe
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/cisco_mds/fence_cisco_mds.py +2 -2
index 4acce4f..2428dcf 100644
@@ -86,7 +86,7 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	docs = { }           
+	docs = { }
 	docs["shortdesc"] = "Fence agent for Cisco MDS"
 	docs["longdesc"] = "fence_cisco_mds is an I/O Fencing agent \
 which can be used with any Cisco MDS 9000 series with SNMP enabled device."
@@ -98,7 +98,7 @@ which can be used with any Cisco MDS 9000 series with SNMP enabled device."
 
 	# Operate the fencing device
 	result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/cisco_ucs/fence_cisco_ucs.py +5 -5
index 71782cb..50c1cb8 100644
@@ -38,14 +38,14 @@ def set_power_status(conn, options):
 		'on' : "up",
 		'off' : "down"
 	}[options["--action"]]
-	
+
 	res = send_command(options, \
 		"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
 		"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] + "/power\">" + \
 		"<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
 		"</pair></inConfigs></configConfMos>", \
 		int(options["--shell-timeout"]))
-	
+
 	return
 
 def get_list(conn, options):
@@ -112,7 +112,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	define_new_opts()
-	
+
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
@@ -131,7 +131,7 @@ used with Cisco UCS to fence machines."
 	try:
 		res = send_command(options, "<aaaLogin inName=\"" + options["--username"] + "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
 		result = RE_COOKIE.search(res)
-		if (result == None):	
+		if (result == None):
 			## Cookie is absenting in response
 			fail(EC_LOGIN_DENIED)
 	except:
@@ -151,7 +151,7 @@ used with Cisco UCS to fence machines."
 
 	### Logout; we do not care about result as we will end in any case
 	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["--shell-timeout"]))
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/drac/fence_drac.py +4 -4
index c690b21..c2b2acc 100644
@@ -35,7 +35,7 @@ def main():
 		all_opt["cmd_prompt"]["default"] = [ "\\[" + opt["--username"] + "\\]# " ]
 	else:
 		all_opt["cmd_prompt"]["default"] = [ "\\[" "username" + "\\]# " ]
-	
+
 	options = check_input(device_opt, opt)
 
 	docs = { }
@@ -64,8 +64,8 @@ To enable telnet on the DRAC: \
 	##
 	## Logout from system
 	##
-	## In some special unspecified cases it is possible that 
-	## connection will be closed before we run close(). This is not 
+	## In some special unspecified cases it is possible that
+	## connection will be closed before we run close(). This is not
 	## a problem because everything is checked before.
 	######
 	try:
@@ -73,7 +73,7 @@ To enable telnet on the DRAC: \
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/drac5/fence_drac5.py +7 -7
index 2c067a7..6ce0586 100644
@@ -24,15 +24,15 @@ BUILD_DATE="March, 2008"
 
 def get_power_status(conn, options):
 	if options["--drac-version"] == "DRAC MC":
-		(_, status) = get_list_devices(conn,options)[options["--plug"]]
+		(_, status) = get_list_devices(conn, options)[options["--plug"]]
 	else:
 		if options["--drac-version"] == "DRAC CMC":
 			conn.send_eol("racadm serveraction powerstatus -m " + options["--plug"])
 		elif options["--drac-version"] == "DRAC 5":
 			conn.send_eol("racadm serveraction powerstatus")
-		
+
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-				
+
 		status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
 
 	if status.lower().strip() in ["on", "powering on", "powering off"]:
@@ -111,8 +111,8 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	docs = { }           
-	docs["shortdesc"] = "Fence agent for Dell DRAC CMC/5" 
+	docs = { }
+	docs["shortdesc"] = "Fence agent for Dell DRAC CMC/5"
 	docs["longdesc"] = "fence_drac5 is an I/O Fencing agent \
 which can be used with the Dell Remote Access Card v5 or CMC (DRAC). \
 This device provides remote access to controlling  power to a server. \
@@ -129,7 +129,7 @@ By default, the telnet interface is not  enabled."
 	if options.has_key("--drac-version") == False:
 		## autodetect from text issued by fence device
 		if conn.before.find("CMC") >= 0:
-	  		options["--drac-version"] = "DRAC CMC"
+			options["--drac-version"] = "DRAC CMC"
 		elif conn.before.find("DRAC 5") >= 0:
 			options["--drac-version"] = "DRAC 5"
 		elif conn.after.find("DRAC/MC") >= 0:
@@ -153,7 +153,7 @@ By default, the telnet interface is not  enabled."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/dummy/fence_dummy.py +3 -3
index d5bb748..1f9ddf1 100644
@@ -10,7 +10,7 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE=""
 #END_VERSION_GENERATION
 
-plug_status="on"
+plug_status = "on"
 
 def get_power_status_file(conn, options):
 	try:
@@ -32,7 +32,7 @@ def set_power_status_file(conn, options):
 	status_file.close()
 
 def get_power_status_fail(conn, options):
-	outlets = get_outlets_fail(conn,options)
+	outlets = get_outlets_fail(conn, options)
 
 	if len(outlets) == 0 or options.has_key("--plug") == 0:
 		fail_usage("Failed: You have to enter existing machine!")
@@ -124,7 +124,7 @@ def main():
 		result = fence_action(None, options, set_power_status_fail, get_power_status_fail, get_outlets_fail)
 	else:
 		result = fence_action(None, options, set_power_status_file, get_power_status_file, None)
-		
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/eps/fence_eps.py +3 -3
index 0e7709d..6f2c6da 100644
@@ -38,7 +38,7 @@ def eps_run_command(options, params):
 		if (options.has_key("--username")):
 			if (not options.has_key("--password")):
 				options["--password"] = "" # Default is empty password
-				
+
 			# String for Authorization header
 			auth_str = 'Basic ' + string.strip(base64.encodestring(options["--username"]+':'+options["--password"]))
 			eps_log(options, "Authorization:"+auth_str+"\n")
@@ -107,8 +107,8 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	docs = { }           
-	docs["shortdesc"] = "Fence agent for ePowerSwitch" 
+	docs = { }
+	docs["shortdesc"] = "Fence agent for ePowerSwitch"
 	docs["longdesc"] = "fence_eps  is an I/O Fencing agent \
 which can be used with the ePowerSwitch 8M+ power switch to fence \
 connected machines. Fence agent works ONLY on 8M+ device, because \
fence/agents/hds_cb/fence_hds_cb.py +3 -4
index 0e15af3..9bdf083 100755
@@ -60,7 +60,6 @@ def set_power_status(conn, options):
 		'off': "F",
 		'reboot' : "H",
 	}[options["--action"]]
-	
 
 	conn.sendline("S")	# Enter System Command Mode
 	conn.log_expect(options, "SVP>", int(options["--shell-timeout"]))
@@ -98,7 +97,7 @@ def get_blades_list(conn, options):
 	for line in conn.before.splitlines():
 		partition = re.search(RE_STATUS_LINE, line)
 		if( partition != None):
-			outlets[partition.group(1)] = (partition.group(2), "")	
+			outlets[partition.group(1)] = (partition.group(2), "")
 	conn.sendline("Q")	# Quit back to system command mode
 	conn.log_expect(options, "SVP>", int(options["--shell-timeout"]))
 	conn.sendline("EX")	# Quit back to system console menu
@@ -124,7 +123,7 @@ which can be used with Hitachi Compute Blades with recent enough firmware that \
 includes telnet support."
 	docs["vendorurl"] = "http://www.hds.com"
 	show_docs(options, docs)
-	
+
 	##
 	## Operate the fencing device
 	######
@@ -139,7 +138,7 @@ includes telnet support."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/hpblade/fence_hpblade.py +4 -4
index 42f5309..238e549 100644
@@ -19,7 +19,7 @@ BUILD_DATE="March, 2008"
 def get_power_status(conn, options):
 	conn.send_eol("show server status " + options["--plug"])
 	conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
-		
+
 	power_re = re.compile("^\s*Power: (.*?)\s*$")
 	status = "unknown"
 	for line in conn.before.splitlines():
@@ -65,14 +65,14 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	docs = { }        
+	docs = { }
 	docs["shortdesc"] = "Fence agent for HP BladeSystem"
 	docs["longdesc"] = "fence_hpblade is an I/O Fencing agent \
 which can be used with HP BladeSystem. It logs into an enclosure via telnet or ssh \
 and uses the command line interface to power on and off blades."
 	docs["vendorurl"] = "http://www.hp.com"
 	show_docs(options, docs)
-	
+
 	##
 	## Operate the fencing device
 	######
@@ -88,7 +88,7 @@ and uses the command line interface to power on and off blades."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/ifmib/fence_ifmib.py +1 -1
index 2184a85..eabcbe9 100644
@@ -119,7 +119,7 @@ to control the state of an interface."
 
 	# Operate the fencing device
 	result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/ilo/fence_ilo.py +2 -2
index 444f94b..779b9a5 100644
@@ -7,7 +7,7 @@
 ##  iLO Version
 ## +---------------------------------------------+
 ##  iLO  / firmware 1.91 / RIBCL 2.22
-##  iLO2 / firmware 1.22 / RIBCL 2.22 
+##  iLO2 / firmware 1.22 / RIBCL 2.22
 ##  iLO2 / firmware 1.50 / RIBCL 2.22
 #####
 
@@ -121,7 +121,7 @@ the iLO card through an XML stream."
 	## Fence operations
 	####
 	result = fence_action(conn, options, set_power_status, get_power_status, None)
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/ilo_mp/fence_ilo_mp.py +6 -6
index b1202bb..23aa8cc 100644
@@ -12,7 +12,7 @@ BUILD_DATE=""
 
 def get_power_status(conn, options):
 	conn.send_eol("show /system1")
-		
+
 	re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
 	conn.log_expect(options, re_state, int(options["--shell-timeout"]))
 
@@ -37,18 +37,18 @@ def main():
 	device_opt = [  "ipaddr", "login", "passwd", "secure", "cmd_prompt" ]
 
 	atexit.register(atexit_handler)
-	
+
 	all_opt["cmd_prompt"]["default"] = [ "MP>", "hpiLO->" ]
 	all_opt["power_wait"]["default"] = 5
-	
+
 	options = check_input(device_opt, process_input(device_opt))
-		
+
 	docs = { }
 	docs["shortdesc"] = "Fence agent for HP iLO MP"
 	docs["longdesc"] = ""
 	docs["vendorurl"] = "http://www.hp.com"
 	show_docs(options, docs)
-	
+
 	conn = fence_login(options)
 	conn.send_eol("SMCLP")
 
@@ -61,7 +61,7 @@ def main():
 		conn.send_eol("exit")
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/intelmodular/fence_intelmodular.py +1 -1
index 192d2e3..35091a0 100644
@@ -85,7 +85,7 @@ for command line and snmp_version option for your cluster.conf."
 
 	# Operate the fencing device
 	result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/ipmilan/fence_ipmilan.py +137 -137

325 lines not on this page · raw message

fence/agents/ldom/fence_ldom.py +10 -11
index 722bfda..acddffe 100644
@@ -2,9 +2,9 @@
 
 ##
 ## The Following Agent Has Been Tested On - LDOM 1.0.3
-## The interface is backward compatible so it will work 
+## The interface is backward compatible so it will work
 ## with 1.0, 1.0.1 and .2 too.
-## 
+##
 #####
 
 import sys, re, pexpect, exceptions
@@ -28,20 +28,19 @@ def start_communication(conn, options):
 		#CSH stuff
 		conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
 		conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
-	
 
 def get_power_status(conn, options):
 	start_communication(conn, options)
-		
+
 	conn.send_eol("ldm ls")
-		    
+
 	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--shell-timeout"]))
 
 	result = {}
 
 	#This is status of mini finite automata. 0 = we didn't found NAME and STATE, 1 = we did
 	fa_status = 0
-		
+
 	for line in conn.before.splitlines():
 		domain = re.search("^(\S+)\s+(\S+)\s+.*$", line)
 
@@ -61,13 +60,13 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	start_communication(conn, options)
-         	
+
 	cmd_line = "ldm "+(options["--action"]=="on" and "start" or "stop -f")+" \""+options["--plug"]+"\""
-            	
+
 	conn.send_eol(cmd_line)
-		    
+
 	conn.log_expect(options, COMMAND_PROMPT_REG, int(options["--power-timeout"]))
-		
+
 def main():
 	device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port" ]
 
@@ -112,7 +111,7 @@ root. Than prompt is $, so again, you must use parameter -c."
 	except pexpect.ExceptionPexpect:
 		pass
 
-	sys.exit(result)		
+	sys.exit(result)
 
 if __name__ == "__main__":
 	main()
fence/agents/lib/check_used_options.py +1 -1
index 86dc35f..2d2abbc 100755
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-## Check if fence agent uses only options["--??"] which are defined in fencing library or 
+## Check if fence agent uses only options["--??"] which are defined in fencing library or
 ## fence agent itself
 ##
 ## Usage: ./check_used_options.py fence-agent (e.g. lpar/fence_lpar.py)
fence/agents/lib/fencing.py.py +32 -32

247 lines not on this page · raw message

fence/agents/lpar/fence_lpar.py +9 -9
index 1d7e09c..8a8b50d 100644
@@ -4,7 +4,7 @@
 ##
 ## The Following Agent Has Been Tested On:
 ##
-##  Version       
+##  Version
 ## +---------------------------------------------+
 ##  Tested on HMC
 ##
@@ -33,7 +33,7 @@ def get_power_status(conn, options):
 		conn.send("lssyscfg -r lpar -m "+ options["--managed"] +" --filter 'lpar_names=" + options["--plug"] + "'\n")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
-		try:				
+		try:
 			status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
 		except AttributeError:
 			fail(EC_STATUS_HMC)
@@ -54,14 +54,14 @@ def set_power_status(conn, options):
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	elif options["--hmc-version"] == "4":
 		if options["--action"] == "on":
-			conn.send("chsysstate -o on -r lpar -m " + options["--managed"] + 
-				" -n " + options["--plug"] + 
+			conn.send("chsysstate -o on -r lpar -m " + options["--managed"] +
+				" -n " + options["--plug"] +
 				" -f `lssyscfg -r lpar -F curr_profile " +
 				" -m " + options["--managed"] +
 				" --filter \"lpar_names="+ options["--plug"] +"\"`\n" )
 		else:
 			conn.send("chsysstate -o shutdown -r lpar --immed" +
-				" -m " + options["--managed"] + " -n " + options["--plug"] + "\n")		
+				" -m " + options["--managed"] + " -n " + options["--plug"] + "\n")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 def get_lpar_list(conn, options):
@@ -76,12 +76,12 @@ def get_lpar_list(conn, options):
 
 		if res == None:
 			fail_usage("Unable to parse output of list command")
-		
+
 		lines = res.group(2).split("\n")
 		for outlet_line in lines:
 			outlets[outlet_line.rstrip()] = ("", "")
 	elif options["--hmc-version"] == "4":
-		conn.send("lssyscfg -r lpar -m " + options["--managed"] + 
+		conn.send("lssyscfg -r lpar -m " + options["--managed"] +
 			" -F name:state\n")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
@@ -91,7 +91,7 @@ def get_lpar_list(conn, options):
 
 		if res == None:
 			fail_usage("Unable to parse output of list command")
-		
+
 		lines = res.group(1).split("\n")
 		for outlet_line in lines:
 			(port, status) = outlet_line.split(":")
@@ -113,7 +113,7 @@ def define_new_opts():
 		"help" : "-H, --hmc-version=[version]    Force HMC version to use: 3, 4 (default)",
 		"required" : "0",
 		"shortdesc" : "Force HMC version to use (3 or 4)",
-		"default" : "4", 
+		"default" : "4",
 		"choices" : [ "3", "4" ],
 		"order" : 1 }
 
fence/agents/ovh/fence_ovh.py +9 -9
index 2ec3fa0..7d4b6bc 100644
@@ -37,7 +37,7 @@ def netboot_reboot(options, mode):
 
 	# dedicatedNetbootModifyById changes the mode of the next reboot
 	conn.service.dedicatedNetbootModifyById(options["session"], options["--plug"], mode, '', options["--email"])
- 
+
 	# dedicatedHardRebootDo initiates a hard reboot on the given node
 	conn.service.dedicatedHardRebootDo(options["session"], options["--plug"], 'Fencing initiated by cluster', '', 'en')
 
@@ -70,14 +70,14 @@ def soap_login(options):
 		soap = Client(url, doctor=d)
 		session = soap.service.login(options["--username"], options["--password"], 'en', 0)
 	except Exception, ex:
-		fail(EC_LOGIN_DENIED)   
+		fail(EC_LOGIN_DENIED)
 
 	options["session"] = session
 	return soap
 
 def remove_tmp_dir(tmp_dir):
 	shutil.rmtree(tmp_dir)
-	
+
 def main():
 	device_opt = [ "login", "passwd", "port", "email" ]
 
@@ -109,11 +109,11 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 
 	if options["--action"] == 'off':
 		# Reboot in Rescue-pro
-		netboot_reboot(options,OVH_RESCUE_PRO_NETBOOT_ID)
+		netboot_reboot(options, OVH_RESCUE_PRO_NETBOOT_ID)
 		time.sleep(STATUS_RESCUE_PRO_SLEEP)
 	elif options["--action"] in  ['on', 'reboot' ]:
 		# Reboot from HD
-		netboot_reboot(options,OVH_HARD_DISK_NETBOOT_ID)
+		netboot_reboot(options, OVH_HARD_DISK_NETBOOT_ID)
 		time.sleep(STATUS_HARD_DISK_SLEEP)
 
 	# Save datetime just after reboot
@@ -123,11 +123,11 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 	reboot_t = reboot_time(options)
 
 	if options.has_key("--verbose"):
-		options["debug_fh"].write("reboot_start_end.start: "+ reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")         
+		options["debug_fh"].write("reboot_start_end.start: "+ reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")
 		options["debug_fh"].write("before_netboot_reboot: " + before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("reboot_start_end.end: "  + reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")        
-		options["debug_fh"].write("after_netboot_reboot: "  + after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")  
-                
+		options["debug_fh"].write("reboot_start_end.end: "  + reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("after_netboot_reboot: "  + after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+
 	if reboot_t.start < after_netboot_reboot < reboot_t.end:
 		result = 0
 		if options.has_key("--verbose"):
fence/agents/rhevm/fence_rhevm.py +3 -3
index ff3d19f..1ed05d5 100644
@@ -14,7 +14,7 @@ BUILD_DATE="March, 2008"
 
 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_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
 
 def get_power_status(conn, options):
 	### Obtain real ID from name
@@ -26,7 +26,7 @@ def get_power_status(conn, options):
 		fail(EC_STATUS)
 
 	options["id"] = result.group(2)
-	
+
 	result = RE_STATUS.search(res)
 	if (result == None):
 		# We were able to parse ID so output is correct
@@ -106,7 +106,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["power_wait"]["default"] = "1"
-	
+
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
fence/agents/rsa/fence_rsa.py +3 -3
index 117dd67..7135573 100644
@@ -20,7 +20,7 @@ BUILD_DATE=""
 def get_power_status(conn, options):
 	conn.send_eol("power state")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-				
+
 	match = re.compile("Power: (.*)", re.IGNORECASE).search(conn.before)
 	if (match != None):
 		status = match.group(1)
@@ -55,7 +55,7 @@ be avoided while a GFS cluster is running because the connection \
 will block any necessary fencing actions."
 	docs["vendorurl"] = "http://www.ibm.com"
 	show_docs(options, docs)
-	
+
 	##
 	## Operate the fencing device
 	######
@@ -70,7 +70,7 @@ will block any necessary fencing actions."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/rsb/fence_rsb.py +3 -3
index da60a61..08af873 100755
@@ -70,8 +70,8 @@ will block any necessary fencing actions."
 	##
 	## Logout from system
 	##
-	## In some special unspecified cases it is possible that 
-	## connection will be closed before we run close(). This is not 
+	## In some special unspecified cases it is possible that
+	## connection will be closed before we run close(). This is not
 	## a problem because everything is checked before.
 	######
 	try:
@@ -79,7 +79,7 @@ will block any necessary fencing actions."
 		conn.close()
 	except:
 		pass
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/sanbox2/fence_sanbox2.py +3 -3
index 5221d49..6f320b1 100644
@@ -34,7 +34,7 @@ def get_power_status(conn, options):
 		except:
 			pass
 		fail(EC_TIMED_OUT)
-	
+
 	status = re.compile(".*AdminState\s+(online|offline)\s+", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 
 	try:
@@ -58,7 +58,7 @@ def set_power_status(conn, options):
 			conn.close()
 		except:
 			pass
-		fail(EC_TIMED_OUT)                                                                         	
+		fail(EC_TIMED_OUT)
 
 	try:
 		conn.send_eol("set port " + options["--plug"] + " state " + action)
@@ -96,7 +96,7 @@ def get_list_devices(conn, options):
 		except:
 			pass
 		fail(EC_TIMED_OUT)
-		
+
 	return outlets
 
 def main():
fence/agents/vmware/fence_vmware.py +1 -1
index dc4ef0f..551337e 100644
@@ -326,7 +326,7 @@ This agent supports only vmrun from version 2.0.0 (VIX API 1.6.0)."
 
 	# Operate the fencing device
 	result = fence_action(None, options, set_power_status, get_power_status, get_outlets_status)
-	
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/vmware_soap/fence_vmware_soap.py +8 -8
index bbac1c5..7ce9016 100644
@@ -23,13 +23,13 @@ def soap_login(options):
 		url = "https://"
 	else:
 		url = "http://"
-	
+
 	url += options["--ip"] + ":" + str(options["--ipport"]) + "/sdk"
 
 	tmp_dir = tempfile.mkdtemp()
 	tempfile.tempdir = tmp_dir
 	atexit.register(remove_tmp_dir, tmp_dir)
-	
+
 	try:
 		conn = Client(url + "/vimService.wsdl")
 		conn.set_options(location = url)
@@ -42,7 +42,7 @@ def soap_login(options):
 
 		SessionManager = conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
 	except Exception, ex:
-		fail(EC_LOGIN_DENIED)	
+		fail(EC_LOGIN_DENIED)
 
 	options["ServiceContent"] = ServiceContent
 	options["mo_SessionManager"] = mo_SessionManager
@@ -125,9 +125,9 @@ def get_power_status(conn, options):
 				## Transform InventoryPath to UUID
 				mo_SearchIndex = Property(options["ServiceContent"].searchIndex.value)
 				mo_SearchIndex._type = "SearchIndex"
-			
+
 				vm = conn.service.FindByInventoryPath(mo_SearchIndex, options["--plug"])
-			
+
 				try:
 					options["--uuid"] = mappingToUUID[vm.value]
 				except KeyError, ex:
@@ -159,7 +159,7 @@ def set_power_status(conn, options):
 
 	mo_machine = Property(vm.value)
 	mo_machine._type = "VirtualMachine"
-	
+
 	try:
 		if options["--action"] == "on":
 			conn.service.PowerOnVM_Task(mo_machine)
@@ -184,7 +184,7 @@ def main():
 
 	options = check_input(device_opt, process_input(device_opt))
 
-	## 
+	##
 	## Fence agent specific defaults
 	#####
 	docs = { }
@@ -207,7 +207,7 @@ Alternatively you can always use UUID to access virtual machine."
 	## Operate the fencing device
 	####
 	conn = soap_login(options)
-		
+
 	result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
 
 	##
fence/agents/wti/fence_wti.py +12 -12
index d824e7d..227e4b4 100644
@@ -51,7 +51,7 @@ def get_plug_status(conn, options):
 	status_index = -1
 	plug_header = list()
 	outlets = {}
-	
+
 	for line in listing.splitlines():
 		if (plug_section == 2) and line.find("|") >= 0 and line.startswith("PLUG") == False:
 			plug_line = [x.strip().lower() for x in line.split("|")]
@@ -80,7 +80,7 @@ def get_plug_status(conn, options):
 def get_plug_group_status_from_list(status_list):
 	for status in status_list:
 		if status == "on":
-		      return status
+			return status
 	return "off"
 
 def get_plug_group_status(conn, options):
@@ -108,7 +108,7 @@ def get_plug_group_status(conn, options):
 						line_index = -1
 
 				return get_plug_group_status_from_list(plug_status)
- 
+
 			else:
 				## We already believe that first column contains plug number
 				if len(plug_line[0]) != 0:
@@ -148,7 +148,7 @@ def get_plug_group_status(conn, options):
 
 def get_power_status(conn, options):
 	ret = get_plug_status(conn, options)
-	
+
 	if ret == "PROBLEM":
 		ret = get_plug_group_status(conn, options)
 
@@ -182,12 +182,12 @@ Lengthy telnet connections to the NPS should be avoided while a GFS cluster \
 is running because the connection will block any necessary fencing actions."
 	docs["vendorurl"] = "http://www.wti.com"
 	show_docs(options, docs)
-	
+
 	##
 	## Operate the fencing device
 	##
 	## @note: if it possible that this device does not need either login, password or both of them
-	#####	
+	#####
 	if 0 == options.has_key("--ssh"):
 		try:
 			if options["--action"] in ["off", "reboot"]:
@@ -196,7 +196,7 @@ is running because the connection will block any necessary fencing actions."
 			conn = fspawn(options, TELNET_PATH)
 			conn.send("set binary\n")
 			conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
-			
+
 			re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
 			re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["--command-prompt"])), re.IGNORECASE)
 
@@ -207,17 +207,17 @@ is running because the connection will block any necessary fencing actions."
 					result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
 				else:
 					fail_usage("Failed: You have to set login name")
-		
+
 			if result == 1:
 				if options.has_key("--password"):
 					conn.send(options["--password"]+"\r\n")
-					conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))	
+					conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 				else:
 					fail_usage("Failed: You have to enter password or password script")
 		except pexpect.EOF:
-			fail(EC_LOGIN_DENIED) 
+			fail(EC_LOGIN_DENIED)
 		except pexpect.TIMEOUT:
-			fail(EC_LOGIN_DENIED)		
+			fail(EC_LOGIN_DENIED)
 	else:
 		conn = fence_login(options)
 
@@ -231,7 +231,7 @@ is running because the connection will block any necessary fencing actions."
 		conn.close()
 	except:
 		pass
-		
+
 	sys.exit(result)
 
 if __name__ == "__main__":
fence/agents/xenapi/fence_xenapi.py +9 -10
index 9cf200a..81ebb96 100644
@@ -8,12 +8,12 @@
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # fence-xenserver is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -49,7 +49,7 @@ def get_power_fn(session, options):
 		verbose = True
 	else:
 		verbose = False
-		
+
 	try:
 		# Get a reference to the vm specified in the UUID or vm_name/port parameter
 		vm = return_vm_reference(session, options)
@@ -78,7 +78,7 @@ def get_power_fn(session, options):
 # Set the state of the port given in the -U flag of options.
 def set_power_fn(session, options):
 	action = options["--action"].lower()
-	
+
 	try:
 		# Get a reference to the vm specified in the UUID or vm_name/port parameter
 		vm = return_vm_reference(session, options)
@@ -88,7 +88,7 @@ def set_power_fn(session, options):
 		# domain as they show up as VM's with specific properties.
 		if not(record["is_a_template"]) and not(record["is_control_domain"]):
 			if( action == "on" ):
-				# Start the VM 
+				# Start the VM
 				session.xenapi.VM.start(vm, False, True)
 			elif( action == "off" ):
 				# Force shutdown the VM
@@ -141,11 +141,11 @@ def connect_and_login(options):
 	except Exception, 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 
+		# 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) 
+		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
@@ -169,7 +169,6 @@ def return_vm_reference(session, options):
 			if verbose:
 				print "No VM's found with a UUID of \"%s\"" % uuid
 			raise
-		
 
 	# Case where the vm_name/port has been specified
 	if options.has_key("--plug"):
@@ -213,12 +212,12 @@ fence_cxs is an I/O Fencing agent used on Citrix XenServer hosts. \
 It uses the XenAPI, supplied by Citrix, to establish an XML-RPC sesssion \
 to a XenServer host. Once the session is established, further XML-RPC \
 commands are issued in order to switch on, switch off, restart and query \
-the status of virtual machines running on the host." 
+the status of virtual machines running on the host."
 	docs["vendorurl"] = "http://www.xenproject.org"
 	show_docs(options, docs)
 
 	xenSession = connect_and_login(options)
-	
+
 	# Operate the fencing device
 	result = fence_action(xenSession, options, set_power_fn, get_power_fn, get_outlet_list)
 
Signature · 1 line
1.9.0
#1 lore raw

PATCH 2/15 Proper import of atexit

Previously atexit library was imported only from the fencing library.

---
 fence/agents/alom/fence_alom.py                 | 1 +
 fence/agents/amt/fence_amt.py                   | 1 +
 fence/agents/apc/fence_apc.py                   | 1 +
 fence/agents/apc_snmp/fence_apc_snmp.py         | 1 +
 fence/agents/bladecenter/fence_bladecenter.py   | 1 +
 fence/agents/brocade/fence_brocade.py           | 1 +
 fence/agents/cisco_mds/fence_cisco_mds.py       | 1 +
 fence/agents/cisco_ucs/fence_cisco_ucs.py       | 1 +
 fence/agents/drac/fence_drac.py                 | 1 +
 fence/agents/drac5/fence_drac5.py               | 1 +
 fence/agents/dummy/fence_dummy.py               | 1 +
 fence/agents/eaton_snmp/fence_eaton_snmp.py     | 1 +
 fence/agents/eps/fence_eps.py                   | 1 +
 fence/agents/hds_cb/fence_hds_cb.py             | 1 +
 fence/agents/hpblade/fence_hpblade.py           | 1 +
 fence/agents/ibmblade/fence_ibmblade.py         | 1 +
 fence/agents/ifmib/fence_ifmib.py               | 1 +
 fence/agents/ilo/fence_ilo.py                   | 1 +
 fence/agents/ilo_mp/fence_ilo_mp.py             | 1 +
 fence/agents/intelmodular/fence_intelmodular.py | 1 +
 fence/agents/ipdu/fence_ipdu.py                 | 1 +
 fence/agents/ipmilan/fence_ipmilan.py           | 1 +
 fence/agents/ldom/fence_ldom.py                 | 1 +
 fence/agents/lib/fencing.py.py                  | 2 +-
 fence/agents/lpar/fence_lpar.py                 | 1 +
 fence/agents/netio/fence_netio.py               | 1 +
 fence/agents/ovh/fence_ovh.py                   | 1 +
 fence/agents/rhevm/fence_rhevm.py               | 1 +
 fence/agents/rsa/fence_rsa.py                   | 1 +
 fence/agents/rsb/fence_rsb.py                   | 1 +
 fence/agents/sanbox2/fence_sanbox2.py           | 1 +
 fence/agents/virsh/fence_virsh.py               | 1 +
 fence/agents/vmware/fence_vmware.py             | 1 +
 fence/agents/vmware_soap/fence_vmware_soap.py   | 1 +
 fence/agents/wti/fence_wti.py                   | 1 +
 fence/agents/xenapi/fence_xenapi.py             | 1 +
 36 files changed, 36 insertions(+), 1 deletion(-)
fence/agents/alom/fence_alom.py +1 -0
index 7a7e38e..ae484a4 100644
@@ -6,6 +6,7 @@
 # as found on SUN T2000 Niagara
 
 import sys, re, pexpect, time, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/amt/fence_amt.py +1 -0
index 71288e0..55e3e5b 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, subprocess, re, os, stat
+import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/apc/fence_apc.py +1 -0
index da1b6b8..451c616 100644
@@ -15,6 +15,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/apc_snmp/fence_apc_snmp.py +1 -0
index 1e44ae6..971919a 100644
@@ -10,6 +10,7 @@
 # - Tripplite PDUMH20HVNET 12.04.0055 - SNMP v1, v2c, v3
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/bladecenter/fence_bladecenter.py +1 -0
index 6eeaeb4..d3a0301 100644
@@ -13,6 +13,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/brocade/fence_brocade.py +1 -0
index 53b4573..b7a197e 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/cisco_mds/fence_cisco_mds.py +1 -0
index 2428dcf..2bd6eae 100644
@@ -7,6 +7,7 @@
 #   with BIOS 1.0.16, kickstart 4.1(1c), system 4.1(1c)
 
 import sys, re
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/cisco_ucs/fence_cisco_ucs.py +1 -0
index 50c1cb8..debefb4 100644
@@ -2,6 +2,7 @@
 
 import sys, re
 import pycurl, StringIO
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/drac/fence_drac.py +1 -0
index c2b2acc..90314f4 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/drac5/fence_drac5.py +1 -0
index 6ce0586..20e2e8a 100644
@@ -13,6 +13,7 @@
 #####
 
 import sys, re, pexpect, exceptions, time
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/dummy/fence_dummy.py +1 -0
index 1f9ddf1..cc136d4 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions, random
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/eaton_snmp/fence_eaton_snmp.py +1 -0
index 462d541..0497c75 100644
@@ -7,6 +7,7 @@
 #   EATON | Powerware ePDU model: Switched ePDU (IPV3600), firmware: 2.0.K
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/eps/fence_eps.py +1 -0
index 6f2c6da..6e7cc1e 100644
@@ -5,6 +5,7 @@
 
 import sys, re
 import httplib, base64, string, socket
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/hds_cb/fence_hds_cb.py +1 -0
index 9bdf083..d8046b1 100755
@@ -11,6 +11,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/hpblade/fence_hpblade.py +1 -0
index 238e549..e2de148 100644
@@ -7,6 +7,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/ibmblade/fence_ibmblade.py +1 -0
index 1787ae2..4567861 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/ifmib/fence_ifmib.py +1 -0
index eabcbe9..ec5ab0c 100644
@@ -9,6 +9,7 @@
 #   Only lance if is visible
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/ilo/fence_ilo.py +1 -0
index 779b9a5..a04aacf 100644
@@ -12,6 +12,7 @@
 #####
 
 import sys, re, pexpect
+import atexit
 from xml.sax.saxutils import quoteattr
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/ilo_mp/fence_ilo_mp.py +1 -0
index 23aa8cc..5bb234b 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/intelmodular/fence_intelmodular.py +1 -0
index 35091a0..d569d74 100644
@@ -12,6 +12,7 @@
 # Thanks Matthew Kent for original agent and testing.
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing_snmp import *
fence/agents/ipdu/fence_ipdu.py +1 -0
index 7f08656..b90a333 100644
@@ -6,6 +6,7 @@
 #
 
 import sys
+import atexit
 sys.path.append("/usr/share/fence")
 from fencing import *
 from fencing_snmp import *
fence/agents/ipmilan/fence_ipmilan.py +1 -0
index 0cea62b..ab5a75a 100644
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, shlex, stat, subprocess, re, os
+import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/ldom/fence_ldom.py +1 -0
index acddffe..1bf1c49 100644
@@ -8,6 +8,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/lib/fencing.py.py +1 -1
index 9ef3c8e..41f9087 100644
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys, getopt, time, os, uuid, pycurl, stat
-import pexpect, re, atexit, syslog
+import pexpect, re, syslog
 import __main__
 
 ## do not add code here.
fence/agents/lpar/fence_lpar.py +1 -0
index 8a8b50d..c4237f2 100644
@@ -11,6 +11,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/netio/fence_netio.py +1 -0
index 3cbf489..71c3014 100755
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/ovh/fence_ovh.py +1 -0
index 7d4b6bc..6becd8e 100644
@@ -10,6 +10,7 @@
 
 import sys, time
 import shutil, tempfile
+import atexit
 from datetime import datetime
 from suds.client import Client
 from suds.xsd.doctor import ImportDoctor, Import
fence/agents/rhevm/fence_rhevm.py +1 -0
index 1ed05d5..e4a11de 100644
@@ -2,6 +2,7 @@
 
 import sys, re
 import pycurl, StringIO
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/rsa/fence_rsa.py +1 -0
index 7135573..992c5e6 100644
@@ -8,6 +8,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/rsb/fence_rsb.py +1 -0
index 08af873..6c5e119 100755
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/sanbox2/fence_sanbox2.py +1 -0
index 6f320b1..86b646b 100644
@@ -9,6 +9,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/virsh/fence_virsh.py +1 -0
index 1ec5310..0ebf668 100644
@@ -6,6 +6,7 @@
 #
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/vmware/fence_vmware.py +1 -0
index 551337e..c6209e8 100644
@@ -23,6 +23,7 @@
 #
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/vmware_soap/fence_vmware_soap.py +1 -0
index 7ce9016..cd56f9f 100644
@@ -3,6 +3,7 @@
 import sys, exceptions, time
 import shutil, tempfile, suds
 import logging
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 
 from suds.client import Client
fence/agents/wti/fence_wti.py +1 -0
index 227e4b4..5157335 100644
@@ -12,6 +12,7 @@
 #####
 
 import sys, re, pexpect, exceptions
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 
fence/agents/xenapi/fence_xenapi.py +1 -0
index 81ebb96..509dd8b 100644
@@ -32,6 +32,7 @@
 # whether I should continue support for it. mattjclark0407 at hotmail dot com
 
 import sys
+import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 import XenAPI
Signature · 1 line
1.9.0
#2 lore raw

PATCH 3/15 Remove unused variables

In reply to Marek 'marx' Grac
---
 fence/agents/apc/fence_apc.py                   |  3 +--
 fence/agents/brocade/fence_brocade.py           |  2 +-
 fence/agents/cisco_mds/fence_cisco_mds.py       |  2 +-
 fence/agents/cisco_ucs/fence_cisco_ucs.py       |  2 +-
 fence/agents/eps/fence_eps.py                   |  2 +-
 fence/agents/ifmib/fence_ifmib.py               |  2 +-
 fence/agents/intelmodular/fence_intelmodular.py |  2 +-
 fence/agents/lib/fencing.py.py                  |  3 +--
 fence/agents/netio/fence_netio.py               |  2 +-
 fence/agents/ovh/fence_ovh.py                   |  2 +-
 fence/agents/rhevm/fence_rhevm.py               |  2 +-
 fence/agents/vmware_soap/fence_vmware_soap.py   | 20 ++++++++++----------
 fence/agents/wti/fence_wti.py                   |  2 --
 fence/agents/xenapi/fence_xenapi.py             |  2 +-
 14 files changed, 22 insertions(+), 26 deletions(-)
fence/agents/apc/fence_apc.py +1 -2
index 451c616..71a3d3e 100644
@@ -175,12 +175,11 @@ def set_power_status(conn, options):
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 def get_power_status5(conn, options):
-	exp_result = 0
 	outlets = {}
 
 	conn.send_eol("olStatus all")
 
-	exp_result = conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	lines = conn.before.split("\n")
 
 	show_re = re.compile('^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
fence/agents/brocade/fence_brocade.py +1 -1
index b7a197e..018f3c0 100644
@@ -14,7 +14,7 @@ BUILD_DATE="March, 20013"
 def get_power_status(conn, options):
 	conn.send_eol("portCfgShow " + options["--plug"])
 
-	exp_result = conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
+	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
 	show_re = re.compile('^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
 	lines = conn.before.split("\n")
fence/agents/cisco_mds/fence_cisco_mds.py +1 -1
index 2bd6eae..f6eed64 100644
@@ -44,7 +44,7 @@ def cisco_port2oid(port):
 		fail_usage("Mangled port number: %s"%(port))
 
 def get_power_status(conn, options):
-	(oid, status) = conn.get(PORT_OID)
+	(_, status) = conn.get(PORT_OID)
 	return (status=="1" and "on" or "off")
 
 def set_power_status(conn, options):
fence/agents/cisco_ucs/fence_cisco_ucs.py +1 -1
index debefb4..9a8ed90 100644
@@ -40,7 +40,7 @@ def set_power_status(conn, options):
 		'off' : "down"
 	}[options["--action"]]
 
-	res = send_command(options, \
+	send_command(options, \
 		"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
 		"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] + "/power\">" + \
 		"<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
fence/agents/eps/fence_eps.py +1 -1
index 6e7cc1e..bd43e58 100644
@@ -83,7 +83,7 @@ def get_power_status(conn, options):
 		return result
 
 def set_power_status(conn, options):
-	ret_val = eps_run_command(options, "P%s=%s"%(options["--plug"], (options["--action"]=="on" and "1" or "0")))
+	eps_run_command(options, "P%s=%s"%(options["--plug"], (options["--action"]=="on" and "1" or "0")))
 
 # Define new option
 def eps_define_new_opts():
fence/agents/ifmib/fence_ifmib.py +1 -1
index ec5ab0c..e7d1fa5 100644
@@ -62,7 +62,7 @@ def get_power_status(conn, options):
 	if (port_num==None):
 		port_num = port2index(conn, options["--plug"])
 
-	(oid, status) = conn.get("%s.%d"%(STATUSES_OID, port_num))
+	(_, status) = conn.get("%s.%d"%(STATUSES_OID, port_num))
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
fence/agents/intelmodular/fence_intelmodular.py +1 -1
index d569d74..3d90707 100644
@@ -39,7 +39,7 @@ STATUS_SET_OFF = 3
 ### FUNCTIONS ###
 
 def get_power_status(conn, options):
-	(oid, status) = conn.get("%s.%s"% (STATUSES_OID, options["--plug"]))
+	(_, status) = conn.get("%s.%s"% (STATUSES_OID, options["--plug"]))
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
fence/agents/lib/fencing.py.py +1 -2
index 41f9087..be925d2 100644
@@ -461,7 +461,7 @@ def metadata(avail_opt, options, docs):
 	if docs.has_key("vendorurl"):
 		print "<vendor-url>" + docs["vendorurl"] + "</vendor-url>"
 	print "<parameters>"
-	for option, _value in sorted_list:
+	for option, _ in sorted_list:
 		if all_opt[option].has_key("shortdesc"):
 			print "\t<parameter name=\"" + option + "\" unique=\"0\" required=\"" + all_opt[option]["required"] + "\">"
 
@@ -918,7 +918,6 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 					# fence action was completed succesfully even in that case
 					sys.stderr.write(str(ex))
 					syslog.syslog(syslog.LOG_NOTICE, str(ex))
-					pass
 
 			if power_on == False:
 				# this should not fail as node was fenced succesfully
fence/agents/netio/fence_netio.py +1 -1
index 71c3014..5902e2e 100755
@@ -84,7 +84,7 @@ block any necessary fencing actions."
 		conn.send("set binary\n")
 		conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
 
-		screen = conn.read_nonblocking(size=100, timeout=int(options["--shell-timeout"]))
+		conn.read_nonblocking(size=100, timeout=int(options["--shell-timeout"]))
 		conn.log_expect(options, "100 HELLO .*", int(options["--shell-timeout"]))
 		conn.send_eol("login %s %s" % (options["--username"], options["--password"]))
 		conn.log_expect(options, "250 OK", int(options["--shell-timeout"]))
fence/agents/ovh/fence_ovh.py +1 -1
index 6becd8e..4d2d9cb 100644
@@ -70,7 +70,7 @@ def soap_login(options):
 	try:
 		soap = Client(url, doctor=d)
 		session = soap.service.login(options["--username"], options["--password"], 'en', 0)
-	except Exception, ex:
+	except Exception:
 		fail(EC_LOGIN_DENIED)
 
 	options["session"] = session
fence/agents/rhevm/fence_rhevm.py +1 -1
index e4a11de..9620c3a 100644
@@ -49,7 +49,7 @@ def set_power_status(conn, options):
 	}[options["--action"]]
 
 	url = "vms/" + options["id"] + "/" + action
-	res = send_command(options, url, "POST")
+	send_command(options, url, "POST")
 
 def get_list(conn, options):
 	outlets = { }
fence/agents/vmware_soap/fence_vmware_soap.py +10 -10
index cd56f9f..8110c9e 100644
@@ -41,8 +41,8 @@ def soap_login(options):
 		mo_SessionManager = Property(ServiceContent.sessionManager.value)
 		mo_SessionManager._type = 'SessionManager'
 
-		SessionManager = conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
-	except Exception, ex:
+		conn.service.Login(mo_SessionManager, options["--username"], options["--password"])
+	except Exception:
 		fail(EC_LOGIN_DENIED)
 
 	options["ServiceContent"] = ServiceContent
@@ -99,7 +99,7 @@ def get_power_status(conn, options):
 
 	try:
 		raw_machines = conn.service.RetrievePropertiesEx(mo_PropertyCollector, propFilterSpec)
-	except Exception, ex:
+	except Exception:
 		fail(EC_STATUS)
 
 	(machines, uuid, mappingToUUID) = process_results(raw_machines, {}, {}, {})
@@ -108,7 +108,7 @@ def get_power_status(conn, options):
 	while (hasattr(raw_machines, 'token') == True):
 		try:
 			raw_machines = conn.service.ContinueRetrievePropertiesEx(mo_PropertyCollector, raw_machines.token)
-		except Exception, ex:
+		except Exception:
 			fail(EC_STATUS)
 		(more_machines, more_uuid, more_mappingToUUID) = process_results(raw_machines, {}, {}, {})
 		machines.update(more_machines)
@@ -131,18 +131,18 @@ def get_power_status(conn, options):
 
 				try:
 					options["--uuid"] = mappingToUUID[vm.value]
-				except KeyError, ex:
+				except KeyError:
 					fail(EC_STATUS)
-				except AttributeError, ex:
+				except AttributeError:
 					fail(EC_STATUS)
 			else:
 				## Name of virtual machine instead of path
 				## warning: if you have same names of machines this won't work correctly
 				try:
 					(options["--uuid"], _) = machines[options["--plug"]]
-				except KeyError, ex:
+				except KeyError:
 					fail(EC_STATUS)
-				except AttributeError, ex:
+				except AttributeError:
 					fail(EC_STATUS)
 
 		try:
@@ -150,7 +150,7 @@ def get_power_status(conn, options):
 				return "on"
 			else:
 				return "off"
-		except KeyError, ex:
+		except KeyError:
 			fail(EC_STATUS)
 
 def set_power_status(conn, options):
@@ -216,7 +216,7 @@ Alternatively you can always use UUID to access virtual machine."
 	#####
 	try:
 		conn.service.Logout(options["mo_SessionManager"])
-	except Exception, ex:
+	except Exception:
 		pass
 
 	sys.exit(result)
fence/agents/wti/fence_wti.py +0 -2
index 5157335..9b7aa39 100644
@@ -87,9 +87,7 @@ def get_plug_group_status_from_list(status_list):
 def get_plug_group_status(conn, options):
 	listing = get_listing(conn, options, "/SG")
 
-	plug_section = 0
 	outlets = {}
-	current_outlet = ""
 	line_index = 0
 	lines = listing.splitlines()
 	while line_index < len(lines) and line_index >= 0:
fence/agents/xenapi/fence_xenapi.py +1 -1
index 509dd8b..8b9857c 100644
@@ -166,7 +166,7 @@ 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:
+		except Exception:
 			if verbose:
 				print "No VM's found with a UUID of \"%s\"" % uuid
 			raise
Signature · 1 line
1.9.0
#3 lore raw

PATCH 4/15 Split lines that were too long

In reply to Marek 'marx' Grac
---
 fence/agents/amt/fence_amt.py                   |  3 +-
 fence/agents/apc/fence_apc.py                   |  6 ++-
 fence/agents/apc_snmp/fence_apc_snmp.py         | 15 +++---
 fence/agents/cisco_ucs/fence_cisco_ucs.py       | 29 ++++++-----
 fence/agents/drac5/fence_drac5.py               |  3 +-
 fence/agents/eaton_snmp/fence_eaton_snmp.py     |  3 +-
 fence/agents/ibmblade/fence_ibmblade.py         |  3 +-
 fence/agents/ilo/fence_ilo.py                   |  6 ++-
 fence/agents/intelmodular/fence_intelmodular.py |  3 +-
 fence/agents/ipmilan/fence_ipmilan.py           |  3 +-
 fence/agents/lib/fencing.py.py                  | 67 +++++++++++++++++--------
 fence/agents/lib/fencing_snmp.py.py             | 19 ++++---
 fence/agents/lpar/fence_lpar.py                 |  6 ++-
 fence/agents/ovh/fence_ovh.py                   | 15 ++++--
 fence/agents/sanbox2/fence_sanbox2.py           |  3 +-
 fence/agents/virsh/fence_virsh.py               |  6 ++-
 fence/agents/vmware/fence_vmware.py             | 15 ++++--
 fence/agents/vmware_soap/fence_vmware_soap.py   |  3 +-
 fence/agents/wti/fence_wti.py                   | 10 ++--
 19 files changed, 140 insertions(+), 78 deletions(-)
fence/agents/amt/fence_amt.py +2 -1
index 55e3e5b..51022ee 100644
@@ -103,7 +103,8 @@ def define_new_opts():
 	all_opt["boot_option"] = {
 		"getopt" : "b:",
 		"longopt" : "boot-option",
-		"help" : "-b, --boot-option=[option]     Change the default boot behavior of the machine. (pxe|hd|hdsafe|cd|diag)",
+		"help" : "-b, --boot-option=[option]     "
+				"Change the default boot behavior of the machine. (pxe|hd|hdsafe|cd|diag)",
 		"required" : "0",
 		"shortdesc" : "Change the default boot behavior of the machine.",
 		"choices" : ["pxe", "hd", "hdsafe", "cd", "diag"],
fence/agents/apc/fence_apc.py +4 -2
index 71a3d3e..b97bbff 100644
@@ -69,7 +69,8 @@ def get_power_status(conn, options):
 		conn.send_eol(options["--switch"])
 
 	while True:
-		exp_result = conn.log_expect(options, ["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
+		exp_result = conn.log_expect(options,
+				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
 		show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
 		for x in lines:
@@ -147,7 +148,8 @@ def set_power_status(conn, options):
 	else:
 		conn.send_eol(options["--switch"])
 
-	while 0 == conn.log_expect(options, [ "Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"])):
+	while 0 == conn.log_expect(options,
+			[ "Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"])):
 		conn.send_eol("")
 
 	conn.send_eol(options["--plug"]+"")
fence/agents/apc_snmp/fence_apc_snmp.py +9 -6
index 971919a..b07d04a 100644
@@ -1,12 +1,15 @@
 #!/usr/bin/python
 
 # The Following agent has been tested on:
-# - 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_aos_270.bin
-#    AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin MN:AP7930 HR:B2) - SNMP v1
-# - APC Web/SNMP Management Card (MB:v3.8.6 PF:v3.5.8 PN:apc_hw02_aos_358.bin AF1:v3.5.7 AN1:apc_hw02_aos_358.bin
-#    AF1:v3.5.7 AN1:apc_hw02_rpdu_357.bin MN:AP7900 HR:B2) - SNMP v1 and v3 (noAuthNoPrivacy,authNoPrivacy, authPrivacy)
-# - 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
+# - APC Switched Rack PDU - SNMP v1
+#	(MB:v3.7.0 PF:v2.7.0 PN:apc_hw02_aos_270.bin AF1:v2.7.3
+#	AN1:apc_hw02_aos_270.bin AF1:v2.7.3 AN1:apc_hw02_rpdu_273.bin MN:AP7930 HR:B2)
+# - APC Web/SNMP Management Card - SNMP v1 and v3 (noAuthNoPrivacy,authNoPrivacy, authPrivacy)
+#	(MB:v3.8.6 PF:v3.5.8 PN:apc_hw02_aos_358.bin AF1:v3.5.7
+#       AN1:apc_hw02_aos_358.bin AF1:v3.5.7 AN1:apc_hw02_rpdu_357.bin MN:AP7900 HR:B2)
+# - APC Switched Rack PDU - SNMP v1
+#       (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)
 # - Tripplite PDUMH20HVNET 12.04.0055 - SNMP v1, v2c, v3
 
 import sys
fence/agents/cisco_ucs/fence_cisco_ucs.py +14 -15
index 9a8ed90..388eda9 100644
@@ -18,10 +18,9 @@ RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
 RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
 
 def get_power_status(conn, options):
-	res = send_command(options, \
-		"<configResolveDn cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" dn=\"org-root" + options["--suborg"] + \
-		"/ls-" + options["--plug"] + "/power\"/>", \
-		 int(options["--shell-timeout"]))
+	res = send_command(options, "<configResolveDn cookie=\"" + options["cookie"] +
+			"\" inHierarchical=\"false\" dn=\"org-root" + options["--suborg"] + "/ls-" +
+			options["--plug"] + "/power\"/>", int(options["--shell-timeout"]))
 
 	result = RE_STATUS.search(res)
 	if (result == None):
@@ -40,12 +39,11 @@ def set_power_status(conn, options):
 		'off' : "down"
 	}[options["--action"]]
 
-	send_command(options, \
-		"<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" + \
-		"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] + "/power\">" + \
-		"<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" + action + "\" status=\"modified\" />" + \
-		"</pair></inConfigs></configConfMos>", \
-		int(options["--shell-timeout"]))
+	send_command(options, "<configConfMos cookie=\"" + options["cookie"] + "\" inHierarchical=\"no\">" +
+			"<inConfigs><pair key=\"org-root" + options["--suborg"] + "/ls-" + options["--plug"] +
+			"/power\">" + "<lsPower dn=\"org-root/ls-" + options["--plug"] + "/power\" state=\"" +
+			action + "\" status=\"modified\" />" + "</pair></inConfigs></configConfMos>",
+			int(options["--shell-timeout"]))
 
 	return
 
@@ -53,9 +51,8 @@ def get_list(conn, options):
 	outlets = { }
 
 	try:
-		res = send_command(options, \
-			"<configResolveClass cookie=\"" + options["cookie"] + "\" inHierarchical=\"false\" classId=\"lsServer\"/>", \
-			int(options["--shell-timeout"]))
+		res = send_command(options, "<configResolveClass cookie=\"" + options["cookie"] +
+				"\" inHierarchical=\"false\" classId=\"lsServer\"/>", int(options["--shell-timeout"]))
 
 		lines = res.split("<lsServer ")
 		for i in range(1, len(lines)):
@@ -130,7 +127,8 @@ used with Cisco UCS to fence machines."
 
 	### Login
 	try:
-		res = send_command(options, "<aaaLogin inName=\"" + options["--username"] + "\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
+		res = send_command(options, "<aaaLogin inName=\"" + options["--username"] +
+				"\" inPassword=\"" + options["--password"] + "\" />", int(options["--login-timeout"]))
 		result = RE_COOKIE.search(res)
 		if (result == None):
 			## Cookie is absenting in response
@@ -151,7 +149,8 @@ used with Cisco UCS to fence machines."
 	result = fence_action(None, options, set_power_status, get_power_status, get_list)
 
 	### Logout; we do not care about result as we will end in any case
-	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />", int(options["--shell-timeout"]))
+	send_command(options, "<aaaLogout inCookie=\"" + options["cookie"] + "\" />",
+			int(options["--shell-timeout"]))
 
 	sys.exit(result)
 
fence/agents/drac5/fence_drac5.py +2 -1
index 20e2e8a..036f294 100644
@@ -34,7 +34,8 @@ def get_power_status(conn, options):
 
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-		status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
+		status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$",
+				re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
 
 	if status.lower().strip() in ["on", "powering on", "powering off"]:
 		return "on"
fence/agents/eaton_snmp/fence_eaton_snmp.py +2 -1
index 0497c75..a329aeb 100644
@@ -177,7 +177,8 @@ def get_outlets_status(conn, options):
 		# 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
fence/agents/ibmblade/fence_ibmblade.py +2 -1
index 4567861..1e60e7d 100644
@@ -32,7 +32,8 @@ def get_power_status(conn, options):
 	return (status == str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(CONTROL_OID, options["--plug"]), (options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
+	conn.set("%s.%s"%(CONTROL_OID, options["--plug"]),
+			(options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
 
 def get_outlets_status(conn, _):
 	result = {}
fence/agents/ilo/fence_ilo.py +4 -2
index a04aacf..48c829d 100644
@@ -110,8 +110,10 @@ the iLO card through an XML stream."
 			conn.send("</RIB_INFO>\r\n")
 			conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
 			conn.log_expect(options, "/>", int(options["--shell-timeout"]))
-			options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1))
-			options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
+			options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"",
+					re.IGNORECASE).search(conn.before).group(1))
+			options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"",
+					re.IGNORECASE).search(conn.before).group(1)
 		conn.send("</LOGIN>\r\n")
 	except pexpect.TIMEOUT:
 		fail(EC_LOGIN_DENIED)
fence/agents/intelmodular/fence_intelmodular.py +2 -1
index 3d90707..bd1faee 100644
@@ -43,7 +43,8 @@ def get_power_status(conn, options):
 	return (status==str(STATUS_UP) and "on" or "off")
 
 def set_power_status(conn, options):
-	conn.set("%s.%s"%(STATUSES_OID, options["--plug"]), (options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
+	conn.set("%s.%s" % (STATUSES_OID, options["--plug"]),
+			(options["--action"]=="on" and STATUS_SET_ON or STATUS_SET_OFF))
 
 def get_outlets_status(conn, options):
 	result = {}
fence/agents/ipmilan/fence_ipmilan.py +2 -1
index ab5a75a..7b37194 100644
@@ -143,7 +143,8 @@ def define_new_opts():
 	all_opt["privlvl"] = {
 		"getopt" : "L:",
 		"longopt" : "privlvl",
-		"help" : "-L, --privlvl=[level]          Privilege level on IPMI device (callback|user|operator|administrator)",
+		"help" : "-L, --privlvl=[level]          "
+				"Privilege level on IPMI device (callback|user|operator|administrator)",
 		"required" : "0",
 		"shortdesc" : "Privilege level on IPMI device",
 		"default" : "administrator",
fence/agents/lib/fencing.py.py +45 -22

177 lines not on this page · raw message

fence/agents/lib/fencing_snmp.py.py +13 -6
index 0112494..3faa295 100644
@@ -29,10 +29,13 @@ class FencingSnmp:
 		return ''.join(map(lambda x:x==r"'" and "'\\''" or x, string))
 
 	def complete_missed_params(self):
-		mapping = [
-			[['snmp-priv-passwd','password','!snmp-sec-level'],'self.options["--snmp-sec-level"]="authPriv"'],
-			[['!snmp-version','community','!username','!snmp-priv-passwd','!password'],'self.options["--snmp-version"]="2c"']
-			]
+		mapping = [[
+					['snmp-priv-passwd','password','!snmp-sec-level'],
+					'self.options["--snmp-sec-level"]="authPriv"'
+				],[
+					['!snmp-version','community','!username','!snmp-priv-passwd','!password'],
+					'self.options["--snmp-version"]="2c"'
+				]]
 
 		for val in mapping:
 			e = val[0]
@@ -88,7 +91,10 @@ class FencingSnmp:
 		try:
 			self.log_command(command)
 
-			(res_output, res_code) = pexpect.run(command, int(self.options["--shell-timeout"]) + int(self.options["--login-timeout"]) + additional_timemout, True)
+			(res_output, res_code) = pexpect.run(command,
+					int(self.options["--shell-timeout"]) +
+					int(self.options["--login-timeout"]) +
+					additional_timemout, True)
 
 			if (res_code==None):
 				fail(EC_TIMED_OUT)
@@ -119,7 +125,8 @@ class FencingSnmp:
 				type_of_value = item[1]
 				break
 
-		cmd = "%s '%s' %s '%s'"% (self.prepare_cmd("snmpset"), self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value)))
+		cmd = "%s '%s' %s '%s'" % (self.prepare_cmd("snmpset"),
+				self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value)))
 
 		self.run_command(cmd, additional_timemout)
 
fence/agents/lpar/fence_lpar.py +4 -2
index c4237f2..438acae 100644
@@ -27,11 +27,13 @@ def get_power_status(conn, options):
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 		try:
-			status = re.compile("^" + options["--plug"] + ",(.*?),.*$", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+			status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
+					re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 		except AttributeError:
 			fail(EC_STATUS_HMC)
 	elif options["--hmc-version"] == "4":
-		conn.send("lssyscfg -r lpar -m "+ options["--managed"] +" --filter 'lpar_names=" + options["--plug"] + "'\n")
+		conn.send("lssyscfg -r lpar -m "+ options["--managed"] +
+				" --filter 'lpar_names=" + options["--plug"] + "'\n")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 
 		try:
fence/agents/ovh/fence_ovh.py +10 -5
index 4d2d9cb..647343c 100644
@@ -40,7 +40,8 @@ def netboot_reboot(options, mode):
 	conn.service.dedicatedNetbootModifyById(options["session"], options["--plug"], mode, '', options["--email"])
 
 	# dedicatedHardRebootDo initiates a hard reboot on the given node
-	conn.service.dedicatedHardRebootDo(options["session"], options["--plug"], 'Fencing initiated by cluster', '', 'en')
+	conn.service.dedicatedHardRebootDo(options["session"],
+			options["--plug"], 'Fencing initiated by cluster', '', 'en')
 
 	conn.logout(options["session"])
 
@@ -124,10 +125,14 @@ Poweroff is simulated with a reboot into rescue-pro mode."
 	reboot_t = reboot_time(options)
 
 	if options.has_key("--verbose"):
-		options["debug_fh"].write("reboot_start_end.start: "+ reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("before_netboot_reboot: " + before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("reboot_start_end.end: "  + reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")
-		options["debug_fh"].write("after_netboot_reboot: "  + after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("reboot_start_end.start: " +
+				reboot_t.start.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("before_netboot_reboot: " +
+				before_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("reboot_start_end.end: " +
+				reboot_t.end.strftime('%Y-%m-%d %H:%M:%S')+"\n")
+		options["debug_fh"].write("after_netboot_reboot: " +
+				after_netboot_reboot.strftime('%Y-%m-%d %H:%M:%S')+"\n")
 
 	if reboot_t.start < after_netboot_reboot < reboot_t.end:
 		result = 0
fence/agents/sanbox2/fence_sanbox2.py +2 -1
index 86b646b..e0c0647 100644
@@ -36,7 +36,8 @@ def get_power_status(conn, options):
 			pass
 		fail(EC_TIMED_OUT)
 
-	status = re.compile(".*AdminState\s+(online|offline)\s+", re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
+	status = re.compile(".*AdminState\s+(online|offline)\s+",
+			re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 
 	try:
 		return status_trans[status.lower().strip()]
fence/agents/virsh/fence_virsh.py +4 -2
index 0ebf668..29d3e58 100644
@@ -40,7 +40,8 @@ def get_outlets_status(conn, options):
 			if ((fa_status==0) and (domain.group(1).lower()=="id") and (domain.group(2).lower()=="name")):
 				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):
@@ -58,7 +59,8 @@ def get_power_status(conn, options):
 
 def set_power_status(conn, options):
 	prefix = SUDO_PATH + " " if options.has_key("--use-sudo") else ""
-	conn.sendline(prefix + "virsh %s "%(options["--action"] == "on" and "start" or "destroy") + get_name_or_uuid(options))
+	conn.sendline(prefix + "virsh %s " %
+			(options["--action"] == "on" and "start" or "destroy") + get_name_or_uuid(options))
 
 	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 	time.sleep(int(options["--power-wait"]))
fence/agents/vmware/fence_vmware.py +10 -5
index c6209e8..8b76103 100644
@@ -149,7 +149,8 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
 	try:
 		vmware_log(options, command)
 
-		(res_output, res_code) = pexpect.run(command, int(options["--shell-timeout"])+int(options["--login-timeout"])+additional_timeout, True)
+		(res_output, res_code) = pexpect.run(command,
+				int(options["--shell-timeout"]) + int(options["--login-timeout"]) + additional_timeout, True)
 
 		if (res_code==None):
 			fail(EC_TIMED_OUT)
@@ -170,7 +171,8 @@ def vmware_get_outlets_vi(conn, options, add_vm_name):
 	outlets = {}
 
 	if (add_vm_name):
-		all_machines = vmware_run_command(options, True, ("--operation status --vmname '%s'"% (quote_for_run(options["--plug"]))), 0)
+		all_machines = vmware_run_command(options, True,
+				("--operation status --vmname '%s'"% (quote_for_run(options["--plug"]))), 0)
 	else:
 		all_machines = vmware_run_command(options, True, "--operation list", int(options["--power-timeout"]))
 
@@ -232,9 +234,11 @@ 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["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
+		additional_params = "--operation %s --vmname '%s'" % \
+				((options["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
 	elif ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
-		additional_params = "%s '%s'"% ((options["--action"]=="on" and "start" or "stop"), quote_for_run(options["--plug"]))
+		additional_params = "%s '%s'" % \
+				((options["--action"]=="on" and "start" or "stop"), quote_for_run(options["--plug"]))
 		if (options["--action"]=="off"):
 			additional_params += " hard"
 
@@ -323,7 +327,8 @@ This agent supports only vmrun from version 2.0.0 (VIX API 1.6.0)."
 	# Test user vmrun command version
 	if ((vmware_internal_type==VMWARE_TYPE_SERVER1) or (vmware_internal_type==VMWARE_TYPE_SERVER2)):
 		if (not (vmware_is_supported_vmrun_version(options))):
-			fail_usage("Unsupported version of vmrun command! You must use at least version %d!"%(VMRUN_MINIMUM_REQUIRED_VERSION))
+			fail_usage("Unsupported version of vmrun command! You must use@least version %d!" %
+					(VMRUN_MINIMUM_REQUIRED_VERSION))
 
 	# Operate the fencing device
 	result = fence_action(None, options, set_power_status, get_power_status, get_outlets_status)
fence/agents/vmware_soap/fence_vmware_soap.py +2 -1
index 8110c9e..6fa3cd6 100644
@@ -73,7 +73,8 @@ def get_power_status(conn, options):
 	mo_PropertyCollector = Property(options["ServiceContent"].propertyCollector.value)
 	mo_PropertyCollector._type = 'PropertyCollector'
 
-	ContainerView = conn.service.CreateContainerView(mo_ViewManager, recursive = 1, container = mo_RootFolder, type = ['VirtualMachine'])
+	ContainerView = conn.service.CreateContainerView(mo_ViewManager, recursive = 1,
+			container = mo_RootFolder, type = ['VirtualMachine'])
 	mo_ContainerView = Property(ContainerView.value)
 	mo_ContainerView._type = "ContainerView"
 
fence/agents/wti/fence_wti.py +7 -3
index 9b7aa39..1cb3356 100644
@@ -58,7 +58,8 @@ def get_plug_status(conn, options):
 			plug_line = [x.strip().lower() for x in line.split("|")]
 			if len(plug_line) < len(plug_header):
 				plug_section = -1
-			if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[plug_index]:
+			if ["list", "monitor"].count(options["--action"]) == 0 and \
+					options["--plug"].lower() == plug_line[plug_index]:
 				return plug_line[status_index]
 			else:
 				## We already believe that first column contains plug number
@@ -94,11 +95,14 @@ def get_plug_group_status(conn, options):
 		line = lines[line_index]
 		if (line.find("|") >= 0 and line.lstrip().startswith("GROUP NAME") == False):
 			plug_line = [x.strip().lower() for x in line.split("|")]
-			if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[name_index]:
+			if ["list", "monitor"].count(options["--action"]) == 0 and \
+					options["--plug"].lower() == plug_line[name_index]:
 				plug_status = []
 				while line_index < len(lines) and line_index >= 0:
 					plug_line = [x.strip().lower() for x in lines[line_index].split("|")]
-					if len(plug_line) >= max(name_index, status_index) and len(plug_line[plug_index]) > 0 and (len(plug_line[name_index]) == 0 or options["--plug"].lower() == plug_line[name_index]):
+					if len(plug_line) >= max(name_index, status_index) and \
+							len(plug_line[plug_index]) > 0 and \
+							(len(plug_line[name_index]) == 0 or options["--plug"].lower() == plug_line[name_index]):
 						## Firmware 1.43 does not have a valid value of plug on first line as only name is defined on that line
 						if not "---" in plug_line[status_index]:
 							plug_status.append(plug_line[status_index])
Signature · 1 line
1.9.0
#4 lore raw

PATCH 5/15 Remove unused dependencies

In reply to Marek 'marx' Grac
---
 fence/agents/alom/fence_alom.py               | 2 +-
 fence/agents/amt/fence_amt.py                 | 2 +-
 fence/agents/apc/fence_apc.py                 | 2 +-
 fence/agents/bladecenter/fence_bladecenter.py | 2 +-
 fence/agents/brocade/fence_brocade.py         | 2 +-
 fence/agents/drac/fence_drac.py               | 2 +-
 fence/agents/drac5/fence_drac5.py             | 2 +-
 fence/agents/dummy/fence_dummy.py             | 2 +-
 fence/agents/hds_cb/fence_hds_cb.py           | 2 +-
 fence/agents/hpblade/fence_hpblade.py         | 2 +-
 fence/agents/ilo_mp/fence_ilo_mp.py           | 2 +-
 fence/agents/ipmilan/fence_ipmilan.py         | 2 +-
 fence/agents/lpar/fence_lpar.py               | 2 +-
 fence/agents/netio/fence_netio.py             | 2 +-
 fence/agents/rsa/fence_rsa.py                 | 2 +-
 fence/agents/rsb/fence_rsb.py                 | 2 +-
 fence/agents/virsh/fence_virsh.py             | 2 +-
 fence/agents/vmware/fence_vmware.py           | 2 +-
 fence/agents/vmware_soap/fence_vmware_soap.py | 2 +-
 fence/agents/wti/fence_wti.py                 | 2 +-
 20 files changed, 20 insertions(+), 20 deletions(-)
fence/agents/alom/fence_alom.py +1 -1
index ae484a4..2844904 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, exceptions
+import sys, re, time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/amt/fence_amt.py +1 -1
index 51022ee..1286bd9 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, subprocess, re, os, stat
+import sys, subprocess, re
 import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
fence/agents/apc/fence_apc.py +1 -1
index b97bbff..d976be6 100644
@@ -14,7 +14,7 @@
 ##        cipher (des/blowfish) have to be defined
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/bladecenter/fence_bladecenter.py +1 -1
index d3a0301..e94fd7d 100644
@@ -12,7 +12,7 @@
 ##
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/brocade/fence_brocade.py +1 -1
index 018f3c0..9e37e49 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/drac/fence_drac.py +1 -1
index 90314f4..ba08ee7 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/drac5/fence_drac5.py +1 -1
index 036f294..b95b1c7 100644
@@ -12,7 +12,7 @@
 ## @note: drac_version was removed
 #####
 
-import sys, re, pexpect, exceptions, time
+import sys, re, time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/dummy/fence_dummy.py +1 -1
index cc136d4..fb79b1a 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions, random
+import sys, random
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/hds_cb/fence_hds_cb.py +1 -1
index d8046b1..78754fc 100755
@@ -10,7 +10,7 @@
 ##
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/hpblade/fence_hpblade.py +1 -1
index e2de148..84e0b0b 100644
@@ -6,7 +6,7 @@
 ##  * BladeSystem c7000 Enclosure
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/ilo_mp/fence_ilo_mp.py +1 -1
index 5bb234b..c76c281 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/ipmilan/fence_ipmilan.py +1 -1
index 7b37194..7254c73 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, shlex, stat, subprocess, re, os
+import sys, shlex, subprocess, re, os
 import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
fence/agents/lpar/fence_lpar.py +1 -1
index 438acae..05e9b28 100644
@@ -10,7 +10,7 @@
 ##
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/netio/fence_netio.py +1 -1
index 5902e2e..e483470 100755
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, re, pexpect
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/rsa/fence_rsa.py +1 -1
index 992c5e6..4e855a2 100644
@@ -7,7 +7,7 @@
 ##
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/rsb/fence_rsb.py +1 -1
index 6c5e119..89fb304 100755
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/virsh/fence_virsh.py +1 -1
index 29d3e58..170c089 100644
@@ -5,7 +5,7 @@
 # Virsh 0.3.3 on RHEL 5.2 with xen-3.0.3-51
 #
 
-import sys, re, pexpect, exceptions
+import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/vmware/fence_vmware.py +1 -1
index 8b76103..f278698 100644
@@ -22,7 +22,7 @@
 #	VMware vCenter 4.0.0
 #
 
-import sys, re, pexpect, exceptions
+import sys, re, pexpect
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
fence/agents/vmware_soap/fence_vmware_soap.py +1 -1
index 6fa3cd6..b55b56c 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import sys, exceptions, time
+import sys, time
 import shutil, tempfile, suds
 import logging
 import atexit
fence/agents/wti/fence_wti.py +1 -1
index 1cb3356..bcb287b 100644
@@ -11,7 +11,7 @@
 ##  WTI IPS-800-CE     v1.40h		(no username) ('list' tested)
 #####
 
-import sys, re, pexpect, exceptions
+import sys, re, pexpect
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
Signature · 1 line
1.9.0
#5 lore raw

PATCH 6/15 Remove problems with redefining variables/functions

In reply to Marek 'marx' Grac
---
 fence/agents/eps/fence_eps.py       |  4 ++--
 fence/agents/ifmib/fence_ifmib.py   |  4 ++--
 fence/agents/ipdu/fence_ipdu.py     |  2 ++
 fence/agents/lib/fencing.py.py      | 11 +++--------
 fence/agents/vmware/fence_vmware.py |  4 ++--
 5 files changed, 11 insertions(+), 14 deletions(-)
fence/agents/eps/fence_eps.py +2 -2
index bd43e58..42e2be7 100644
@@ -16,9 +16,9 @@ BUILD_DATE=""
 #END_VERSION_GENERATION
 
 # Log actions and results from EPS device
-def eps_log(options, str):
+def eps_log(options, text):
 	if options["log"] >= LOG_MODE_VERBOSE:
-		options["debug_fh"].write(str)
+		options["debug_fh"].write(text)
 
 # Run command on EPS device.
 # @param options Device options
fence/agents/ifmib/fence_ifmib.py +2 -2
index e7d1fa5..1273b0e 100644
@@ -85,10 +85,10 @@ def get_outlets_status(conn, options):
 	res_aliases = array_to_dict(conn.walk(ALIASES_OID, 30))
 
 	for x in res_fc:
-		port_num = x[0].split('.')[-1]
+		port_number = 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_alias = (res_aliases.has_key(port_number) and res_aliases[port_number].strip('"') or "")
 		port_status = ""
 		result[port_name] = (port_alias, port_status)
 
fence/agents/ipdu/fence_ipdu.py +2 -0
index b90a333..c1fc368 100644
@@ -126,6 +126,8 @@ def get_outlets_status(conn, options):
 
 # Main agent method
 def main():
+	global device
+
 	device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
 		       "port", "snmp_version", "community" ]
 
fence/agents/lib/fencing.py.py +3 -8
index a713dc8..6aab45b 100644
@@ -408,11 +408,6 @@ def add_dependency_options(options):
 			added_opt.extend([y for y in DEPENDENCY_OPT[x] if options.count(y) == 0])
 	return added_opt
 
-def version(command, release, build_date, copyright_notice):
-	print command, " ", release, " ", build_date
-	if len(copyright_notice) > 0:
-		print copyright_notice
-
 def fail_usage(message = ""):
 	if len(message) > 0:
 		sys.stderr.write(message+"\n")
@@ -757,10 +752,10 @@ def check_input(device_opt, opt):
 
 	for opt in device_opt:
 		if all_opt[opt].has_key("choices"):
-			long = "--" + all_opt[opt]["longopt"]
+			longopt = "--" + all_opt[opt]["longopt"]
 			possible_values_upper = map (lambda y : y.upper(), all_opt[opt]["choices"])
-			if options.has_key(long):
-				options[long] = options[long].upper()
+			if options.has_key(longopt):
+				options[longopt] = options[longopt].upper()
 				if not options["--" + all_opt[opt]["longopt"]] in possible_values_upper:
 					fail_usage("Failed: You have to enter a valid choice " + \
 							"for %s from the valid values: %s" % \
fence/agents/vmware/fence_vmware.py +2 -2
index f278698..f0f6023 100644
@@ -94,10 +94,10 @@ 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):
+def quote_for_run(text):
 	dstr = ''
 
-	for c in str:
+	for c in text:
 		if c == r"'":
 			dstr += "'\\''"
 		else:
Signature · 1 line
1.9.0
#6 lore raw

PATCH 7/15 Only symbols that should be used are exported from fencing library

In reply to Marek 'marx' Grac

Previously, all symbols were exported what ends with redefining some symbols. Currently, the wildcard (from fencing import *) imports only those that should be used. Rest of them make sense for some fence agents (e.g. TELNET_PATH if we are not able to use regular fence_login) but there are some symbols which have to be used before but they are not needed now. This will be solved later.

---
 fence/agents/amt/fence_amt.py                 | 1 +
 fence/agents/apc/fence_apc.py                 | 1 +
 fence/agents/bladecenter/fence_bladecenter.py | 1 +
 fence/agents/brocade/fence_brocade.py         | 1 +
 fence/agents/cisco_mds/fence_cisco_mds.py     | 1 +
 fence/agents/cisco_ucs/fence_cisco_ucs.py     | 2 ++
 fence/agents/drac5/fence_drac5.py             | 1 +
 fence/agents/dummy/fence_dummy.py             | 2 ++
 fence/agents/eps/fence_eps.py                 | 1 +
 fence/agents/hpblade/fence_hpblade.py         | 1 +
 fence/agents/ifmib/fence_ifmib.py             | 1 +
 fence/agents/ilo/fence_ilo.py                 | 1 +
 fence/agents/ipmilan/fence_ipmilan.py         | 1 +
 fence/agents/ldom/fence_ldom.py               | 1 +
 fence/agents/lib/fencing.py.py                | 3 +++
 fence/agents/lib/fencing_snmp.py.py           | 1 +
 fence/agents/lpar/fence_lpar.py               | 1 +
 fence/agents/netio/fence_netio.py             | 1 +
 fence/agents/ovh/fence_ovh.py                 | 1 +
 fence/agents/rhevm/fence_rhevm.py             | 1 +
 fence/agents/sanbox2/fence_sanbox2.py         | 1 +
 fence/agents/virsh/fence_virsh.py             | 2 ++
 fence/agents/vmware/fence_vmware.py           | 1 +
 fence/agents/vmware_soap/fence_vmware_soap.py | 1 +
 fence/agents/wti/fence_wti.py                 | 2 ++
 25 files changed, 31 insertions(+)
fence/agents/amt/fence_amt.py +1 -0
index 1286bd9..346677e 100644
@@ -5,6 +5,7 @@ import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage, is_executable, SUDO_PATH, LOG_MODE_VERBOSE
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Fence agent for Intel AMT"
fence/agents/apc/fence_apc.py +1 -0
index d976be6..76b544b 100644
@@ -18,6 +18,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, fail_usage, EC_STATUS
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New APC Agent - test release on steroids"
fence/agents/bladecenter/fence_bladecenter.py +1 -0
index e94fd7d..34a8975 100644
@@ -16,6 +16,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_STATUS, EC_GENERIC_ERROR
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Bladecenter Agent - test release on steroids"
fence/agents/brocade/fence_brocade.py +1 -0
index 9e37e49..2deab5b 100644
@@ -4,6 +4,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_STATUS
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Brocade Agent - test release on steroids"
fence/agents/cisco_mds/fence_cisco_mds.py +1 -0
index f6eed64..6af1e99 100644
@@ -10,6 +10,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage
 from fencing_snmp import *
 
 #BEGIN_VERSION_GENERATION
fence/agents/cisco_ucs/fence_cisco_ucs.py +2 -0
index 388eda9..81a911e 100644
@@ -2,9 +2,11 @@
 
 import sys, re
 import pycurl, StringIO
+import time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, LOG_MODE_VERBOSE
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Cisco UCS Agent - test release on steroids"
fence/agents/drac5/fence_drac5.py +1 -0
index b95b1c7..642dcda 100644
@@ -16,6 +16,7 @@ import sys, re, time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Drac5 Agent - test release on steroids"
fence/agents/dummy/fence_dummy.py +2 -0
index fb79b1a..dc65bee 100644
@@ -1,9 +1,11 @@
 #!/usr/bin/python
 
 import sys, random
+import time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Dummy Agent - test release on steroids"
fence/agents/eps/fence_eps.py +1 -0
index 42e2be7..3c4be8d 100644
@@ -8,6 +8,7 @@ import httplib, base64, string, socket
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, fail_usage, EC_LOGIN_DENIED, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="ePowerSwitch 8M+ (eps)"
fence/agents/hpblade/fence_hpblade.py +1 -0
index 84e0b0b..44032d3 100644
@@ -10,6 +10,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_STATUS
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Bladecenter Agent - test release on steroids"
fence/agents/ifmib/fence_ifmib.py +1 -0
index 1273b0e..3ecc85d 100644
@@ -12,6 +12,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage
 from fencing_snmp import *
 
 #BEGIN_VERSION_GENERATION
fence/agents/ilo/fence_ilo.py +1 -0
index 48c829d..8171958 100644
@@ -16,6 +16,7 @@ import atexit
 from xml.sax.saxutils import quoteattr
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_LOGIN_DENIED
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New ILO Agent - test release on steroids"
fence/agents/ipmilan/fence_ipmilan.py +1 -0
index 7254c73..c5cab2b 100644
@@ -5,6 +5,7 @@ import atexit
 from pipes import quote
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import SUDO_PATH, LOG_MODE_VERBOSE, fail_usage, is_executable
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION=""
fence/agents/ldom/fence_ldom.py +1 -0
index 1bf1c49..ffa8fe4 100644
@@ -11,6 +11,7 @@ import sys, re, pexpect, exceptions
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Logical Domains (LDoms) fence Agent"
fence/agents/lib/fencing.py.py +3 -0
index 6aab45b..40ee919 100644
@@ -11,6 +11,9 @@ REDHAT_COPYRIGHT = ""
 BUILD_DATE = "March, 2008"
 #END_VERSION_GENERATION
 
+__all__ = [ 'atexit_handler', 'check_input', 'process_input', 'all_opt', 'show_docs',
+		'fence_login', 'fence_action' ]
+
 LOG_MODE_VERBOSE = 100
 LOG_MODE_QUIET = 0
 
fence/agents/lib/fencing_snmp.py.py +1 -0
index 3faa295..a081052 100644
@@ -4,6 +4,7 @@
 
 import re, pexpect
 from fencing import *
+from fencing import fail, fail_usage, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
 ## do not add code here.
 #BEGIN_VERSION_GENERATION
fence/agents/lpar/fence_lpar.py +1 -0
index 05e9b28..4278650 100644
@@ -14,6 +14,7 @@ import sys, re
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, fail_usage, EC_STATUS_HMC
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION=""
fence/agents/netio/fence_netio.py +1 -0
index e483470..a1b4abf 100755
@@ -4,6 +4,7 @@ import sys, re, pexpect
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fspawn, fail, EC_LOGIN_DENIED, TELNET_PATH
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION=""
fence/agents/ovh/fence_ovh.py +1 -0
index 647343c..9b1b373 100644
@@ -16,6 +16,7 @@ from suds.client import Client
 from suds.xsd.doctor import ImportDoctor, Import
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, fail_usage, EC_LOGIN_DENIED
 
 OVH_RESCUE_PRO_NETBOOT_ID = '28'
 OVH_HARD_DISK_NETBOOT_ID  = '1'
fence/agents/rhevm/fence_rhevm.py +1 -0
index 9620c3a..ea10d4b 100644
@@ -5,6 +5,7 @@ import pycurl, StringIO
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_STATUS, LOG_MODE_VERBOSE
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New RHEV-M Agent - test release on steroids"
fence/agents/sanbox2/fence_sanbox2.py +1 -0
index e0c0647..a9d7c76 100644
@@ -12,6 +12,7 @@ import sys, re, pexpect, exceptions
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, EC_TIMED_OUT, EC_GENERIC_ERROR
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New Sanbox2 Agent - test release on steroids"
fence/agents/virsh/fence_virsh.py +2 -0
index 170c089..fa6993e 100644
@@ -6,9 +6,11 @@
 #
 
 import sys, re
+import time
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail_usage, SUDO_PATH
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Virsh fence agent"
fence/agents/vmware/fence_vmware.py +1 -0
index f0f6023..9f19cb9 100644
@@ -26,6 +26,7 @@ import sys, re, pexpect
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fail, fail_usage, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="VMware Agent using VI Perl API and/or VIX vmrun command"
fence/agents/vmware_soap/fence_vmware_soap.py +1 -0
index b55b56c..f944a04 100644
@@ -9,6 +9,7 @@ sys.path.append("@FENCEAGENTSLIBDIR@")
 from suds.client import Client
 from suds.sudsobject import Property
 from fencing import *
+from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, EC_INVALID_PRIVILEGES, EC_WAITING_ON, EC_WAITING_OFF
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New VMWare Agent - test release on steroids"
fence/agents/wti/fence_wti.py +2 -0
index bcb287b..da68b66 100644
@@ -13,8 +13,10 @@
 
 import sys, re, pexpect
 import atexit
+import time
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
+from fencing import fspawn, fail, fail_usage, TELNET_PATH, EC_LOGIN_DENIED
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="New WTI Agent - test release on steroids"
Signature · 1 line
1.9.0
#7 lore raw

PATCH 8/15 Mark raw strings with r""

In reply to Marek 'marx' Grac
---
 fence/agents/alom/fence_alom.py               | 2 +-
 fence/agents/apc/fence_apc.py                 | 6 +++---
 fence/agents/bladecenter/fence_bladecenter.py | 6 +++---
 fence/agents/brocade/fence_brocade.py         | 2 +-
 fence/agents/cisco_mds/fence_cisco_mds.py     | 4 ++--
 fence/agents/drac/fence_drac.py               | 2 +-
 fence/agents/drac5/fence_drac5.py             | 8 ++++----
 fence/agents/eps/fence_eps.py                 | 2 +-
 fence/agents/hds_cb/fence_hds_cb.py           | 4 ++--
 fence/agents/hpblade/fence_hpblade.py         | 4 ++--
 fence/agents/ilo/fence_ilo.py                 | 6 +++---
 fence/agents/ldom/fence_ldom.py               | 6 +++---
 fence/agents/lib/check_used_options.py        | 8 ++++----
 fence/agents/lib/fencing.py.py                | 4 ++--
 fence/agents/lpar/fence_lpar.py               | 2 +-
 fence/agents/rsb/fence_rsb.py                 | 2 +-
 fence/agents/sanbox2/fence_sanbox2.py         | 6 +++---
 fence/agents/virsh/fence_virsh.py             | 2 +-
 fence/agents/vmware/fence_vmware.py           | 2 +-
 19 files changed, 39 insertions(+), 39 deletions(-)
fence/agents/alom/fence_alom.py +1 -1
index 2844904..2a72d7e 100644
@@ -37,7 +37,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ "sc\>\ " ]
+	all_opt["cmd_prompt"]["default"] = [ r"sc\>\ " ]
 
 	options = check_input(device_opt, process_input(device_opt))
 	options["telnet_over_ssh"] = 1
fence/agents/apc/fence_apc.py +3 -3
index 76b544b..3b17cd0 100644
@@ -73,7 +73,7 @@ def get_power_status(conn, options):
 		exp_result = conn.log_expect(options,
 				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
-		show_re = re.compile('(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
+		show_re = re.compile(r'(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
 		for x in lines:
 			res = show_re.search(x)
 			if (res != None):
@@ -185,7 +185,7 @@ def get_power_status5(conn, options):
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 	lines = conn.before.split("\n")
 
-	show_re = re.compile('^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
+	show_re = re.compile(r'^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
 
 	for x in lines:
 		res = show_re.search(x)
@@ -246,7 +246,7 @@ will block any necessary fencing actions."
 	## and continue with proper action
 	####
 	result = -1
-	firmware_version = re.compile('\s*v(\d)*\.').search(conn.before)
+	firmware_version = re.compile(r'\s*v(\d)*\.').search(conn.before)
 	if (firmware_version != None) and (firmware_version.group(1) == "5"):
 		result = fence_action(conn, options, set_power_status5, get_power_status5, get_power_status5)
 	else:
fence/agents/bladecenter/fence_bladecenter.py +3 -3
index 34a8975..3bb02fc 100644
@@ -25,7 +25,7 @@ BUILD_DATE="March, 2008"
 #END_VERSION_GENERATION
 
 def get_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
+	node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
 
 	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
 	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
@@ -44,7 +44,7 @@ def get_power_status(conn, options):
 	return status.lower().strip()
 
 def set_power_status(conn, options):
-	node_cmd = "system:blade\[" + options["--plug"] + "\]>"
+	node_cmd = r"system:blade\[" + options["--plug"] + r"\]>"
 
 	conn.send_eol("env -T system:blade[" + options["--plug"] + "]")
 	i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["--shell-timeout"]))
@@ -71,7 +71,7 @@ def get_blades_list(conn, options):
 	conn.log_expect(options, node_cmd, int(options["--shell-timeout"]))
 
 	lines = conn.before.split("\r\n")
-	filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
+	filter_re = re.compile(r"^\s*blade\[(\d+)\]\s+(.*?)\s*$")
 	for blade_line in lines:
 		res = filter_re.search(blade_line)
 		if res != None:
fence/agents/brocade/fence_brocade.py +1 -1
index 2deab5b..c6b2bfc 100644
@@ -17,7 +17,7 @@ def get_power_status(conn, options):
 
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	show_re = re.compile('^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
+	show_re = re.compile(r'^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
 	lines = conn.before.split("\n")
 
 	for x in lines:
fence/agents/cisco_mds/fence_cisco_mds.py +2 -2
index 6af1e99..dc6c41b 100644
@@ -37,7 +37,7 @@ PORT_OID = ""
 def cisco_port2oid(port):
 	port = port.lower()
 
-	nums = re.match('^fc(\d+)/(\d+)$', port)
+	nums = re.match(r'^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)
@@ -62,7 +62,7 @@ def get_outlets_status(conn, options):
 	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(r'^"fc\d+/\d+"$')
 
 	for x in res_fc:
 		if fc_re.match(x[1]):
fence/agents/drac/fence_drac.py +1 -1
index ba08ee7..396f09e 100644
@@ -14,7 +14,7 @@ BUILD_DATE=""
 def get_power_status(conn, options):
 	conn.send_eol("getmodinfo")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-	status = re.compile("\s+(on|off)\s+", re.IGNORECASE).search(conn.before).group(1)
+	status = re.compile(r"\s+(on|off)\s+", re.IGNORECASE).search(conn.before).group(1)
 	return (status.lower().strip())
 
 def set_power_status(conn, options):
fence/agents/drac5/fence_drac5.py +4 -4
index 642dcda..cdf4f4f 100644
@@ -35,7 +35,7 @@ def get_power_status(conn, options):
 
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-		status = re.compile("(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$",
+		status = re.compile(r"(^|: )(ON|OFF|Powering ON|Powering OFF)\s*$",
 				re.IGNORECASE | re.MULTILINE).search(conn.before).group(2)
 
 	if status.lower().strip() in ["on", "powering on", "powering off"]:
@@ -70,7 +70,7 @@ def get_list_devices(conn, options):
 	if options["--drac-version"] == "DRAC CMC":
 		conn.send_eol("getmodinfo")
 
-		list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
+		list_re = re.compile(r"^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
@@ -78,7 +78,7 @@ def get_list_devices(conn, options):
 	elif options["--drac-version"] == "DRAC MC":
 		conn.send_eol("getmodinfo")
 
-		list_re = re.compile("^\s*([^\s]*)\s*---->\s*(.*?)\s+Present\s*(ON|OFF)\s*.*$")
+		list_re = re.compile(r"^\s*([^\s]*)\s*---->\s*(.*?)\s+Present\s*(ON|OFF)\s*.*$")
 		conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
@@ -110,7 +110,7 @@ def main():
 
 	define_new_opts()
 
-	all_opt["cmd_prompt"]["default"] = [ "\$", "DRAC\/MC:" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\$", r"DRAC\/MC:" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
fence/agents/eps/fence_eps.py +1 -1
index 3c4be8d..daffab4 100644
@@ -71,7 +71,7 @@ def get_power_status(conn, options):
 	ret_val = eps_run_command(options,"")
 
 	result = {}
-	status = re.findall("p(\d{2})=(0|1)\s*\<br\>", ret_val.lower())
+	status = re.findall(r"p(\d{2})=(0|1)\s*\<br\>", ret_val.lower())
 	for out_num, out_stat in status:
 		result[out_num] = ("",(out_stat=="1" and "on" or "off"))
 
fence/agents/hds_cb/fence_hds_cb.py +2 -2
index 78754fc..70ca185 100755
@@ -21,7 +21,7 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE="November, 2012"
 #END_VERSION_GENERATION
 
-RE_STATUS_LINE = "^([0-9]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$"
+RE_STATUS_LINE = r"^([0-9]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$"
 
 def get_power_status(conn, options):
 	#### Maybe should put a conn.log_expect here to make sure
@@ -113,7 +113,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["power_wait"]["default"] = "5"
-	all_opt["cmd_prompt"]["default"] = [ "\) :" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\) :" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
fence/agents/hpblade/fence_hpblade.py +2 -2
index 44032d3..6b883db 100644
@@ -22,7 +22,7 @@ def get_power_status(conn, options):
 	conn.send_eol("show server status " + options["--plug"])
 	conn.log_expect(options, options["--command-prompt"] , int(options["--shell-timeout"]))
 
-	power_re = re.compile("^\s*Power: (.*?)\s*$")
+	power_re = re.compile(r"^\s*Power: (.*?)\s*$")
 	status = "unknown"
 	for line in conn.before.splitlines():
 		res = power_re.search(line)
@@ -50,7 +50,7 @@ def get_blades_list(conn, options):
 	conn.send_eol("show server list" )
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	list_re = re.compile("^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
+	list_re = re.compile(r"^\s*(.*?)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$")
 	for line in conn.before.splitlines():
 		res = list_re.search(line)
 		if res != None:
fence/agents/ilo/fence_ilo.py +3 -3
index 8171958..8719573 100644
@@ -109,11 +109,11 @@ the iLO card through an XML stream."
 		if options["--ribcl-version"] >= 2:
 			conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
 			conn.send("</RIB_INFO>\r\n")
-			conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
+			conn.log_expect(options, r"<GET_FW_VERSION\s*\n", int(options["--shell-timeout"]))
 			conn.log_expect(options, "/>", int(options["--shell-timeout"]))
-			options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"",
+			options["fw_version"] = float(re.compile(r"FIRMWARE_VERSION\s*=\s*\"(.*?)\"",
 					re.IGNORECASE).search(conn.before).group(1))
-			options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"",
+			options["fw_processor"] = re.compile(r"MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"",
 					re.IGNORECASE).search(conn.before).group(1)
 		conn.send("</LOGIN>\r\n")
 	except pexpect.TIMEOUT:
fence/agents/ldom/fence_ldom.py +3 -3
index ffa8fe4..7545eed 100644
@@ -19,7 +19,7 @@ REDHAT_COPYRIGHT=""
 BUILD_DATE=""
 #END_VERSION_GENERATION
 
-COMMAND_PROMPT_REG = "\[PEXPECT\]$"
+COMMAND_PROMPT_REG = r"\[PEXPECT\]$"
 COMMAND_PROMPT_NEW = "[PEXPECT]"
 
 # Start comunicating after login. Prepare good environment.
@@ -44,7 +44,7 @@ def get_power_status(conn, options):
 	fa_status = 0
 
 	for line in conn.before.splitlines():
-		domain = re.search("^(\S+)\s+(\S+)\s+.*$", line)
+		domain = re.search(r"^(\S+)\s+(\S+)\s+.*$", line)
 
 		if (domain!=None):
 			if ((fa_status==0) and (domain.group(1)=="NAME") and (domain.group(2)=="STATE")):
@@ -75,7 +75,7 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ "\ $" ]
+	all_opt["cmd_prompt"]["default"] = [ r"\ $" ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
fence/agents/lib/check_used_options.py +4 -4
index 2d2abbc..92a2ae6 100755
@@ -25,8 +25,8 @@ def main():
 
 	## all_opt defined in fence agent are found
 	agent_file = open(agent)
-	opt_re = re.compile("\s*all_opt\[\"([^\"]*)\"\] = {")
-	opt_longopt_re = re.compile("\s*\"longopt\" : \"([^\"]*)\"")
+	opt_re = re.compile(r"\s*all_opt\[\"([^\"]*)\"\] = {")
+	opt_longopt_re = re.compile(r"\s*\"longopt\" : \"([^\"]*)\"")
 
 	in_opt = False
 	for line in agent_file:
@@ -38,8 +38,8 @@ def main():
 
 	## check if all options are defined
 	agent_file = open(agent)
-	option_use_re = re.compile("options\[\"(-[^\"]*)\"\]")
-	option_has_re = re.compile("options.has_key\(\"(-[^\"]*)\"\)")
+	option_use_re = re.compile(r"options\[\"(-[^\"]*)\"\]")
+	option_has_re = re.compile(r"options.has_key\(\"(-[^\"]*)\"\)")
 
 	counter = 0
 	without_errors = True
fence/agents/lib/fencing.py.py +2 -2
index 40ee919..47d6e83 100644
@@ -489,7 +489,7 @@ def metadata(avail_opt, options, docs):
 
 			mixed = all_opt[option]["help"]
 			## split it between option and help text
-			res = re.compile("^(.*--\S+)\s+", re.IGNORECASE | re.S).search(mixed)
+			res = re.compile(r"^(.*--\S+)\s+", re.IGNORECASE | re.S).search(mixed)
 			if (None != res):
 				mixed = res.group(1)
 			mixed = mixed.replace("<", "&lt;").replace(">", "&gt;")
@@ -950,7 +950,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 
 	return result
 
-def fence_login(options, re_login_string = "(login\s*: )|(Login Name:  )|(username: )|(User Name :)"):
+def fence_login(options, re_login_string = r"(login\s*: )|(Login Name:  )|(username: )|(User Name :)"):
 	force_ipvx = ""
 
 	if (options.has_key("--inet6-only")):
fence/agents/lpar/fence_lpar.py +1 -1
index 4278650..630b2ca 100644
@@ -131,7 +131,7 @@ def main():
 
 	all_opt["login_timeout"]["default"] = "15"
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ ":~>", "]\$", "\$ " ]
+	all_opt["cmd_prompt"]["default"] = [ r":~>", r"]\$", r"\$ " ]
 
 	options = check_input(device_opt, process_input(device_opt))
 
fence/agents/rsb/fence_rsb.py +1 -1
index 89fb304..af3a2e4 100755
@@ -14,7 +14,7 @@ BUILD_DATE=""
 def get_power_status(conn, options):
 	conn.send("2")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
-	status = re.compile("Power Status[\s]*: (on|off)", re.IGNORECASE).search(conn.before).group(1)
+	status = re.compile(r"Power Status[\s]*: (on|off)", re.IGNORECASE).search(conn.before).group(1)
 	conn.send("0")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
fence/agents/sanbox2/fence_sanbox2.py +3 -3
index a9d7c76..0dfab37 100644
@@ -37,7 +37,7 @@ def get_power_status(conn, options):
 			pass
 		fail(EC_TIMED_OUT)
 
-	status = re.compile(".*AdminState\s+(online|offline)\s+",
+	status = re.compile(r".*AdminState\s+(online|offline)\s+",
 			re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
 
 	try:
@@ -82,7 +82,7 @@ def get_list_devices(conn, options):
 		conn.send_eol("show port")
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-		list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
+		list_re = re.compile(r"^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
 		for line in conn.before.splitlines():
 			if (list_re.search(line)):
 				status = {
@@ -129,7 +129,7 @@ because the connection will block any necessary fencing actions."
 	conn.send_eol("admin start")
 	conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
 
-	if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
+	if (re.search(r"\(admin\)", conn.before, re.MULTILINE) == None):
 		## Someone else is in admin section, we can't enable/disable
 		## ports so we will rather exit
 		sys.stderr.write("Failed: Unable to switch to admin section\n")
fence/agents/virsh/fence_virsh.py +1 -1
index fa6993e..f03ea74 100644
@@ -36,7 +36,7 @@ def get_outlets_status(conn, options):
 	fa_status = 0
 
 	for line in conn.before.splitlines():
-		domain = re.search("^\s*(\S+)\s+(\S+)\s+(\S+).*$", line)
+		domain = re.search(r"^\s*(\S+)\s+(\S+)\s+(\S+).*$", line)
 
 		if (domain!=None):
 			if ((fa_status==0) and (domain.group(1).lower()=="id") and (domain.group(2).lower()=="name")):
fence/agents/vmware/fence_vmware.py +1 -1
index 9f19cb9..42ac505 100644
@@ -248,7 +248,7 @@ def set_power_status(conn, options):
 # 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())
+	version_re = re.search(r"vmrun version (\d\.(\d[\.]*)*)", vmware_help_str.lower())
 	if (version_re==None):
 		return False   # Looks like this "vmrun" is not real vmrun
 
Signature · 1 line
1.9.0
#8 lore raw

PATCH 9/15 Only symbols that should be used are exported from fencing_snmp library

In reply to Marek 'marx' Grac
---
 fence/agents/lib/fencing_snmp.py.py | 2 ++
 1 file changed, 2 insertions(+)
fence/agents/lib/fencing_snmp.py.py +2 -0
index a081052..c5688be 100644
@@ -6,6 +6,8 @@ import re, pexpect
 from fencing import *
 from fencing import fail, fail_usage, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
+__all__ = [ 'FencingSnmp', 'snmp_define_defaults' ]
+
 ## do not add code here.
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION = ""
Signature · 1 line
1.9.0
#9 lore raw

PATCH 10/15 Errors when encountering mixed space/tab in python

In reply to Marek 'marx' Grac
---
 fence/agents/alom/fence_alom.py                 | 2 +-
 fence/agents/amt/fence_amt.py                   | 2 +-
 fence/agents/apc/fence_apc.py                   | 2 +-
 fence/agents/apc_snmp/fence_apc_snmp.py         | 2 +-
 fence/agents/bladecenter/fence_bladecenter.py   | 2 +-
 fence/agents/brocade/fence_brocade.py           | 2 +-
 fence/agents/cisco_mds/fence_cisco_mds.py       | 2 +-
 fence/agents/cisco_ucs/fence_cisco_ucs.py       | 2 +-
 fence/agents/drac/fence_drac.py                 | 2 +-
 fence/agents/drac5/fence_drac5.py               | 2 +-
 fence/agents/dummy/fence_dummy.py               | 2 +-
 fence/agents/eaton_snmp/fence_eaton_snmp.py     | 2 +-
 fence/agents/eps/fence_eps.py                   | 2 +-
 fence/agents/hds_cb/fence_hds_cb.py             | 2 +-
 fence/agents/hpblade/fence_hpblade.py           | 2 +-
 fence/agents/ibmblade/fence_ibmblade.py         | 2 +-
 fence/agents/ifmib/fence_ifmib.py               | 2 +-
 fence/agents/ilo/fence_ilo.py                   | 2 +-
 fence/agents/ilo_mp/fence_ilo_mp.py             | 2 +-
 fence/agents/intelmodular/fence_intelmodular.py | 2 +-
 fence/agents/ipdu/fence_ipdu.py                 | 2 +-
 fence/agents/ipmilan/fence_ipmilan.py           | 2 +-
 fence/agents/ldom/fence_ldom.py                 | 2 +-
 fence/agents/lib/check_used_options.py          | 2 +-
 fence/agents/lib/fencing.py.py                  | 2 +-
 fence/agents/lib/fencing_snmp.py.py             | 2 +-
 fence/agents/lib/transfer.py                    | 2 +-
 fence/agents/lpar/fence_lpar.py                 | 2 +-
 fence/agents/netio/fence_netio.py               | 2 +-
 fence/agents/ovh/fence_ovh.py                   | 2 +-
 fence/agents/rhevm/fence_rhevm.py               | 2 +-
 fence/agents/rsa/fence_rsa.py                   | 2 +-
 fence/agents/rsb/fence_rsb.py                   | 2 +-
 fence/agents/sanbox2/fence_sanbox2.py           | 2 +-
 fence/agents/virsh/fence_virsh.py               | 2 +-
 fence/agents/vmware/fence_vmware.py             | 2 +-
 fence/agents/vmware_soap/fence_vmware_soap.py   | 2 +-
 fence/agents/wti/fence_wti.py                   | 2 +-
 fence/agents/xenapi/fence_xenapi.py             | 2 +-
 39 files changed, 39 insertions(+), 39 deletions(-)
fence/agents/alom/fence_alom.py +1 -1
index 2a72d7e..c2af527 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following Agent Has Been Tested On:
 #
fence/agents/amt/fence_amt.py +1 -1
index 346677e..f7e8cc0 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, subprocess, re
 import atexit
fence/agents/apc/fence_apc.py +1 -1
index 3b17cd0..1e86c07 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/apc_snmp/fence_apc_snmp.py +1 -1
index b07d04a..2461476 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following agent has been tested on:
 # - APC Switched Rack PDU - SNMP v1
fence/agents/bladecenter/fence_bladecenter.py +1 -1
index 3bb02fc..0f59f55 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/brocade/fence_brocade.py +1 -1
index c6b2bfc..a60355d 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import atexit
fence/agents/cisco_mds/fence_cisco_mds.py +1 -1
index dc6c41b..6cc189f 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following agent has been tested on:
 # - Cisco MDS UROS 9134 FC (1 Slot) Chassis ("1/2/4 10 Gbps FC/Supervisor-2") Motorola, e500v2
fence/agents/cisco_ucs/fence_cisco_ucs.py +1 -1
index 81a911e..95dd2b4 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import pycurl, StringIO
fence/agents/drac/fence_drac.py +1 -1
index 396f09e..b858d62 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import atexit
fence/agents/drac5/fence_drac5.py +1 -1
index cdf4f4f..7d8fe9a 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/dummy/fence_dummy.py +1 -1
index dc65bee..e7c235a 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, random
 import time
fence/agents/eaton_snmp/fence_eaton_snmp.py +1 -1
index a329aeb..f519be8 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following agent has been tested on:
 # - Eaton ePDU Managed - SNMP v1
fence/agents/eps/fence_eps.py +1 -1
index daffab4..f8230e5 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following Agent Has Been Tested On:
 # ePowerSwitch 8M+ version 1.0.0.4
fence/agents/hds_cb/fence_hds_cb.py +1 -1
index 70ca185..f895fd3 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/hpblade/fence_hpblade.py +1 -1
index 6b883db..636c77d 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/ibmblade/fence_ibmblade.py +1 -1
index 1e60e7d..43bc73e 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys
 import atexit
fence/agents/ifmib/fence_ifmib.py +1 -1
index 3ecc85d..350ce71 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following agent has been tested on:
 # - Cisco MDS UROS 9134 FC (1 Slot) Chassis ("1/2/4 10 Gbps FC/Supervisor-2") Motorola, e500v2
fence/agents/ilo/fence_ilo.py +1 -1
index 8719573..f45e749 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/ilo_mp/fence_ilo_mp.py +1 -1
index c76c281..1d874c1 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import atexit
fence/agents/intelmodular/fence_intelmodular.py +1 -1
index bd1faee..320b2db 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # Tested with an Intel MFSYS25 using firmware package 2.6 Should work with an
 # MFSYS35 as well.
fence/agents/ipdu/fence_ipdu.py +1 -1
index c1fc368..62a2df4 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following agent has been tested on:
 #   IBM iPDU model 46M4002
fence/agents/ipmilan/fence_ipmilan.py +1 -1
index c5cab2b..93e87ae 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, shlex, subprocess, re, os
 import atexit
fence/agents/ldom/fence_ldom.py +1 -1
index 7545eed..65c810b 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 ##
 ## The Following Agent Has Been Tested On - LDOM 1.0.3
fence/agents/lib/check_used_options.py +1 -1
index 92a2ae6..ce74fa9 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 ## Check if fence agent uses only options["--??"] which are defined in fencing library or
 ## fence agent itself
fence/agents/lib/fencing.py.py +1 -1
index 47d6e83..3409b60 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, getopt, time, os, uuid, pycurl, stat
 import pexpect, re, syslog
fence/agents/lib/fencing_snmp.py.py +1 -1
index c5688be..e65a551 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # For example of use please see fence_cisco_mds
 
fence/agents/lib/transfer.py +1 -1
index ddf2486..b7a39db 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 from fencing import *
 
fence/agents/lpar/fence_lpar.py +1 -1
index 630b2ca..304ebe4 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/netio/fence_netio.py +1 -1
index a1b4abf..4708ff6 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re, pexpect
 import atexit
fence/agents/ovh/fence_ovh.py +1 -1
index 9b1b373..6602b8e 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 # Copyright 2013 Adrian Gibanel Lopez (bTactic)
 # Adrian Gibanel improved this script at 2013 to add verification of success and to output metadata
 
fence/agents/rhevm/fence_rhevm.py +1 -1
index ea10d4b..8c28b2d 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import pycurl, StringIO
fence/agents/rsa/fence_rsa.py +1 -1
index 4e855a2..ba93709 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/rsb/fence_rsb.py +1 -1
index af3a2e4..b72d295 100755
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, re
 import atexit
fence/agents/sanbox2/fence_sanbox2.py +1 -1
index 0dfab37..6750252 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/virsh/fence_virsh.py +1 -1
index f03ea74..c1cbc65 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 # The Following Agent Has Been Tested On:
 #
fence/agents/vmware/fence_vmware.py +1 -1
index 42ac505..3a7bc61 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #
 # The Following agent has been tested on:
fence/agents/vmware_soap/fence_vmware_soap.py +1 -1
index f944a04..ccdbac1 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import sys, time
 import shutil, tempfile, suds
fence/agents/wti/fence_wti.py +1 -1
index da68b66..01667fc 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 #####
 ##
fence/agents/xenapi/fence_xenapi.py +1 -1
index 8b9857c..3b6454c 100644
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 #
 #############################################################################
 # Copyright 2011 Matthew Clark
Signature · 1 line
1.9.0
#10 lore raw

PATCH 11/15 Mark raw strings with r"" in fence_virsh

In reply to Marek 'marx' Grac
---
 fence/agents/virsh/fence_virsh.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fence/agents/virsh/fence_virsh.py +2 -2
index c1cbc65..cbdb399 100644
@@ -73,8 +73,8 @@ def main():
 	atexit.register(atexit_handler)
 
 	all_opt["secure"]["default"] = "1"
-	all_opt["cmd_prompt"]["default"] = [ "\[EXPECT\]#\ " ]
-	all_opt["ssh_options"]["default"] = "-t '/bin/bash -c \"PS1=\[EXPECT\]#\  /bin/bash --noprofile --norc\"'"
+	all_opt["cmd_prompt"]["default"] = [ r"\[EXPECT\]#\ " ]
+	all_opt["ssh_options"]["default"] = "-t '/bin/bash -c \"" + r"PS1=\[EXPECT\]#\  " + "/bin/bash --noprofile --norc\"'"
 
 	options = check_input(device_opt, process_input(device_opt))
 
Signature · 1 line
1.9.0
#11 lore raw

PATCH 12/15 Remove snmp_define_defaults()

In reply to Marek 'marx' Grac

This function is always called for SNMP fence agents so it is possible to run it automatically.

---
 fence/agents/apc_snmp/fence_apc_snmp.py         | 11 +++--------
 fence/agents/cisco_mds/fence_cisco_mds.py       |  4 +---
 fence/agents/eaton_snmp/fence_eaton_snmp.py     |  4 +---
 fence/agents/ibmblade/fence_ibmblade.py         |  3 +--
 fence/agents/ifmib/fence_ifmib.py               |  3 +--
 fence/agents/intelmodular/fence_intelmodular.py |  4 +---
 fence/agents/ipdu/fence_ipdu.py                 |  3 +--
 fence/agents/lib/fencing.py.py                  |  3 +++
 fence/agents/lib/fencing_snmp.py.py             |  6 +-----
 9 files changed, 13 insertions(+), 28 deletions(-)
fence/agents/apc_snmp/fence_apc_snmp.py +3 -8
index 2461476..29aafe6 100644
@@ -16,7 +16,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="APC SNMP fence agent"
@@ -169,11 +169,6 @@ def get_outlets_status(conn, options):
 
 	return result
 
-# Define new options
-def apc_snmp_define_defaults():
-	all_opt["snmp_version"]["default"] = "1"
-	all_opt["community"]["default"] = "private"
-
 # Main agent method
 def main():
 	device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
@@ -181,8 +176,8 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-	apc_snmp_define_defaults()
+	all_opt["snmp_version"]["default"] = "1"
+	all_opt["community"]["default"] = "private"
 
 	options = check_input(device_opt, process_input(device_opt))
 
fence/agents/cisco_mds/fence_cisco_mds.py +1 -3
index 6cc189f..84adee2 100644
@@ -11,7 +11,7 @@ import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing import fail_usage
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Cisco MDS 9xxx SNMP fence agent"
@@ -84,8 +84,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
fence/agents/eaton_snmp/fence_eaton_snmp.py +1 -3
index f519be8..970fd69 100644
@@ -10,7 +10,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Eaton SNMP fence agent"
@@ -204,8 +204,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	all_opt["switch"]["default"] = 1
 	all_opt["power_wait"]["default"] = 2
 	all_opt["snmp_version"]["default"] = "1"
fence/agents/ibmblade/fence_ibmblade.py +1 -2
index 43bc73e..d1bb065 100644
@@ -4,7 +4,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IBM Blade SNMP fence agent"
@@ -57,7 +57,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults()
 	all_opt["snmp_version"]["default"] = "1"
 
 	options = check_input(device_opt, process_input(device_opt))
fence/agents/ifmib/fence_ifmib.py +1 -2
index 350ce71..f8beaa5 100644
@@ -13,7 +13,7 @@ import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing import fail_usage
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IF:MIB SNMP fence agent"
@@ -102,7 +102,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
 	all_opt["snmp_version"]["default"] = "2c"
 
 	options = check_input(device_opt, process_input(device_opt))
fence/agents/intelmodular/fence_intelmodular.py +1 -3
index 320b2db..e9ef43c 100644
@@ -15,7 +15,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Intel Modular SNMP fence agent"
@@ -68,8 +68,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
fence/agents/ipdu/fence_ipdu.py +1 -2
index 62a2df4..83f1dd4 100644
@@ -9,7 +9,7 @@ import sys
 import atexit
 sys.path.append("/usr/share/fence")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IBM iPDU SNMP fence agent"
@@ -133,7 +133,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
 	all_opt["snmp_version"]["default"] = "3"
 	all_opt["community"]["default"] = "private"
 	all_opt["switch"]["default"] = "1"
fence/agents/lib/fencing.py.py +3 -0
index 3409b60..fe4d9c4 100644
@@ -643,6 +643,9 @@ def check_input(device_opt, opt):
 		if options.has_key("--ipport"):
 			all_opt["ipport"]["help"] = "-u, --ipport=[port]            " + \
 					"TCP/UDP port to use (default " + options["--ipport"] +")"
+		elif device_opt.count("snmp_version"):
+			all_opt["ipport"]["default"] = "161"
+			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default 161)"
 		elif options.has_key("--ssh"):
 			all_opt["ipport"]["default"] = 22
 			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default 22)"
fence/agents/lib/fencing_snmp.py.py +1 -5
index e65a551..98afd30 100644
@@ -6,7 +6,7 @@ import re, pexpect
 from fencing import *
 from fencing import fail, fail_usage, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
-__all__ = [ 'FencingSnmp', 'snmp_define_defaults' ]
+__all__ = [ 'FencingSnmp' ]
 
 ## do not add code here.
 #BEGIN_VERSION_GENERATION
@@ -15,10 +15,6 @@ REDHAT_COPYRIGHT = ""
 BUILD_DATE = ""
 #END_VERSION_GENERATION
 
-# Fix for RHBZ#527844
-def snmp_define_defaults ():
-	all_opt["ipport"]["default"] = "161"
-
 class FencingSnmp:
 	def __init__(self, options):
 		self.options = options
Signature · 1 line
1.9.0
#12 lore raw

PATCH 13/15 Remove unused arguments

In reply to Marek 'marx' Grac

Arguments 'options' which will be used instead of global variables are left untouched so that this problem is visible.

---
 fence/agents/apc_snmp/fence_apc_snmp.py     |  6 +++---
 fence/agents/cisco_ucs/fence_cisco_ucs.py   |  5 +++++
 fence/agents/dummy/fence_dummy.py           |  7 +++++++
 fence/agents/eaton_snmp/fence_eaton_snmp.py |  6 +++---
 fence/agents/eps/fence_eps.py               |  2 ++
 fence/agents/rhevm/fence_rhevm.py           |  4 ++++
 fence/agents/vmware/fence_vmware.py         | 12 ++++++++----
 7 files changed, 32 insertions(+), 10 deletions(-)
fence/agents/apc_snmp/fence_apc_snmp.py +3 -3
index 29aafe6..d91e9e9 100644
@@ -87,7 +87,7 @@ class ApcMS:
 	has_switches = False
 
 ### FUNCTIONS ###
-def apc_set_device(conn, options):
+def apc_set_device(conn):
 	global device
 
 	agents_dir = {'.1.3.6.1.4.1.318.1.3.4.5':ApcRPDU,
@@ -109,7 +109,7 @@ def apc_resolv_port_id(conn, options):
 	global port_id, switch_id
 
 	if (device == None):
-		apc_set_device(conn, options)
+		apc_set_device(conn)
 
 	# Now we resolv port_id/switch_id
 	if ((options["--plug"].isdigit()) and ((not device.has_switches) or (options["--switch"].isdigit()))):
@@ -154,7 +154,7 @@ def get_outlets_status(conn, options):
 	result = {}
 
 	if (device == None):
-		apc_set_device(conn, options)
+		apc_set_device(conn)
 
 	res_ports = conn.walk(device.outlet_table_oid, 30)
 
fence/agents/cisco_ucs/fence_cisco_ucs.py +5 -0
index 95dd2b4..d073af6 100644
@@ -20,6 +20,8 @@ RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
 RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
 
 def get_power_status(conn, options):
+	del conn
+
 	res = send_command(options, "<configResolveDn cookie=\"" + options["cookie"] +
 			"\" inHierarchical=\"false\" dn=\"org-root" + options["--suborg"] + "/ls-" +
 			options["--plug"] + "/power\"/>", int(options["--shell-timeout"]))
@@ -36,6 +38,8 @@ def get_power_status(conn, options):
 		return "off"
 
 def set_power_status(conn, options):
+	del conn
+
 	action = {
 		'on' : "up",
 		'off' : "down"
@@ -50,6 +54,7 @@ def set_power_status(conn, options):
 	return
 
 def get_list(conn, options):
+	del conn
 	outlets = { }
 
 	try:
fence/agents/dummy/fence_dummy.py +7 -0
index e7c235a..f3b0ec0 100644
@@ -16,6 +16,8 @@ BUILD_DATE=""
 plug_status = "on"
 
 def get_power_status_file(conn, options):
+	del conn
+
 	try:
 		status_file = open(options["--status-file"], 'r')
 	except:
@@ -27,6 +29,8 @@ def get_power_status_file(conn, options):
 	return status.lower()
 
 def set_power_status_file(conn, options):
+	del conn
+
 	if not (options["--action"] in [ "on", "off" ]):
 		return
 
@@ -44,12 +48,15 @@ def get_power_status_fail(conn, options):
 
 def set_power_status_fail(conn, options):
 	global plug_status
+	del conn
 
 	plug_status = "unknown"
 	if options["--action"] == "on":
 		plug_status = "off"
 
 def get_outlets_fail(conn, options):
+	del conn
+
 	result = {}
 	global plug_status
 
fence/agents/eaton_snmp/fence_eaton_snmp.py +3 -3
index 970fd69..9688516 100644
@@ -65,7 +65,7 @@ class EatonSwitchedePDU:
 	has_switches = False
 
 ### FUNCTIONS ###
-def eaton_set_device(conn, options):
+def eaton_set_device(conn):
 	global device
 
 	agents_dir = {'.1.3.6.1.4.1.534.6.6.6':EatonManagedePDU,
@@ -86,7 +86,7 @@ def eaton_resolv_port_id(conn, options):
 	global port_id, switch_id
 
 	if (device==None):
-		eaton_set_device(conn, options)
+		eaton_set_device(conn)
 
 	# Restore the increment, that was removed in main for ePDU Managed
 	if (device.ident_str == "Eaton Switched ePDU"):
@@ -165,7 +165,7 @@ def get_outlets_status(conn, options):
 	result = {}
 
 	if (device==None):
-		eaton_set_device(conn, options)
+		eaton_set_device(conn)
 
 	res_ports = conn.walk(device.outlet_table_oid, 30)
 
fence/agents/eps/fence_eps.py +2 -0
index f8230e5..65b49db 100644
@@ -68,6 +68,7 @@ def eps_run_command(options, params):
 	return result
 
 def get_power_status(conn, options):
+	del conn
 	ret_val = eps_run_command(options,"")
 
 	result = {}
@@ -84,6 +85,7 @@ def get_power_status(conn, options):
 		return result
 
 def set_power_status(conn, options):
+	del conn
 	eps_run_command(options, "P%s=%s"%(options["--plug"], (options["--action"]=="on" and "1" or "0")))
 
 # Define new option
fence/agents/rhevm/fence_rhevm.py +4 -0
index 8c28b2d..2529801 100644
@@ -19,6 +19,8 @@ RE_STATUS = re.compile("<state>(.*?)</state>", re.IGNORECASE)
 RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
 
 def get_power_status(conn, options):
+	del conn
+
 	### Obtain real ID from name
 	res = send_command(options, "vms/?search=name%3D" + options["--plug"])
 
@@ -44,6 +46,7 @@ def get_power_status(conn, options):
 		return "on"
 
 def set_power_status(conn, options):
+	del conn
 	action = {
 		'on' : "start",
 		'off' : "stop"
@@ -53,6 +56,7 @@ def set_power_status(conn, options):
 	send_command(options, url, "POST")
 
 def get_list(conn, options):
+	del conn
 	outlets = { }
 
 	try:
fence/agents/vmware/fence_vmware.py +8 -4
index 3a7bc61..ee65186 100644
@@ -168,7 +168,7 @@ def vmware_run_command(options, add_login_params, additional_params, additional_
 
 # 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):
+def vmware_get_outlets_vi(options, add_vm_name):
 	outlets = {}
 
 	if (add_vm_name):
@@ -195,7 +195,7 @@ def vmware_get_outlets_vi(conn, options, add_vm_name):
 	return outlets
 
 # Get outlet list with status as hash table.
-def vmware_get_outlets_vix(conn, options):
+def vmware_get_outlets_vix(options):
 	outlets = {}
 
 	running_machines = vmware_run_command(options, True, "list", 0)
@@ -214,10 +214,12 @@ def vmware_get_outlets_vix(conn, options):
 	return outlets
 
 def get_outlets_status(conn, options):
+	del conn
+
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
-		return vmware_get_outlets_vi(conn, options, False)
+		return vmware_get_outlets_vi(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(options)
 
 def get_power_status(conn, options):
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
@@ -234,6 +236,8 @@ def get_power_status(conn, options):
 		return ((options["--plug"] in outlets) and "on" or "off")
 
 def set_power_status(conn, options):
+	del conn
+
 	if (vmware_internal_type==VMWARE_TYPE_ESX):
 		additional_params = "--operation %s --vmname '%s'" % \
 				((options["--action"]=="on" and "on" or "off"), quote_for_run(options["--plug"]))
Signature · 1 line
1.9.0
#13 lore raw

PATCH 14/15 Remove transfer script used in transition 3.x->4.x

In reply to Marek 'marx' Grac
---
 fence/agents/lib/transfer.py | 16 ----------------
 1 file changed, 16 deletions(-)
 delete mode 100755 fence/agents/lib/transfer.py
fence/agents/lib/transfer.py deleted +0 -16
deleted file mode 100755
index b7a39db..0000000
@@ -1,16 +0,0 @@
-#!/usr/bin/python -tt
-
-from fencing import *
-
-def main():
-	for key in all_opt.keys():
-		if all_opt[key].has_key("getopt") and all_opt[key].has_key("longopt"):
-			print "s/options\[\"-" + all_opt[key]["getopt"].rstrip(":") + "\"\]/options[\"--" + \
-				all_opt[key]["longopt"] + "\"]/g"
-			print "s/options.has_key(\"-" + all_opt[key]["getopt"].rstrip(":") + "\")/options.has_key(" + \
-				"\"--" + all_opt[key]["longopt"] + "\")/g"
-
-
-
-if __name__ == "__main__":
-	main()
\ No newline at end of file
Signature · 1 line
1.9.0
#14 lore raw

PATCH 15/15 Fix invalid names of variables

In reply to Marek 'marx' Grac
---
 fence/agents/apc/fence_apc.py             |  8 ++++----
 fence/agents/brocade/fence_brocade.py     |  4 ++--
 fence/agents/cisco_ucs/fence_cisco_ucs.py | 26 +++++++++++++-------------
 fence/agents/lib/check_used_options.py    |  8 ++++----
 fence/agents/lib/fencing.py.py            | 14 +++++++-------
 fence/agents/rhevm/fence_rhevm.py         | 26 +++++++++++++-------------
 fence/agents/xenapi/fence_xenapi.py       |  4 ++--
 7 files changed, 45 insertions(+), 45 deletions(-)
fence/agents/apc/fence_apc.py +4 -4
index 1e86c07..f744583 100644
@@ -74,8 +74,8 @@ def get_power_status(conn, options):
 				["Press <ENTER>" ] + options["--command-prompt"], int(options["--shell-timeout"]))
 		lines = conn.before.split("\n")
 		show_re = re.compile(r'(^|\x0D)\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
-		for x in lines:
-			res = show_re.search(x)
+		for line in lines:
+			res = show_re.search(line)
 			if (res != None):
 				outlets[res.group(2)] = (res.group(3), res.group(4))
 		conn.send_eol("")
@@ -187,8 +187,8 @@ def get_power_status5(conn, options):
 
 	show_re = re.compile(r'^\s*(\d+): (.*): (On|Off)\s*$', re.IGNORECASE)
 
-	for x in lines:
-		res = show_re.search(x)
+	for line in lines:
+		res = show_re.search(line)
 		if (res != None):
 			outlets[res.group(1)] = (res.group(2), res.group(3))
 
fence/agents/brocade/fence_brocade.py +2 -2
index a60355d..35082ee 100644
@@ -20,8 +20,8 @@ def get_power_status(conn, options):
 	show_re = re.compile(r'^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
 	lines = conn.before.split("\n")
 
-	for x in lines:
-		res = show_re.search(x)
+	for line in lines:
+		res = show_re.search(line)
 		if (res != None):
 			# We queried if it is disabled, so we have to negate answer
 			if res.group(1) == "ON":
fence/agents/cisco_ucs/fence_cisco_ucs.py +13 -13
index d073af6..ee1ae11 100644
@@ -63,9 +63,9 @@ def get_list(conn, options):
 
 		lines = res.split("<lsServer ")
 		for i in range(1, len(lines)):
-			dn = RE_GET_DN.search(lines[i]).group(1)
+			node_name = RE_GET_DN.search(lines[i]).group(1)
 			desc = RE_GET_DESC.search(lines[i]).group(1)
-			outlets[dn] = (desc, None)
+			outlets[node_name] = (desc, None)
 	except AttributeError:
 		return { }
 	except IndexError:
@@ -83,17 +83,17 @@ def send_command(opt, command, timeout):
 	url += "//" + opt["--ip"] + ":" + str(opt["--ipport"]) + "/nuova"
 
 	## send command through pycurl
-	c = pycurl.Curl()
-	b = StringIO.StringIO()
-	c.setopt(pycurl.URL, url)
-	c.setopt(pycurl.HTTPHEADER, [ "Content-type: text/xml" ])
-	c.setopt(pycurl.POSTFIELDS, command)
-	c.setopt(pycurl.WRITEFUNCTION, b.write)
-	c.setopt(pycurl.TIMEOUT, timeout)
-	c.setopt(pycurl.SSL_VERIFYPEER, 0)
-	c.setopt(pycurl.SSL_VERIFYHOST, 0)
-	c.perform()
-	result = b.getvalue()
+	conn = pycurl.Curl()
+	web_buffer = StringIO.StringIO()
+	conn.setopt(pycurl.URL, url)
+	conn.setopt(pycurl.HTTPHEADER, [ "Content-type: text/xml" ])
+	conn.setopt(pycurl.POSTFIELDS, command)
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
+	conn.setopt(pycurl.TIMEOUT, timeout)
+	conn.setopt(pycurl.SSL_VERIFYPEER, 0)
+	conn.setopt(pycurl.SSL_VERIFYHOST, 0)
+	conn.perform()
+	result = web_buffer.getvalue()
 
 	if opt["log"] >= LOG_MODE_VERBOSE:
 		opt["debug_fh"].write(command + "\n")
fence/agents/lib/check_used_options.py +4 -4
index ce74fa9..7f821b1 100755
@@ -46,13 +46,13 @@ def main():
 	for line in agent_file:
 		counter += 1
 
-		for x in option_use_re.findall(line):
-			if not available.has_key(x):
+		for option in option_use_re.findall(line):
+			if not available.has_key(option):
 				print "ERROR on line %d in %s: option %s is not defined" % (counter, agent, option_use_re.search(line).group(1))
 				without_errors = False
 
-		for x in option_has_re.findall(line):
-			if not available.has_key(x):
+		for option in option_has_re.findall(line):
+			if not available.has_key(option):
 				print "ERROR on line %d in %s: option %s is not defined" % (counter, agent, option_has_re.search(line).group(1))
 				without_errors = False
 
fence/agents/lib/fencing.py.py +7 -7
index fe4d9c4..013ae68 100644
@@ -404,11 +404,11 @@ def atexit_handler():
 		sys.exit(EC_GENERIC_ERROR)
 
 def add_dependency_options(options):
-	## Add options which are available for every fence agent
+	## Add also options which are available for every fence agent
 	added_opt = []
-	for x in options + ["default"]:
-		if DEPENDENCY_OPT.has_key(x):
-			added_opt.extend([y for y in DEPENDENCY_OPT[x] if options.count(y) == 0])
+	for opt in options + ["default"]:
+		if DEPENDENCY_OPT.has_key(opt):
+			added_opt.extend([y for y in DEPENDENCY_OPT[opt] if options.count(y) == 0])
 	return added_opt
 
 def fail_usage(message = ""):
@@ -860,10 +860,10 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 				((options["--action"] == "monitor") and 1 == options["device_opt"].count("port")):
 			outlets = get_outlet_list(tn, options)
 			## keys can be numbers (port numbers) or strings (names of VM)
-			for o in outlets.keys():
-				(alias, status) = outlets[o]
+			for outlet_id in outlets.keys():
+				(alias, status) = outlets[outlet_id]
 				if options["--action"] != "monitor":
-					print o + options["--separator"] + alias
+					print outled_id + options["--separator"] + alias
 			return
 
 		status = get_multi_power_fn(tn, options, get_power_fn)
fence/agents/rhevm/fence_rhevm.py +13 -13
index 2529801..b1c97e4 100644
@@ -83,22 +83,22 @@ def send_command(opt, command, method = "GET"):
 	url += "//" + opt["--ip"] + ":" + str(opt["--ipport"]) + "/api/" + command
 
 	## send command through pycurl
-	c = pycurl.Curl()
-	b = StringIO.StringIO()
-	c.setopt(pycurl.URL, url)
-	c.setopt(pycurl.HTTPHEADER, [ "Content-type: application/xml", "Accept: application/xml" ])
-	c.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
-	c.setopt(pycurl.USERPWD, opt["--username"] + ":" + opt["--password"])
-	c.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
-	c.setopt(pycurl.SSL_VERIFYPEER, 0)
-	c.setopt(pycurl.SSL_VERIFYHOST, 0)
+	conn = pycurl.Curl()
+	web_buffer = StringIO.StringIO()
+	conn.setopt(pycurl.URL, url)
+	conn.setopt(pycurl.HTTPHEADER, [ "Content-type: application/xml", "Accept: application/xml" ])
+	conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
+	conn.setopt(pycurl.USERPWD, opt["--username"] + ":" + opt["--password"])
+	conn.setopt(pycurl.TIMEOUT, int(opt["--shell-timeout"]))
+	conn.setopt(pycurl.SSL_VERIFYPEER, 0)
+	conn.setopt(pycurl.SSL_VERIFYHOST, 0)
 
 	if (method == "POST"):
-		c.setopt(pycurl.POSTFIELDS, "<action />")
+		conn.setopt(pycurl.POSTFIELDS, "<action />")
 
-	c.setopt(pycurl.WRITEFUNCTION, b.write)
-	c.perform()
-	result = b.getvalue()
+	conn.setopt(pycurl.WRITEFUNCTION, web_buffer.write)
+	conn.perform()
+	result = web_buffer.getvalue()
 
 	if opt["log"] >= LOG_MODE_VERBOSE:
 		opt["debug_fh"].write(command + "\n")
fence/agents/xenapi/fence_xenapi.py +2 -2
index 3b6454c..2a52c98 100644
@@ -217,10 +217,10 @@ the status of virtual machines running on the host."
 	docs["vendorurl"] = "http://www.xenproject.org"
 	show_docs(options, docs)
 
-	xenSession = connect_and_login(options)
+	xen_session = connect_and_login(options)
 
 	# Operate the fencing device
-	result = fence_action(xenSession, options, set_power_fn, get_power_fn, get_outlet_list)
+	result = fence_action(xen_session, options, set_power_fn, get_power_fn, get_outlet_list)
 
 	sys.exit(result)
 
Signature · 1 line
1.9.0