Bug 999146

Summary: Error in fencing_snmp.py on line 73
Product: [Fedora] Fedora Reporter: Tim Schoondergang <redhat>
Component: fence-agentsAssignee: Fabio Massimo Di Nitto <fdinitto>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: acathrow, cluster-maint, fdinitto, mgrac
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1022525 (view as bug list) Environment:
Last Closed: 2013-08-30 07:37:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1022525    
Attachments:
Description Flags
corrected file none

Description Tim Schoondergang 2013-08-20 19:46:09 UTC
Description of problem:
fencing_snmp.py returns KeyError: '--a'
and the fencing will fail

Version-Release number of selected component (if applicable):
4.0.2

How reproducible:
Always in combination of fence_intelmodular

Steps to Reproduce:
1. /usr/sbin/fence_intelmodular --action=status --ip=XXX.XXX.XXX.XXX --username=snmpv3user --password=XXXXXXXXXX --snmp-version=3 --snmp-auth-prot=SHA --verbose --plug=3 --snmp-sec-level=auth


Actual results:
Traceback (most recent call last):
  File "/usr/sbin/fence_intelmodular", line 92, in <module>
    main()
  File "/usr/sbin/fence_intelmodular", line 87, in main
    result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
  File "/usr/share/fence/fencing.py", line 810, in fence_action
    status = get_multi_power_fn(tn, options, get_power_fn)
  File "/usr/share/fence/fencing.py", line 743, in get_multi_power_fn
    plug_status = get_power_fn(tn, options)
  File "/usr/sbin/fence_intelmodular", line 41, in get_power_status
    (oid, status) = conn.get("%s.%s"% (STATUSES_OID, options["--plug"]))
  File "/usr/share/fence/fencing_snmp.py", line 106, in get
    cmd = "%s '%s'"% (self.prepare_cmd("snmpget"), self.quote_for_run(oid))
  File "/usr/share/fence/fencing_snmp.py", line 73, in prepare_cmd
    cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[1]]))
KeyError: '--a'

Expected results:
/usr/bin/snmpget -m '' -Oeqn  -v '3' -a 'SHA' -l 'auth' -A '87654321' -u 'snmpv3user' '85.17.234.138:161' '.1.3.6.1.4.1.343.2.19.1.2.10.202.1.1.6.3'
.1.3.6.1.4.1.343.2.19.1.2.10.202.1.1.6.3 2

Status: ON


Additional info:
I have found the bug, but can't know if it will affect other snmp fencing. But the correction is logic trough my eyes

in the file fencing_snmp.py on line 73 it states:
cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[1]]))

And it need to be:
cmd += " -%s '%s'"% (item[1], self.quote_for_run(self.options["--" + item[0]]))
I have attached the corrected file

Comment 1 Tim Schoondergang 2013-08-20 19:47:27 UTC
Created attachment 788626 [details]
corrected file

This the corrected file.

Comment 3 Marek Grac 2013-08-28 08:17:21 UTC
Thanks for reporting, fix is in upstream now. But are you sure that this happends in RHEL 6.x ? Should it be reported against upstream?

Comment 4 Tim Schoondergang 2013-08-28 08:43:27 UTC
Hi Marec,

No you are totaly right. It was Fedora. I was confused and mixed my RHE servers with my test servers. Sorry, my excuse!

How did I need to report it? So I can't make this mistake again.

Comment 5 Marek Grac 2013-08-28 08:46:26 UTC
@Tim:

No problem, I'm also upstream and Fedora maintainer so I have to do it anyway. Next time, just report it against Fedora.