-
Notifications
You must be signed in to change notification settings - Fork 750
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
[snmp] Add snmp_facts support for ieee802.1ab MIBs, extend snmp testcase #679
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# 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 | ||
|
||
- set_fact: | ||
snmp_ports: "{{ snmp_ports|default({}) | combine({ item.key : item.value}) }}" | ||
when: "{{ item.value.name is defined }} | ||
and {{ item.value['name'].find('Ethernet') != -1 }}" | ||
with_dict: "{{ snmp_interfaces }}" | ||
|
||
# Check if lldpLocPortTable is present for all ports | ||
- name: "Verify lldpLocPortTable is present" | ||
assert: { that: "{{ item.value['lldpLocPortNum'] is defined }} | ||
and {{ item.value['lldpLocPortIdSubtype'] is defined }} | ||
and {{ item.value['lldpLocPortId'] is defined }} | ||
and {{ item.value['lldpLocPortDesc'] is defined }}" } | ||
with_dict: "{{ snmp_ports }}" | ||
|
||
# Check if lldpLocManAddrTable 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 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 }} | ||
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 }} > {{ active_intf | length * 0.8 }}" } | ||
|
||
|
||
# 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 | ||
assert: {that: "{{ minigraph_lldp_nei | length }} > {{ active_intf | length * 0.8 }}" } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the same #Closed