Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=825e27394... Commit: 825e2739411c1421fba2090a71244ad1a3299a7b Parent: fd471013bdda9202b045ebbfd00edeb734c41f13 Author: Marek 'marx' Grac mgrac@redhat.com AuthorDate: Thu Jun 27 13:27:32 2013 +0200 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Thu Jun 27 13:27:32 2013 +0200
fence_apc: Problem with <ENTER> prompt
After introducing support for firmware 5.x, the length of command prompt regular expressions is not strictly equal to one. This patches solves this problem by moving '<ENTER>' prompt to first position (index 0), so we do not rely on length of command prompt. --- fence/agents/apc/fence_apc.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py index 13b1e69..24ab5ee 100644 --- a/fence/agents/apc/fence_apc.py +++ b/fence/agents/apc/fence_apc.py @@ -68,7 +68,7 @@ def get_power_status(conn, options): conn.send_eol(options["--switch"]) while True: - exp_result = conn.log_expect(options, options["--command-prompt"] + [ "Press <ENTER>" ], 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: @@ -76,7 +76,7 @@ def get_power_status(conn, options): if (res != None): outlets[res.group(2)] = (res.group(3), res.group(4)) conn.send_eol("") - if exp_result == 0: + if exp_result != 0: break conn.send(chr(03)) conn.log_expect(options, "- Logout", int(options["--shell-timeout"])) @@ -146,7 +146,7 @@ def set_power_status(conn, options): else: conn.send_eol(options["--switch"])
- while 1 == conn.log_expect(options, options["--command-prompt"] + [ "Press <ENTER>" ], 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"]+"")
cluster-commits@lists.fedorahosted.org