Skip to content
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

Update XR show bgp neighbors template #346

Merged

Conversation

jtishey
Copy link

@jtishey jtishey commented Jan 22, 2019

ISSUE TYPE
  • New Template Pull Request
COMPONENT

cisco_xr_show_bgp_neighbor

SUMMARY

Updates to PR #341 for Cisco XR show bgp neighbors and add an additional test

Added tests/cisco_xr/show_bgp_neighbors1.raw
Added tests/cisco_xr/show_bgp_neighbors1.parsed
Updated templates/cisco_xr_show_bgp_neighbors.templates

Value GR (.+?)
Value List DEFAULT_ORIGINATE (.+)
Value LAST_RESET_REASON (.*)

START
^\s+Remote\s+AS\s+${REMOTE_AS},\s+local\s+AS\s+${LOCAL_AS},\s+(?:no-prepend,\s+)?(?:replace-as,\s+)?${TYPE}\s+link
^\s+Administratively\s+shut\s+down
^\s+BFD\s+[Ee]nabled
^\s+Configured hold time:\s+\d+,\s+keepalive:
^\s+Graceful\s+restart\s+is\s+${GR}\s*$$
^\s+Restart\s+time\s+is
^\s+Stale\s+path\s+timeout\s+time\s+is
^\s+Graceful\s+Restart\s+(GR\s+Awareness):
^\s+Inbound\s+message\s+logging
^\s+Outbound\s+message\s+logging

AFI
^\s+Default\s+information\s+originate:\s+${DEFAULT_ORIGINATE}
^\s+AF-dependent capabilities
^\s+Graceful\s+Restart\s+capability
^\s+Local\s+restart\s+time\s+is
^\s+Maximum\s+stalepath\s+time\s+is
^\s+Remote\s+Restart\s+time\s+is
^\s+Private\s+AS\s+number\s+removed
^\s+Community\s+attribute
^\s+Advertise\s+VPNv[46]\s+routes\s+(is\s)?enabled\s+with
^\s+AS\s+[oO]verride\s+is
^\s+Send\s+Multicast\s+Attributes

CONNECTION
^\s+Last\s+reset\s+${LAST_RESET},\s+due\s+to\s+${LAST_RESET_REASON}
^\s+Last\s+reset\s+${LAST_RESET}
^\s+External\s+BGP\s+neighbor\s+not\s+directly

Added tests/cisco_xr/show_bgp_neighbors1.raw
Added tests/cisco_xr/show_bgp_neighbors1.parsed
Updated templates/cisco_xr_show_bgp_neighbors.templates

Value GR (.+?)
Value List DEFAULT_ORIGINATE (.+)
Value LAST_RESET_REASON (.*)

START
  ^\s+Remote\s+AS\s+${REMOTE_AS}\,\s+local\s+AS\s+${LOCAL_AS}\,\s+(?:no\-prepend,\s+)?(?:replace\-as\,\s+)?${TYPE}\s+link
  ^\s+Administratively\s+shut\s+down
  ^\s+BFD\s+[Ee]nabled
  ^\s+Configured hold time\:\s+\d+\,\s+keepalive\:
  ^\s+Graceful\s+restart\s+is\s+${GR}\s*$$
  ^\s+Restart\s+time\s+is
  ^\s+Stale\s+path\s+timeout\s+time\s+is
  ^\s+Graceful\s+Restart\s+\(GR\s+Awareness\)\:
  ^\s+Inbound\s+message\s+logging
  ^\s+Outbound\s+message\s+logging

AFI
  ^\s+Default\s+information\s+originate\:\s+${DEFAULT_ORIGINATE}
  ^\s+AF-dependent capabilities
  ^\s+Graceful\s+Restart\s+capability
  ^\s+Local\s+restart\s+time\s+is
  ^\s+Maximum\s+stalepath\s+time\s+is
  ^\s+Remote\s+Restart\s+time\s+is
  ^\s+Private\s+AS\s+number\s+removed
  ^\s+Community\s+attribute
  ^\s+Advertise\s+VPNv[46]\s+routes\s+(is\s)?enabled\s+with
  ^\s+AS\s+[oO]verride\s+is
  ^\s+Send\s+Multicast\s+Attributes

CONNECTION
  ^\s+Last\s+reset\s+${LAST_RESET}\,\s+due\s+to\s+${LAST_RESET_REASON}
  ^\s+Last\s+reset\s+${LAST_RESET}
  ^\s+External\s+BGP\s+neighbor\s+not\s+directly
Copy link
Contributor

@jmcgill298 jmcgill298 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtishey when matching the rest of the line, you need to ensure that you account for a trailing space (it will eventually happen). The capture group will be either (.+?) or (.*?) and the regex will be ...${CAPTURE_GROUP}\s*$$

templates/cisco_xr_show_bgp_neighbors.template Outdated Show resolved Hide resolved
@@ -32,7 +34,7 @@ Value LOCAL_PORT (\d+)
Value REMOTE_ADDRESS (.*)
Value REMOTE_PORT (\d+)
Value LAST_RESET (\S+)
Value LAST_RESET_REASON (.+?)
Value LAST_RESET_REASON (.*)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this not working for your data? Follows for line 106

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative, it was matching the first letter. For example, "P" in:
Last reset 2w3d, due to Peer closing down the session
with:
^\s+Last\s+reset\s+${LAST_RESET}\,\s+due\s+to\s+${LAST_RESET_REASON}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without ending the line with \s*$$ that will happen, but my update included \s*$$, so it will capture everything up to the end of the line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmcgill298 I see what the issue was. Some routers output
^\s+Last\s+reset\s+${LAST_RESET}\,\s+due\s+to\s+${LAST_RESET_REASON}
and some just output
^\s+Last\s+reset\s+${LAST_RESET}

So there is a need to match either or (or just omit the values) . so the .+? failed with the first output scenario... I'll look into a more proper solution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmcgill298 Can you check out the latest commit 60e6e56 and see if that makes sense?

templates/cisco_xr_show_bgp_neighbors.template Outdated Show resolved Hide resolved
@jmcgill298 jmcgill298 merged commit a421bdb into networktocode:xr_show_bgp_neigh Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants