Blame SOURCES/bz1148762-1-fence_wti_eol.patch

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