Closed mzi77 closed 1 year ago
No response
gives endless loop with error when loading with CiscoConfParse(PATH, factory=True)
FTOS9 route syntax
ip route [vrf vrf-name] ip-address mask {ip-address | interface [ip- address]} [distance] [name description] [permanent] [tag tag-value] [vrf vrf-name] [weight weight-value]
ipv6 route [vrf vrf-name] ipv6-address prefix-length {ipv6-address | interface | interface ipv6-address} [distance] [name description] [tag value] [permanent] [weight weight-value]
1.9.0
Linux - Debian, Ubuntu, CentOS, RHEL or others
Python 3.9
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function from ciscoconfparse import CiscoConfParse from netaddr import IPNetwork import argparse import os import os.path import sys parser = argparse.ArgumentParser() parser.add_argument('-f','--config_name',required=True,default=True,help='config') argument=parser.parse_args() PATH=argument.config_name if (os.path.isfile(PATH) and os.access(PATH, os.R_OK)): soubor=open(PATH,"r") full_path = os.path.realpath(PATH) else: sys.exit('Dany konfiguracni soubor neexistuje nebo neni citelny') parse = CiscoConfParse(PATH, factory=True)
--- Logging error in Loguru Handler #1 --- 2023-10-10 13:47:06.316 | CRITICAL | ciscoconfparse.models_cisco:network_object:2242 - Found _address_family = 'ipv6'' Record was: {'elapsed': datetime.timedelta(seconds=14, microseconds=778880), 'exception': (type=<class 'AttributeError'>, value=AttributeError("'IOSRouteLine' object has no attribute 'route_info'"), traceback=<traceback object at 0x7f767976a180>), 'extra': {}, 'file': (name='models_cisco.py', path='/home/zidek/dev/ansible-2.10/python3.9/lib/python3.9/site-packages/ciscoconfparse/models_cisco.py'), 'function': 'routeinfo', 'level': (name='ERROR', no=40, icon='❌'), 'line': 2059, 'message': "An error has been caught in function 'routeinfo', process 'MainProcess' (1427438), thread 'MainThread' (140147159159040):", 'module': 'models_cisco', 'name': 'ciscoconfparse.models_cisco', 'process': (id=1427438, name='MainProcess'), 'thread': (id=140147159159040, name='MainThread'), 'time': datetime(2023, 10, 10, 13, 47, 6, 316847, tzinfo=datetime.timezone(datetime.timedelta(seconds=7200), 'CEST'))} Chained exceptions have been truncated to avoid stack overflow in traceback formatting: Traceback (most recent call last): File "/home/zidek/dev/ansible-2.10/python3.9/lib/python3.9/site-packages/loguru/_logger.py", line 1277, in catch_wrapper return function(*args, **kwargs) File "/home/zidek/dev/ansible-2.10/python3.9/lib/python3.9/site-packages/ciscoconfparse/models_cisco.py", line 2230, in masklen masklen_str = self.route_info["masklength"] or "128" AttributeError: 'IOSRouteLine' object has no attribute 'route_info' ...
There is no FTOS factory support at this time, but that could be added sometime in the future.
As such, parse like this...
parse = CiscoConfParse(PATH, factory=False)
Contact Details
No response
What happened?
Simple configuration
! interface TenGigabitEthernet 1/1 no ip address shutdown ! ipv6 route 2a01:0::0::/64 Vlan 10 2a01::1 ip route 10.0.0.0/24 Vlan 10 10.0.0.1 ! end
gives endless loop with error when loading with CiscoConfParse(PATH, factory=True)
FTOS9 route syntax
ip route [vrf vrf-name] ip-address mask {ip-address | interface [ip- address]} [distance] [name description] [permanent] [tag tag-value] [vrf vrf-name] [weight weight-value]
ipv6 route [vrf vrf-name] ipv6-address prefix-length {ipv6-address | interface | interface ipv6-address} [distance] [name description] [tag value] [permanent] [weight weight-value]
CiscoConfParse Version
1.9.0
What Operating System are you using?
Linux - Debian, Ubuntu, CentOS, RHEL or others
What Python version(s) have this problem?
Python 3.9
Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.
Python tracebacks
Relevant log output
No response
Code of Conduct