-
Notifications
You must be signed in to change notification settings - Fork 1k
[snmp] Add snmp_facts support for ieee802.1ab MIBs, extend snmp testcase #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Test checks for ieee802_1ab MIBs: | ||
| # - lldpLocalSystemData 1.0.8802.1.1.2.1.3 | ||
| # - lldpLocPortTable 1.0.8802.1.1.2.1.3.7 | ||
| # - lldpLocManAddrTable 1.0.8802.1.1.2.1.3.8 | ||
| # | ||
| # - lldpRemTable 1.0.8802.1.1.2.1.4.1 | ||
| # - lldpRemManAddrTable 1.0.8802.1.1.2.1.4.2 | ||
| # | ||
| # For local data check if every OID has value | ||
| # For remote values check for availability for | ||
| # at least 80% of minigraph neighbors | ||
| # (similar to lldp test) | ||
|
|
||
|
|
||
| # Gather facts with SNMP version 2 | ||
| - name: Gathering basic snmp facts about the device | ||
| snmp_facts: host={{ ansible_host }} version=v2c community={{ snmp_rocommunity }} | ||
| connection: local | ||
|
|
||
| - name: Print SNMP LLDP information | ||
| debug: msg="{{ snmp_lldp }}" | ||
|
|
||
| # Check if lldpLocalSysData is present | ||
|
|
||
| - name: "Verify {{ item }} is defined" | ||
| assert: { that: "{{ snmp_lldp[item] is defined }} | ||
| and not {{ snmp_lldp[item] | search('No Such Object currently exists') }}" } | ||
| with_items: | ||
| - lldpLocChassisIdSubtype | ||
| - lldpLocChassisId | ||
| - lldpLocSysName | ||
| - lldpLocSysDesc | ||
|
|
||
| # Check if lldpLocManAddr is present | ||
| - name: "Verify {{ item }} is defined" | ||
| assert: { that: "{{ snmp_lldp[item] is defined }} | ||
| and not {{ snmp_lldp[item] | search('No Such Object currently exists') }}" } | ||
|
||
| with_items: | ||
| - lldpLocManAddrSubtype | ||
| - lldpLocManAddr | ||
| - lldpLocManAddrLen | ||
| - lldpLocManAddrIfSubtype | ||
| - lldpLocManAddrIfId | ||
| - lldpLocManAddrOID | ||
|
|
||
| # Check if lldpLocPortTable is present | ||
| - fail: | ||
| msg: "lldpLocPortTable data missing for interface {{ item.key }}" | ||
| when: "{{ item.value.description | match('^Ethernet') }} | ||
| and ( {{ item.value['lldpLocPortNum'] is not defined }} | ||
|
||
| or {{ item.value['lldpLocPortIdSubtype'] is not defined }} | ||
| or {{ item.value['lldpLocPortId'] is not defined }} | ||
| or {{ item.value['lldpLocPortDesc'] is not defined }} )" | ||
| with_dict: "{{ snmp_interfaces }}" | ||
|
|
||
| # Check if lldpRemTable is present | ||
|
|
||
| - set_fact: | ||
| active_intf: [] | ||
|
|
||
| - name: find minigraph lldp neighbor | ||
| set_fact: | ||
| minigraph_lldp_nei: "{{ minigraph_lldp_nei|default({}) | combine({ item.key : item.value}) }}" | ||
| when: "'server' not in item.value['name'] | lower" | ||
| with_dict: minigraph_neighbors | ||
|
|
||
| - name: Create list of ports with lldpRemTable data | ||
| when: "{{ item.value['lldpRemTimeMark'] is defined }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same #Closed |
||
| and {{ item.value['lldpRemLocalPortNum'] is defined }} | ||
| and {{ item.value['lldpRemIndex'] is defined }} | ||
| and {{ item.value['lldpRemChassisIdSubtype'] is defined }} | ||
| and {{ item.value['lldpRemChassisId'] is defined }} | ||
| and {{ item.value['lldpRemPortIdSubtype'] is defined }} | ||
| and {{ item.value['lldpRemPortId'] is defined }} | ||
| and {{ item.value['lldpRemPortDesc'] is defined }} | ||
| and {{ item.value['lldpRemSysName'] is defined }} | ||
| and {{ item.value['lldpRemSysDesc'] is defined }} | ||
| and {{ item.value['lldpRemSysCapSupported'] is defined }} | ||
| and {{ item.value['lldpRemSysCapEnabled'] is defined }}" | ||
| set_fact: | ||
| active_intf: "{{ active_intf + [item] }}" | ||
| with_dict: "{{ snmp_interfaces }}" | ||
|
|
||
| - debug: | ||
| msg: "Found {{ active_intf | length }} Ifs with lldpRemTable data\n | ||
| Minigraph contains {{ minigraph_lldp_nei | length }} neighbors" | ||
|
|
||
| - name: Verify lldpRemTable is available on most interfaces | ||
| assert: {that: "{{ minigraph_lldp_nei | length * 0.8 }} > {{ active_intf | length }}" } | ||
|
|
||
| # Check if lldpRemManAddrTable is present | ||
|
|
||
| - set_fact: | ||
| active_intf: [] | ||
|
|
||
| - name: Create list of ports with lldpRemManAddr data | ||
| when: "{{ item.value['lldpRemManAddrSubtype'] is defined }} | ||
| and {{ item.value['lldpRemManAddr'] is defined }} | ||
|
||
| and {{ item.value['lldpRemManAddr'] is defined }} | ||
| and {{ item.value['lldpRemManAddrIfSubtype'] is defined }} | ||
| and {{ item.value['lldpRemManAddrIfId'] is defined }} | ||
| and {{ item.value['lldpRemManAddrOID'] is defined }}" | ||
| set_fact: | ||
| active_intf: "{{ active_intf + [item] }}" | ||
| with_dict: "{{ snmp_interfaces }}" | ||
|
|
||
| - debug: | ||
| msg: "Found {{ active_intf | length }} Ifs with lldpRemManAddr data\n | ||
| Minigraph contains {{ minigraph_lldp_nei | length }} neighbors" | ||
|
||
|
|
||
| - name: Verify lldpRemManAddr is available on most interfaces | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we test lldpRemManAddr is available on all interfaces? #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking into consideration that in lldp test we are satisfied with lldp data awailable on 80% of the interfaces, demanding more of the same data here is questionable. |
||
| assert: {that: "{{ minigraph_lldp_nei | length * 0.8 }} > {{ active_intf | length }}" } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add one level indentation before 'and not'? #Closed