-
Notifications
You must be signed in to change notification settings - Fork 784
Fix new format of cisco_ios show cdp neigh detail #2260
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
Open
Ardeck
wants to merge
2
commits into
networktocode:master
Choose a base branch
from
Ardeck:Update_cisco_ios_show_cdp_neighbors_detail
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
92 changes: 80 additions & 12 deletions
92
ntc_templates/templates/cisco_ios_show_cdp_neighbors_detail.textfsm
This file contains hidden or 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 |
|---|---|---|
| @@ -1,27 +1,95 @@ | ||
| Value Required NEIGHBOR_NAME (\S+) | ||
| Value MGMT_ADDRESS (\d+\.\d+\.\d+\.\d+|\w+\.\w+\.\w+) | ||
| Value List INTERFACE_IPV6 ([0-9a-fA-F:]+) | ||
| Value MGMT_IP_ADDRESS (\d+\.\d+\.\d+\.\d+) | ||
| Value PLATFORM (.*) | ||
| Value NEIGHBOR_INTERFACE (.*) | ||
| Value LOCAL_INTERFACE (.*) | ||
| Value NEIGHBOR_DESCRIPTION (.*$) | ||
| Value CAPABILITIES (.+?) | ||
| Value SOFTWARE_VERSION ([^,\s]+) | ||
| Value SOFTWARE (.*) | ||
| Value SOFTWARE_FAMILY (.*) | ||
| Value List VERSION (\S.*) | ||
| Value SERIAL (\S+) | ||
| Value VTP_DOMAIN (.+) | ||
| Value VTP_VERSION (\d+) | ||
| Value NATIVE_VLAN (\d+) | ||
| Value DUPLEX (\S+) | ||
| Value DUPLEX_MISMATCH (\S+) | ||
| Value HOLDTIME (\d+) | ||
| Value POWER_DRAWN ([.\d]+) | ||
| Value POWER_REQUEST_ID ([-\d]+) | ||
| Value POWER_REQUEST_LEVEL ([-\d\s]+) | ||
| Value POWER_MGMT_ID ([-\d]+) | ||
| Value POWER_AVAILABLE ([-\d]+) | ||
| Value POWER_MGMT_LEVEL ([-\d]+) | ||
| Value PEER_MAC (\S+\.\S+\.\S+) | ||
| Value UNIDIRECTIONAL_MODE (\S+) | ||
|
|
||
| Start | ||
| ^Device ID: ${NEIGHBOR_NAME} | ||
| ^Entry address\(es\)\s*:\s* -> ParseIP | ||
| ^Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}\s+$$ | ||
| ^Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}$$ | ||
| ^Interface: ${LOCAL_INTERFACE}, Port ID \(outgoing port\): ${NEIGHBOR_INTERFACE} | ||
| ^Version : -> GetVersion | ||
| # Nexus Neighbor provides Serial Number | ||
| ^Device ID\s*:\s*${NEIGHBOR_NAME}\s*\(${SERIAL}\)\s*$$ | ||
| ^Device ID\s*:\s*${NEIGHBOR_NAME}\s*$$ | ||
| ^Entry address\(es\)\s*:\s*$$ -> ParseIP | ||
| ^\s*Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}\s*$$ | ||
| ^Interface:\s*${LOCAL_INTERFACE}\s*,\s*Port ID\s*\(outgoing port\)\s*:\s*${NEIGHBOR_INTERFACE}\s*$$ | ||
| # For Compatibility preserve the legacy format | ||
| ^Version\s*:\s*$$ -> GetVersion | ||
| ^Version\s*:\s*$$ -> NewVersion | ||
| # Various optional parameters | ||
| ^advertisement\s+version\s*:\s*${VTP_VERSION}\s*$$ | ||
| ^Peer\s*Source\s*MAC:\s*${PEER_MAC}\s*$$ | ||
| ^VTP Management Domain\s*:\s*${VTP_DOMAIN}\s*$$ | ||
| ^Native VLAN\s*:\s*${NATIVE_VLAN}\s*$$ | ||
| ^\s*Duplex\s*:\s*${DUPLEX}\s*\(\s*${DUPLEX_MISMATCH}\s*\)\s*$$ | ||
| ^\s*Duplex\s*:\s*${DUPLEX}\s*$$ | ||
| ^Power\s*drawn:\s*${POWER_DRAWN}\s*Watts$$ | ||
| # Management Address may be different of interface - global address | ||
| ^Management address\(es\)\s*:\s*$$ -> ParseMgmtIP | ||
| # PoE information | ||
| ^\s*Power\s*Available\s*TLV\s*:\s*$$ -> PwrAvail | ||
| ^\s*Power\s*request\s*id\s*:\s*${POWER_REQUEST_ID}\s*,\s*Power\s*management\s*id\s*:\s*${POWER_MGMT_ID}\s*$$ | ||
| ^\s*Power\s*request\s*levels\s*are\s*:\s*${POWER_REQUEST_LEVEL}\s*$$ | ||
| ^Holdtime\s*:\s*${HOLDTIME}\s*sec | ||
| ^Unidirectional\s*Mode\s*:\s*${UNIDIRECTIONAL_MODE}\s*$$ | ||
| # Additionnal parameters - noise | ||
| ^advertisement version\s*: | ||
| ^Protocol\s+Hello | ||
| # Capture time-stamp if vty line has command time-stamping turned on | ||
| ^Load\s+for\s+ | ||
| ^Load\s+for | ||
| ^Time\s+source\s+is | ||
| ^-+$$ -> Record Start | ||
| ^$$ -> Start | ||
| ^Total\s*cdp\s*entries\s*displayed\s*: | ||
| ^. -> Error | ||
|
|
||
| ParseIP | ||
| ^.*IP address: ${MGMT_ADDRESS} -> Start | ||
| ^Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}\s+$$ -> Start | ||
| ^Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}$$ -> Start | ||
| ^.* -> Start | ||
| # Parse Management IP - unfortunately no clear separator with the rest of the record | ||
| ^\s*IP address:\s*${MGMT_ADDRESS}\s*$$ | ||
| ^\s*IPv6 address:\s*${INTERFACE_IPV6}\s*\(.*\)\s*$$ | ||
| ^\s*Platform\s*:\s*${PLATFORM}\s*,\s*Capabilities\s*:\s*${CAPABILITIES}\s*$$ -> Start | ||
|
|
||
| GetVersion | ||
| ^${NEIGHBOR_DESCRIPTION} -> Record Start | ||
| # For compatibility with legacy templates | ||
| ^${NEIGHBOR_DESCRIPTION} -> NewVersion | ||
| # Match software line with version info for Cisco Devices | ||
|
|
||
| NewVersion | ||
| # Parse directly relevant information of the version of the software | ||
| ^\s*${SOFTWARE}\s*,\s*${SOFTWARE_FAMILY}\s*,\s*[^,]*\bVersion\s*:?\s*${SOFTWARE_VERSION}\s*,*\s*.*$$ | ||
| ^\s*${SOFTWARE}\s*,*\s*${SOFTWARE_FAMILY}\s*,*s*[^,]*\bVersion\s*:?\s*${SOFTWARE_VERSION}\s*,*\s*.*$$ | ||
| # get whatever is provided | ||
| ^${VERSION} | ||
| ^\s*$$ -> Start | ||
|
|
||
|
|
||
| ParseMgmtIP | ||
| ^\s*IP address:\s*${MGMT_IP_ADDRESS}\s*$$ -> Start | ||
| ^$$ -> Start | ||
|
|
||
| PwrAvail | ||
| # Optional: tolerate blank lines or unrelated lines after the header without failing. | ||
| ^\s*$$ -> PwrAvail | ||
| # Match the detail line (allow indentation and flexible spaces/commas). | ||
| ^\s*Power\s*request\s*id\s*:\s*${POWER_REQUEST_ID}\s*,\s*Power\s*management\s*id\s*:\s*${POWER_MGMT_ID}\s*,\s*Power\s*available\s*:\s*${POWER_AVAILABLE}\s*,\s*Power\s*management\s*level\s*:\s*${POWER_MGMT_LEVEL}\s*$$ -> Start | ||
This file contains hidden or 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
106 changes: 97 additions & 9 deletions
106
tests/cisco_ios/show_cdp_neighbors_detail/cisco_ios_show_cdp_neighbors_detail.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,35 +1,123 @@ | ||
| --- | ||
| parsed_sample: | ||
| - capabilities: "Switch IGMP" | ||
| duplex: "full" | ||
| duplex_mismatch: "" | ||
| holdtime: "164" | ||
| interface_ipv6: [] | ||
| local_interface: "GigabitEthernet1/0/16" | ||
| mgmt_address: "10.1.1.2" | ||
| neighbor_description: "Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M),\ | ||
| \ Version 12.2(55)SE9, RELEASE SOFTWARE (fc1)" | ||
| mgmt_ip_address: "10.1.1.2" | ||
| native_vlan: "1" | ||
| neighbor_description: "Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(55)SE9, RELEASE SOFTWARE (fc1)" | ||
| neighbor_interface: "GigabitEthernet0/1" | ||
| neighbor_name: "desktop-switch" | ||
| peer_mac: "" | ||
| platform: "cisco WS-C2960-8TC-L" | ||
| power_available: "" | ||
| power_drawn: "" | ||
| power_mgmt_id: "" | ||
| power_mgmt_level: "" | ||
| power_request_id: "" | ||
| power_request_level: "" | ||
| serial: "" | ||
| software: "" | ||
| software_family: "" | ||
| software_version: "" | ||
| unidirectional_mode: "" | ||
| version: | ||
| - "Technical Support: http://www.cisco.com/techsupport" | ||
| - "Copyright (c) 1986-2014 by Cisco Systems, Inc." | ||
| - "Compiled Mon 03-Mar-14 22:53 by prod_rel_team" | ||
| vtp_domain: "''" | ||
| vtp_version: "2" | ||
| - capabilities: "Router Switch IGMP" | ||
| duplex: "full" | ||
| duplex_mismatch: "" | ||
| holdtime: "156" | ||
| interface_ipv6: [] | ||
| local_interface: "GigabitEthernet1/0/22" | ||
| mgmt_address: "10.1.1.1" | ||
| neighbor_description: "Cisco IOS Software, 3800 Software (C3825-ADVENTERPRISEK9-M),\ | ||
| \ Version 12.4(24)T1, RELEASE SOFTWARE (fc3)" | ||
| mgmt_ip_address: "" | ||
| native_vlan: "" | ||
| neighbor_description: "Cisco IOS Software, 3800 Software (C3825-ADVENTERPRISEK9-M), Version 12.4(24)T1, RELEASE SOFTWARE (fc3)" | ||
| neighbor_interface: "GigabitEthernet0/0" | ||
| neighbor_name: "ce-router" | ||
| peer_mac: "" | ||
| platform: "Cisco 3825" | ||
| power_available: "" | ||
| power_drawn: "" | ||
| power_mgmt_id: "" | ||
| power_mgmt_level: "" | ||
| power_request_id: "" | ||
| power_request_level: "" | ||
| serial: "" | ||
| software: "" | ||
| software_family: "" | ||
| software_version: "" | ||
| unidirectional_mode: "" | ||
| version: | ||
| - "Technical Support: http://www.cisco.com/techsupport" | ||
| - "Copyright (c) 1986-2009 by Cisco Systems, Inc." | ||
| - "Compiled Fri 19-Jun-09 18:40 by prod_rel_team" | ||
| vtp_domain: "''" | ||
| vtp_version: "2" | ||
| - capabilities: "Host" | ||
| duplex: "full" | ||
| duplex_mismatch: "" | ||
| holdtime: "145" | ||
| interface_ipv6: [] | ||
| local_interface: "GigabitEthernet1/0/19" | ||
| mgmt_address: "10.1.1.232" | ||
| neighbor_description: "Linux 2.6.32-431.20.3.el6.x86_64 #1 SMP Fri Jun 6 18:30:54\ | ||
| \ EDT 2014 CCM:10.5.2.10000-5.i386" | ||
| mgmt_ip_address: "" | ||
| native_vlan: "" | ||
| neighbor_description: "Linux 2.6.32-431.20.3.el6.x86_64 #1 SMP Fri Jun 6 18:30:54 EDT 2014 CCM:10.5.2.10000-5.i386" | ||
| neighbor_interface: "eth0" | ||
| neighbor_name: "server" | ||
| peer_mac: "" | ||
| platform: "VMware" | ||
| power_available: "" | ||
| power_drawn: "" | ||
| power_mgmt_id: "" | ||
| power_mgmt_level: "" | ||
| power_request_id: "" | ||
| power_request_level: "" | ||
| serial: "" | ||
| software: "" | ||
| software_family: "" | ||
| software_version: "" | ||
| unidirectional_mode: "" | ||
| version: [] | ||
| vtp_domain: "" | ||
| vtp_version: "2" | ||
| - capabilities: "Router Switch IGMP" | ||
| duplex: "full" | ||
| duplex_mismatch: "" | ||
| holdtime: "173" | ||
| interface_ipv6: [] | ||
| local_interface: "GigabitEthernet0/3" | ||
| mgmt_address: "" | ||
| neighbor_description: "Cisco IOS Software, vios_l2 Software (vios_l2-ADVENTERPRISEK9-M),\ | ||
| \ Version 15.2(CML_NIGHTLY_20150414)FLO_DSGS7, EARLY DEPLOYMENT DEVELOPMENT\ | ||
| \ BUILD, synced to DSGS_PI5_POSTCOLLAPSE_TEAM_TRACK_CLONE" | ||
| mgmt_ip_address: "" | ||
| native_vlan: "1" | ||
| neighbor_description: "Cisco IOS Software, vios_l2 Software (vios_l2-ADVENTERPRISEK9-M), Version 15.2(CML_NIGHTLY_20150414)FLO_DSGS7, EARLY DEPLOYMENT DEVELOPMENT BUILD, synced to DSGS_PI5_POSTCOLLAPSE_TEAM_TRACK_CLONE" | ||
| neighbor_interface: "GigabitEthernet0/3" | ||
| neighbor_name: "vIOS-L2-1" | ||
| peer_mac: "" | ||
| platform: "Cisco " | ||
| power_available: "" | ||
| power_drawn: "" | ||
| power_mgmt_id: "" | ||
| power_mgmt_level: "" | ||
| power_request_id: "" | ||
| power_request_level: "" | ||
| serial: "" | ||
| software: "" | ||
| software_family: "" | ||
| software_version: "" | ||
| unidirectional_mode: "" | ||
| version: | ||
| - "Technical Support: http://www.cisco.com/techsupport" | ||
| - "Copyright (c) 1986-2015 by Cisco Systems, Inc." | ||
| - "Compiled Wed 15-Apr-15 00:42 by mmen" | ||
| vtp_domain: "" | ||
| vtp_version: "2" |
27 changes: 25 additions & 2 deletions
27
tests/cisco_ios/show_cdp_neighbors_detail/cisco_ios_show_cdp_neighbors_detail2.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,10 +1,33 @@ | ||
| --- | ||
| parsed_sample: | ||
| - capabilities: "Switch IGMP" | ||
| duplex: "full" | ||
| duplex_mismatch: "" | ||
| holdtime: "154" | ||
| interface_ipv6: [] | ||
| local_interface: "GigabitEthernet0/3" | ||
| mgmt_address: "1.1.1.1" | ||
| neighbor_description: "Cisco IOS Software, C3560E Software (C3560E-UNIVERSALK9-M),\ | ||
| \ Version 12.2(55)SE10, RELEASE SOFTWARE (fc2)" | ||
| mgmt_ip_address: "1.1.1.1" | ||
| native_vlan: "1" | ||
| neighbor_description: "Cisco IOS Software, C3560E Software (C3560E-UNIVERSALK9-M), Version 12.2(55)SE10, RELEASE SOFTWARE (fc2)" | ||
| neighbor_interface: "GigabitEthernet0/8" | ||
| neighbor_name: "switchxxxxx" | ||
| peer_mac: "" | ||
| platform: "cisco WS-C3560X-24P" | ||
| power_available: "0" | ||
| power_drawn: "" | ||
| power_mgmt_id: "1" | ||
| power_mgmt_level: "-1" | ||
| power_request_id: "0" | ||
| power_request_level: "" | ||
| serial: "" | ||
| software: "" | ||
| software_family: "" | ||
| software_version: "" | ||
| unidirectional_mode: "" | ||
| version: | ||
| - "Technical Support: http://www.cisco.com/techsupport" | ||
| - "Copyright (c) 1986-2015 by Cisco Systems, Inc." | ||
| - "Compiled Wed 11-Feb-15 11:28 by prod_rel_team" | ||
| vtp_domain: "''" | ||
| vtp_version: "2" |
Oops, something went wrong.
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.
I'd like to keep the MGMT_ADDRESS in lock step with LLDP neighbor outputs as well. So that these remain consistent across neighbor templates.
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.
I have reverted the breaking changes. At least the naming is not critical.