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 03-16-2011, 12:06 PM
"Fabio M. Di Nitto"
 
Default fence_wti: Unable to parse output when splitted into several screens

From: Marek 'marx' Grac <mgrac@redhat.com>

Parsing of listing that consists of several screens added.

Resolves: rhbz#678522
---
fence/agents/wti/fence_wti.py | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index a71852a..d05676b 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -22,9 +22,26 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION

def get_power_status(conn, options):
- try:
+ listing = ""
+
+ try:
+ conn.send("/S"+"
")
+
+ if isinstance(options["-c"], list):
+ re_all = options["-c"]
+ else:
+ re_all = [options["-c"]]
+ re_next = re.compile("Enter: ", re.IGNORECASE)
+ re_all.append(re_next)
+
conn.send("/S"+"
")
- conn.log_expect(options, options["-c"], int(options["-Y"]))
+ result = conn.log_expect(options, re_all, int(options["-Y"]))
+ listing = conn.before
+ if result == (len(re_all) - 1):
+ conn.send("
")
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
+ listing += conn.before
+
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -32,8 +49,8 @@ def get_power_status(conn, options):

plug_section = 0
outlets = {}
- for line in conn.before.splitlines():
- if (plug_section == 2) and line.find("|") >= 0:
+ 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("|")]
if len(plug_line) < len(plug_header):
plug_section = -1
@@ -42,7 +59,8 @@ def get_power_status(conn, options):
return plug_line[status_index]
else:
## We already believe that first column contains plug number
- outlets[plug_line[0]] = (plug_line[name_index], plug_line[status_index])
+ if len(plug_line[0]) != 0:
+ outlets[plug_line[0]] = (plug_line[name_index], plug_line[status_index])
elif (plug_section == 1):
plug_section = 2
pass
--
1.7.4
 

Thread Tools




All times are GMT. The time now is 07:19 AM.

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