Blame SOURCES/bz1148762-1-fence_wti_eol.patch

e4ffb1
From d3d73eaa39dd49cc7fbc93b267daa7f51b1c5fff Mon Sep 17 00:00:00 2001
e4ffb1
From: Marek 'marx' Grac <mgrac@redhat.com>
e4ffb1
Date: Thu, 2 Oct 2014 16:20:59 +0200
e4ffb1
Subject: [PATCH 2/2] fence_wti: Fix invalid "eol"
e4ffb1
e4ffb1
Fence agent for WTI does not use standard telnet login because it is possible that username/password are not
e4ffb1
required. EOL is set by fence_login() function that is not used, so we set it manually and replace
e4ffb1
obsolete combination of send (+eol) to correct send_eol()
e4ffb1
e4ffb1
Resolves: rhbz#1148762
e4ffb1
---
e4ffb1
 fence/agents/wti/fence_wti.py | 14 ++++++++------
e4ffb1
 1 file changed, 8 insertions(+), 6 deletions(-)
e4ffb1
e4ffb1
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
e4ffb1
index 78cd4e1..86f9a4d 100644
e4ffb1
--- a/fence/agents/wti/fence_wti.py
e4ffb1
+++ b/fence/agents/wti/fence_wti.py
e4ffb1
@@ -27,7 +27,7 @@ BUILD_DATE="March, 2008"
e4ffb1
 def get_listing(conn, options, listing_command):
e4ffb1
 	listing = ""
e4ffb1
 
e4ffb1
-	conn.send(listing_command + "\r\n")
e4ffb1
+	conn.send_eol(listing_command)
e4ffb1
 
e4ffb1
 	if isinstance(options["--command-prompt"], list):
e4ffb1
 		re_all = list(options["--command-prompt"])
e4ffb1
@@ -39,7 +39,7 @@ def get_listing(conn, options, listing_command):
e4ffb1
 	result = conn.log_expect(options, re_all, int(options["--shell-timeout"]))
e4ffb1
 	listing = conn.before
e4ffb1
 	if result == (len(re_all) - 1):
e4ffb1
-		conn.send("\r\n")
e4ffb1
+		conn.send_eol("")
e4ffb1
 		conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
e4ffb1
 		listing += conn.before
e4ffb1
 
e4ffb1
@@ -174,7 +174,7 @@ def set_power_status(conn, options):
e4ffb1
 		'off': "/off"
e4ffb1
 	}[options["--action"]]
e4ffb1
 
e4ffb1
-	conn.send(action + " " + options["--plug"] + ",y\r\n")
e4ffb1
+	conn.send_eol(action + " " + options["--plug"] + ",y")
e4ffb1
 	conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
e4ffb1
 
e4ffb1
 def main():
e4ffb1
@@ -207,6 +207,8 @@ is running because the connection will block any necessary fencing actions."
e4ffb1
 			if options["--action"] in ["off", "reboot"]:
e4ffb1
 				time.sleep(int(options["--delay"]))
e4ffb1
 
e4ffb1
+			options["eol"] = "\r\n"
e4ffb1
+
e4ffb1
 			conn = fspawn(options, TELNET_PATH)
e4ffb1
 			conn.send("set binary\n")
e4ffb1
 			conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
e4ffb1
@@ -217,14 +219,14 @@ is running because the connection will block any necessary fencing actions."
e4ffb1
 			result = conn.log_expect(options, [re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
e4ffb1
 			if result == 0:
e4ffb1
 				if options.has_key("--username"):
e4ffb1
-					conn.send(options["--username"]+"\r\n")
e4ffb1
+					conn.send_eol(options["--username"])
e4ffb1
 					result = conn.log_expect(options, [re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
e4ffb1
 				else:
e4ffb1
 					fail_usage("Failed: You have to set login name")
e4ffb1
 
e4ffb1
 			if result == 1:
e4ffb1
 				if options.has_key("--password"):
e4ffb1
-					conn.send(options["--password"]+"\r\n")
e4ffb1
+					conn.send_eol(options["--password"])
e4ffb1
 					conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
e4ffb1
 				else:
e4ffb1
 					fail_usage("Failed: You have to enter password or password script")
e4ffb1
@@ -236,7 +238,7 @@ is running because the connection will block any necessary fencing actions."
e4ffb1
 		conn = fence_login(options)
e4ffb1
 
e4ffb1
 	result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
e4ffb1
-	fence_logout(conn, "/X\r\n")
e4ffb1
+	fence_logout(conn, "/X")
e4ffb1
 	sys.exit(result)
e4ffb1
 
e4ffb1
 if __name__ == "__main__":
e4ffb1
-- 
e4ffb1
1.9.3
e4ffb1