FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 05-09-2012, 08:37 AM
"Marek 'marx' Grac"
 
Default Autodetect EOL in fence agents

Fence agents diffes in EOL they accept. EOL
is quite universal but in some cases
it is translated to

what makes login process impossible to complete as it ends like
(capitals are fence agent response)

Login: USER

Password:


Login: PASSWORD


Until now there was a device option that handles that login_eol_lf but we found out that there are few
APC devices which does not work correctly with
and needs
. So we have to autodetect it, this feature was
added to standard library. As it can also helps with common problem when you have to write exactly
conn.send("message" + "
"). Method conn.sendline("") uses EOL according to platform, so we have decided to create
new method conn.sendxline (need a better name) which uses correct EOL. We need conn.sendline in communication with other local
application so we should not reuse it for this purpose.
---
fence/agents/lib/fencing.py.py | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 5748391..a61c45f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -175,11 +175,6 @@ all_opt = {
"required" : "0",
"shortdesc" : "Force ribcl version to use",
"order" : 1 },
- "login_eol_lf" : {
- "getopt" : "",
- "help" : "",
- "order" : 1
- },
"cmd_prompt" : {
"getopt" : "c:",
"longopt" : "command-prompt",
@@ -407,12 +402,20 @@ all_opt = {
common_opt = [ "retry_on", "delay" ]

class fspawn(pexpect.spawn):
+ def __init__(self, options, command):
+ pexpect.spawn.__init__(self, command)
+ self.opt = options
+
def log_expect(self, options, pattern, timeout):
result = self.expect(pattern, timeout)
if options["log"] >= LOG_MODE_VERBOSE:
options["debug_fh"].write(self.before + self.after)
return result

+ # send EOL according to what was detected in login process (telnet)
+ def sendxline(self, message):
+ self.send(message + self.opt["eol"])
+
def atexit_handler():
try:
sys.stdout.close()
@@ -864,10 +867,7 @@ def fence_login(options):
if (options.has_key("-4")):
force_ipvx="-4 "

- if (options["device_opt"].count("login_eol_lf")):
- login_eol = "
"
- else:
- login_eol = "
"
+ options["eol"] = "
"

## Do the delay of the fence device before logging in
## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
@@ -939,7 +939,7 @@ def fence_login(options):
fail_usage("Failed: You have to enter passphrase (-p) for identity file")
else:
try:
- conn = fspawn(TELNET_PATH)
+ conn = fspawn(options, TELNET_PATH)
conn.send("set binary
")
conn.send("open %s -%s
"%(options["-a"], options["-u"]))
except pexpect.ExceptionPexpect, ex:
@@ -948,11 +948,20 @@ def fence_login(options):
"are not in the spec file and must be installed separately." + "
")
sys.exit(EC_GENERIC_ERROR)

- conn.log_expect(options, re_login, int(options["-y"]))
- conn.send(options["-l"] + login_eol)
- conn.log_expect(options, re_pass, int(options["-Y"]))
+ result = conn.log_expect(options, re_login, int(options["-y"]))
+ conn.sendxline(options["-l"])
+
+ ## automatically change end of line separator
+ screen = conn.read_nonblocking(size=100, timeout=int(options["-Y"]))
+ if (re_login.search(screen) != None):
+ options["eol"] = "
"
+ conn.sendxline(options["-l"])
+ result = conn.log_expect(options, re_pass, int(options["-y"]))
+ elif (re_pass.search(screen) == None):
+ conn.log_expect(options, re_pass, int(options["-Y"]))
+
try:
- conn.send(options["-p"] + login_eol)
+ conn.sendxline(options["-p"])
conn.log_expect(options, options["-c"], int(options["-Y"]))
except KeyError:
fail(EC_PASSWORD_MISSING)
--
1.7.7.6
 

Thread Tools




All times are GMT. The time now is 04:19 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org