cluster: STABLE3 - fencing: SNMP fence agents don't fail
Jan Friesse
honzaf at fedoraproject.org
Tue Mar 16 12:46:56 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=11f4970cfaa3f7448a0f1c78f1e9ce4bd2fb43df
Commit: 11f4970cfaa3f7448a0f1c78f1e9ce4bd2fb43df
Parent: ab02e00776c03abec5669869d58e2b77205fc993
Author: Jan Friesse <jfriesse at redhat.com>
AuthorDate: Tue Mar 16 13:46:35 2010 +0100
Committer: Jan Friesse <jfriesse at redhat.com>
CommitterDate: Tue Mar 16 13:46:35 2010 +0100
fencing: SNMP fence agents don't fail
Net-SNMP command-line utilities have interesting "feature"
causing too short pass-phrase (shorter then 8 characters)
write error but sadly, not return error code. In such case,
fencing can be considered successful even if it is not.
Patch fixes this by:
- Pass v3 options only for v3 mode
- Search for Error string in snmpcmd output
RHBZ#574027
---
fence/agents/lib/fencing_snmp.py.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 94f5af5..4f55795 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -58,12 +58,20 @@ class FencingSnmp:
self.complete_missed_params()
#mapping from our option to snmpcmd option
- mapping=(('d','v'), ('c','c'),('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','u'))
+ mapping=(('d','v'),('c','c'))
for item in mapping:
if (self.options.has_key("-"+item[0])):
cmd+=" -%s '%s'"%(item[1],self.quote_for_run(self.options["-"+item[0]]))
+ # Some options make sense only for v3 (and for v1/2c can cause "problems")
+ if (self.options.has_key("-d")) and (self.options["-d"] == "3"):
+ # Mapping from our options to snmpcmd options for v3
+ mapping_v3=(('b','a'),('E','l'),('B','x'),('P','X'),('p','A'),('l','u'))
+ for item in mapping_v3:
+ if (self.options.has_key("-"+item[0])):
+ cmd+=" -%s '%s'"%(item[1],self.quote_for_run(self.options["-"+item[0]]))
+
force_ipvx=""
if (self.options.has_key("-6")):
@@ -86,7 +94,8 @@ class FencingSnmp:
fail(EC_TIMED_OUT)
self.log_command(res_output)
- if (res_code!=0):
+
+ if (res_code!=0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
fail_usage("Returned %d: %s"%(res_code,res_output))
except pexpect.ExceptionPexpect:
fail_usage("Cannot run command %s"%(command))
More information about the cluster-commits
mailing list