Bug 1459586

Summary: RFE: Improve handling of unknown devices by fence_eaton_snmp
Product: Red Hat Enterprise Linux 7 Reporter: Ondrej Faměra <ofamera>
Component: fence-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED NOTABUG QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: cfeist, cluster-maint, mjuricek, oalbrigt
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-08-06 14:23:41 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:

Description Ondrej Faměra 2017-06-07 14:08:36 UTC
=== Description of problem:
When the fence_eaton_snmp is used against device not supported
by it as seen from the source code of the agent it crashes with python
traceback. A simple listing of supported devices would be a better output 
so we can distinguish between "potentially broken fence agent" and "unsupported device".
From the code it looks that we would just need to check if the supported OIDs are present.

=== Version-Release number of selected component (if applicable):
fence-agents-eaton-snmp-4.0.11-47.el7_3.5.x86_64

=== How reproducible:
Always.

=== Steps to Reproduce:
1. Run command below against unsupported EATON device
fence_eaton_snmp --ip=192.168.X.X --community=public --username=admin --password=admin --plug=1 --action=status --verbose

=== Actual results:
/usr/bin/snmpwalk -m '' -Oeqn  -v '1' -c 'public' '192.168.X.X:161' '.1.3.6.1.2.1.1.2.0'

.1.3.6.1.2.1.1.2.0 .1.3.6.1.4.1.534.6.6.7

Traceback (most recent call last):
  File "/usr/sbin/fence_eaton_snmp", line 235, in <module>
    main()
  File "/usr/sbin/fence_eaton_snmp", line 231, in main
    result = fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
  File "/usr/share/fence/fencing.py", line 974, in fence_action
    status = get_multi_power_fn(tn, options, get_power_fn)
  File "/usr/share/fence/fencing.py", line 880, in get_multi_power_fn
    plug_status = get_power_fn(tn, options)
  File "/usr/sbin/fence_eaton_snmp", line 128, in get_power_status
    eaton_resolv_port_id(conn, options)
  File "/usr/sbin/fence_eaton_snmp", line 91, in eaton_resolv_port_id
    eaton_set_device(conn)
  File "/usr/sbin/fence_eaton_snmp", line 83, in eaton_set_device
    device = agents_dir[eaton_type[0][1]]
KeyError: None

=== Expected results:
Message in below style:
###
The device that you are trying to connect doesn't look to be supported by this fencing agent. 

Following devices were tested with this agentto work:
 - Eaton ePDU Managed - SNMP v1
   EATON | Powerware ePDU model: Managed ePDU (PW104MA0UB99), firmware: 01.01.01
 - Eaton ePDU Switched - SNMP v1
   EATON | Powerware ePDU model: Switched ePDU (IPV3600), firmware: 2.0.K
###

=== Additional info:
The list of tested devices is from the fencing agent itself.