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

platform="cisco_ios", command="sh ip route summary" returning an empty array. #655

Closed
delhipnr opened this issue Apr 21, 2020 · 10 comments
Closed

Comments

@delhipnr
Copy link

from ntc_templates.parse import parse_output
from pprint import pprint

showiproute = """
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source Networks Subnets Replicates Overhead Memory (bytes)
connected 0 3 0 180 540
static 0 0 0 0 0
bgp 65000 0 0 0 0 0
External: 0 Internal: 0 Local: 0
internal 2 640
Total 2 3 0 180 1180

"""

vlan_parsed = parse_output(platform="cisco_ios", command="sh ip ro sum", data=showiproute)
pprint(vlan_parsed)

from ntc_templates.parse import parse_output
from pprint import pprint

showiproute = """
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source Networks Subnets Replicates Overhead Memory (bytes)
connected 0 3 0 180 540
static 0 0 0 0 0
bgp 65000 0 0 0 0 0
External: 0 Internal: 0 Local: 0
internal 2 640
Total 2 3 0 180 1180

"""

vlan_parsed = parse_output(platform="cisco_ios", command="sh ip ro sum", data=showiproute)
pprint(vlan_parsed)

@FragmentedPacket
Copy link
Contributor

@delhipnr Can you provide the real format of the command? I'd like to compare it to the data we have in tests and then what error are you experiencing?

@delhipnr
Copy link
Author

delhipnr commented Apr 21, 2020

@delhipnr Can you provide the real format of the command? I'd like to compare it to the data we have in tests and then what error are you experiencing?

show IP route summary

R1#show ip route summary
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source Networks Subnets Replicates Overhead Memory (bytes)
connected 0 3 0 180 540
static 0 0 0 0 0
bgp 65000 0 0 0 0 0
External: 0 Internal: 0 Local: 0
internal 2 640
Total 2 3 0 180 1180
R1#

@delhipnr
Copy link
Author

@delhipnr Can you provide the real format of the command? I'd like to compare it to the data we have in tests and then what error are you experiencing?

it is NOT similar to as I am getting nothing.
#643 Shared in below post

@FragmentedPacket
Copy link
Contributor

Yeah that is definitely odd as the template has ^. -> Error within it.

Can you grab the actual output from the device and wrap it in triple backticks here? The formatting of what you provided doesn't match any other output we have as normally the External: 0 Internal: 0 Local: 0 is indented under BGP.

Trying to help you out here, but definitely need more information.

@delhipnr
Copy link
Author

Yeah that is definitely odd as the template has ^. -> Error within it.

Can you grab the actual output from the device and wrap it in triple backticks here? The formatting of what you provided doesn't match any other output we have as normally the External: 0 Internal: 0 Local: 0 is indented under BGP.

Trying to help you out here, but definitely need more information.

from ntc_templates.parse import parse_output
from pprint import pprint

indata = """
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source Networks Subnets Replicates Overhead Memory (bytes)
connected 0 85 0 5780 15640
static 8 219 0 15436 41768
application 0 0 0 0 0
bgp 65182 58 6649 0 726036 1234088
External: 6706 Internal: 1 Local: 0
internal 146 305084
Total 212 6953 0 747252 1596580
"""

vlan_parsed = parse_output(platform="cisco_ios", command="show ip route summary", data=indata)
pprint(vlan_parsed)

na-EDGE1001SWG-VSS-242>show ip route summary
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source Networks Subnets Replicates Overhead Memory (bytes)
connected 0 85 0 5780 15640
static 8 219 0 15436 41768
application 0 0 0 0 0
bgp 65182 58 6649 0 726036 1234088
External: 6706 Internal: 1 Local: 0
internal 146 305084
Total 212 6953 0 747252 1596580
na-EDGE1001SWG-VSS-242>

RESTART: C:\Users\devuser\AppData\Local\Programs\Python\Python37-32\dictl.py
[]

@FragmentedPacket
Copy link
Contributor

The formatting still seems off with the indention to be honest.

Does the output you're providing here match what you see on the device?

I'd expect you could log into the device and then copy and paste it here wrapped in triple backticks and it would have the proper indentation.


IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           41          0           3936        11808
static          0           3           0           288         864
application     0           0           0           0           0
nhrp            0           0           0           0           0
eigrp 65329     3           3013        0           481920      868608
ospf 20         1           0           0           384         292
  Intra-area: 0 Inter-area: 0 External-1: 0 External-2: 1
  NSSA External-1: 0 NSSA External-2: 0
internal        24                                              240672
Total           28          3057        0           486528      1122244

I am curious as well that it is not parsing anything so maybe that is more of the smoking gun at this point.

It appears the template was added 21 days ago. Did you pip install ntc-templates? Or are you getting the templates from git?

@delhipnr
Copy link
Author

The formatting still seems off with the indention to be honest.

Does the output you're providing here match what you see on the device?

I'd expect you could log into the device and then copy and paste it here wrapped in triple backticks and it would have the proper indentation.


IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           41          0           3936        11808
static          0           3           0           288         864
application     0           0           0           0           0
nhrp            0           0           0           0           0
eigrp 65329     3           3013        0           481920      868608
ospf 20         1           0           0           384         292
  Intra-area: 0 Inter-area: 0 External-1: 0 External-2: 1
  NSSA External-1: 0 NSSA External-2: 0
internal        24                                              240672
Total           28          3057        0           486528      1122244

I am curious as well that it is not parsing anything so maybe that is more of the smoking gun at this point.

It appears the template was added 21 days ago. Did you pip install ntc-templates? Or are you getting the templates from git?

The formatting still seems off with the indention to be honest.

Does the output you're providing here match what you see on the device?

I'd expect you could log into the device and then copy and paste it here wrapped in triple backticks and it would have the proper indentation.


IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           41          0           3936        11808
static          0           3           0           288         864
application     0           0           0           0           0
nhrp            0           0           0           0           0
eigrp 65329     3           3013        0           481920      868608
ospf 20         1           0           0           384         292
  Intra-area: 0 Inter-area: 0 External-1: 0 External-2: 1
  NSSA External-1: 0 NSSA External-2: 0
internal        24                                              240672
Total           28          3057        0           486528      1122244

I am curious as well that it is not parsing anything so maybe that is more of the smoking gun at this point.

It appears the template was added 21 days ago. Did you pip install ntc-templates? Or are you getting the templates from git?



router>show ip route summary
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           85          0           5780        15640
static          8           219         0           15436       41768
application     0           0           0           0           0
bgp 65182       58          6649        0           726036      1234088
  External: 6706 Internal: 1 Local: 0
internal        146                                             305084
Total           212         6953        0           747252      1596580
router>

#########################################



PS C:\Users\auser> pip install ntc_templates
Collecting ntc_templates
  Downloading https://files.pythonhosted.org/packages/ee/cc/869f8bd85e63972f3873d82372a59f3408633f0634362af27e0a3aec3444
/ntc_templates-1.4.0.tar.gz (636kB)
     |████████████████████████████████| 645kB 91kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting terminal (from ntc_templates)
  Downloading https://files.pythonhosted.org/packages/1d/33/063e9da9aca3fd67f9e9176483195cba970e320e7dc660018025ef4457de
/terminal-0.4.0.tar.gz
Requirement already satisfied: textfsm in c:\users\auser\appdata\local\programs\python\python37-32\lib\site-packages
(from ntc_templates) (0.4.1)
Requirement already satisfied: colorama in c:\users\auser\appdata\roaming\python\python37\site-packages (from termina
l->ntc_templates) (0.4.1)
Building wheels for collected packages: ntc-templates
  Building wheel for ntc-templates (PEP 517) ... done
  Stored in directory: C:\Users\auser\AppData\Local\pip\Cache\wheels\1a\df\8c\79115911790c03486d665df324f90e7cfe78693
a6e09790b66
Successfully built ntc-templates
Installing collected packages: terminal, ntc-templates
  Running setup.py install for terminal ... done
Successfully installed ntc-templates-1.4.0 terminal-0.4.0
WARNING: You are using pip version 19.1.1, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS C:\Users\auser> 


PS C:\Users\auser> pip show ntc_templates
Name: ntc-templates
Version: 1.4.0
Summary: Package to return structured data from the output of network devices.
Home-page: https://github.com/networktocode/ntc-templates
Author: network.toCode()
Author-email: info@networktocode.com
License: UNKNOWN
Location: c:\users\auser\appdata\local\programs\python\python37-32\lib\site-packages
Requires: terminal, textfsm
Required-by:
PS C:\Users\auser> ntc_templates


@FragmentedPacket
Copy link
Contributor

Ok that is what I suspected. The template you're not getting any output for is not in the 1.4.0 package of ntc-templates as it was just added 22 days ago.

I'll try and cut a new release soon to get you that. You can always git clone the repo for the latest updates.

Here is my script that I use:

import sys

sys.path.append("/home/myohman/cloned-repos/ntc-templates/lib/ntc_templates")

from parse import parse_output


platform = "cisco_ios"
command = "show vlan"
with open("textfsm_data.cfg", "r") as f:
    data = f.read()

parsed_output = parse_output(platform, command, data)
print(parsed_output)

@delhipnr
Copy link
Author

Ok that is what I suspected. The template you're not getting any output for is not in the 1.4.0 package of ntc-templates as it was just added 22 days ago.

I'll try and cut a new release soon to get you that. You can always git clone the repo for the latest updates.

Here is my script that I use:

import sys

sys.path.append("/home/myohman/cloned-repos/ntc-templates/lib/ntc_templates")

from parse import parse_output


platform = "cisco_ios"
command = "show vlan"
with open("textfsm_data.cfg", "r") as f:
    data = f.read()

parsed_output = parse_output(platform, command, data)
print(parsed_output)

Thank You it is work.

>>> 
=============== RESTART: C:\Temp\reactsap\ntc_template\ntc.py ===============
[{'memory': '15640',
  'name': 'default (0x0)',
  'networks': '0',
  'overhead': '5780',
  'replicates': '0',
  'route_source': 'connected',
  'subnets': '85'},
 {'memory': '41768',
  'name': 'default (0x0)',
  'networks': '8',
  'overhead': '15436',
  'replicates': '0',
  'route_source': 'static',
  'subnets': '219'},
 {'memory': '0',
  'name': 'default (0x0)',
  'networks': '0',
  'overhead': '0',
  'replicates': '0',
  'route_source': 'application',
  'subnets': '0'},
 {'memory': '1234088',
  'name': 'default (0x0)',
  'networks': '58',
  'overhead': '726036',
  'replicates': '0',
  'route_source': 'bgp 65182',
  'subnets': '6649'},
 {'memory': '305084',
  'name': 'default (0x0)',
  'networks': '146',
  'overhead': '',
  'replicates': '',
  'route_source': 'internal',
  'subnets': ''},
 {'memory': '1596580',
  'name': 'default (0x0)',
  'networks': '212',
  'overhead': '747252',
  'replicates': '0',
  'route_source': 'Total',
  'subnets': '6953'}]
>>> 

@FragmentedPacket
Copy link
Contributor

I'll be releasing 1.4.1 tonight so you can pip install the newest version to use the same method you've been using although I would suggest the git route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants