question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

help to build show dmvpn parser

See original GitHub issue
#!/bin/env python
import sys
from pprint import pprint

python3 = sys.version_info >= (3, 0)

if python3:
    from unittest.mock import Mock
    from unittest.mock import patch
else:
    from mock import Mock
    from mock import patch

ats_mock = Mock()
with patch.dict('sys.modules', {'ats': ats_mock}):
    from genie import parsergen
    from genie.parsergen import oper_fill_tabular

show_command_output_example = """
Legend: Attrb --> S - Static, D - Dynamic, I - Incomplete
        N - NATed, L - Local, X - No Socket
        # Ent --> Number of NHRP entries with same NBMA peer
        NHS Status: E --> Expecting Replies, R --> Responding, W --> Waiting
        UpDn Time --> Up or Down Time for a Tunnel
==========================================================================

Interface: Tunnel1, IPv4 NHRP Details
Type:Hub, NHRP Peers:2,

 # Ent  Peer NBMA Addr Peer Tunnel Add State  UpDn Tm Attrb
 ----- --------------- --------------- ----- -------- -----
     1 27.27.27.2            10.0.1.12   IKE 01:28:32     D
     1 37.37.37.3            10.0.1.13    UP 00:28:42     D
"""


class my_dmvpn_parser(oper_fill_tabular):

    def __init__(self, device, show_command):
        headers = ["Ent", "Peer NBMA Addr",
                   "Peer Tunnel Add", "State", "UpDn Tm", "Attrb"]
        labels = ["Ent", "Peer Addr",
                  "Peer Tunnel add", "State", "time", "attrb"]
        device_os = 'iosxe'

        super(my_dmvpn_parser, self).__init__(
            device,
            show_command,
            header_fields=headers,
            label_fields=labels,
            index=[1],
            device_os=device_os)


# Define how device stub will behave when accessed by production parser.
device_kwargs = {
    'is_connected.return_value': True,
    'execute.return_value': show_command_output_example}
dev1 = Mock(**device_kwargs)

result = my_dmvpn_parser(dev1, "show dmvpn")

print("\nThe following commands were just executed on the device : {}\n".
      format(dev1.execute.call_args))

if result.entries['27.27.27.2']['Peer Tunnel add'] == '10.0.1.12':
    print("Test passed")
    pprint(result.entries)
else:
    print("Test failed")
    pprint(result.entries)

out

The following commands were just executed on the device : call('show dmvpn')

Test failed
{'27.27.27.2': {'Ent': '1',
                'Peer Addr': '27.27.27.2',
                'Peer Tunnel add': '10.0.1.1',
                'State': '2   IKE',
                'attrb': '2     D',
                'time': '01:28:3'},
 '37.37.37.3': {'Ent': '1',
                'Peer Addr': '37.37.37.3',
                'Peer Tunnel add': '10.0.1.1',
                'State': '3    UP',
                'attrb': '2     D',
                'time': '00:28:4'}}

I missing the last number in the ip address. ‘Peer Tunnel add’: shoud be ‘10.0.1.12’ i missing the last 2 😕 some one have a ide to solve it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
urskog84commented, Mar 10, 2020

Yes let’s givet a try

1reaction
urskog84commented, Mar 10, 2020

i fix the issue,

Uppdated the heder row 😄

 headers = ["Ent",   "Peer NBMA Addr", "Peer Tunnel Add", "State", "UpDn Tm", "Attrb"]
 headers = ['# Ent', ' Peer NBMA Addr', "Peer Tunnel Add", "State", "UpDn Tm", "Attrb"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Most Common DMVPN Troubleshooting Solutions - Cisco
Introduction. This document contains the most common solutions to Dynamic Multipoint VPN (DMVPN) problems. Many of these solutions can be ...
Read more >
Troubleshooting DMVPN Connectivity Problems
To troubleshoot DMVPN issues, we can break our efforts into four areas: Transport, Encryption, Tunnels, and Routing. Here are some tools to get...
Read more >
Cisco show dmvpn regular expression change regex in php ...
I tried to read up on Regular Expressions however couldn't make head/tails of how to join [3x] word/date/time. Working: if(pregmatch ...
Read more >
Dynamic Multipoint VPN (DMVPN) Explained | INE
DMVPN stands for Dynamic Multipoint VPN and it is an effective solution for dynamic secure overlay networks. In short, DMVPN is combination ...
Read more >
DMVPN to Cisco router not come UP - Bugs - VyOS forum
Also, the following command may help to check nhrp on Spoke side: show ip nhrp nhs detail. dinukro June 2, 2022, 5:24pm #5....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found