Giter Site home page Giter Site logo

Comments (6)

mpenning avatar mpenning commented on May 24, 2024

Thank you for filing a bug. To be exact, ciscoconfparse.ccp_util.CiscoInterface chokes on IOS XR interface names... it also happens with my git HEAD as shown below...

Have you been using IOS XR factory before now?

The most basic problem is that IOS XR factory is not part of the test suite; it would have caught this problem if it was.
I need to do some reading about "IOS XR" interface names.

$ python
Python 3.10.13 (main, Nov  2 2023, 08:33:35) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse.ccp_util import CiscoInterface
>>> CiscoInterface("MgmtEth0/RP0/CPU0/0")
2023-11-14 04:57:48.873 | ERROR    | ciscoconfparse.ccp_util:__init__:3070 - An error has been caught in function '__init__', process 'MainProcess' (5229), thread 'MainThread' (139841872544384):
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

> File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3070, in __init__
    self.update_internal_state(intf_dict=intf_dict)
    │    │                               └ {'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, '...
    │    └ <function CiscoInterface.update_internal_state at 0x7f2f77de0e50><CiscoInterface None__UNINITIALIZED_NUMBER_ATTRIBUTE__>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3161, in update_internal_state
    raise InvalidCiscoInterface(f"intf_dict={intf_dict}")
          └ <class 'ciscoconfparse.errors.InvalidCiscoInterface'>

ciscoconfparse.errors.InvalidCiscoInterface: intf_dict={'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, 'interface_class': None}
2023-11-14 04:57:48.887 | ERROR    | __main__:<module>:1 - An error has been caught in function '<module>', process 'MainProcess' (5229), thread 'MainThread' (139841872544384):
Traceback (most recent call last):

> File "<stdin>", line 1, in <module>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3070, in __init__
    self.update_internal_state(intf_dict=intf_dict)
    │    │                               └ {'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, '...
    │    └ <function CiscoInterface.update_internal_state at 0x7f2f77de0e50><CiscoInterface None__UNINITIALIZED_NUMBER_ATTRIBUTE__>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3161, in update_internal_state
    raise InvalidCiscoInterface(f"intf_dict={intf_dict}")
          └ <class 'ciscoconfparse.errors.InvalidCiscoInterface'>

ciscoconfparse.errors.InvalidCiscoInterface: intf_dict={'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, 'interface_class': None}
2023-11-14 04:57:48.873 | ERROR    | ciscoconfparse.ccp_util:__init__:3070 - An error has been caught in function '__init__', process 'MainProcess' (5229), thread 'MainThread' (139841872544384):
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

> File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3070, in __init__
    self.update_internal_state(intf_dict=intf_dict)
    │    │                               └ {'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, '...
    │    └ <function CiscoInterface.update_internal_state at 0x7f2f77de0e50><CiscoInterface None__UNINITIALIZED_NUMBER_ATTRIBUTE__>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3161, in update_internal_state
    raise InvalidCiscoInterface(f"intf_dict={intf_dict}")
          └ <class 'ciscoconfparse.errors.InvalidCiscoInterface'>

ciscoconfparse.errors.InvalidCiscoInterface: intf_dict={'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, 'interface_class': None}
2023-11-14 04:57:48.887 | ERROR    | __main__:<module>:1 - An error has been caught in function '<module>', process 'MainProcess' (5229), thread 'MainThread' (139841872544384):
Traceback (most recent call last):

> File "<stdin>", line 1, in <module>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3070, in __init__
    self.update_internal_state(intf_dict=intf_dict)
    │    │                               └ {'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, '...
    │    └ <function CiscoInterface.update_internal_state at 0x7f2f77de0e50><CiscoInterface None__UNINITIALIZED_NUMBER_ATTRIBUTE__>

  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3161, in update_internal_state
    raise InvalidCiscoInterface(f"intf_dict={intf_dict}")
          └ <class 'ciscoconfparse.errors.InvalidCiscoInterface'>

ciscoconfparse.errors.InvalidCiscoInterface: intf_dict={'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, 'interface_class': None}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/virtual_env/py310_test/lib/python3.10/site-packages/loguru/_logger.py", line 1277, in catch_wrapper
    return function(*args, **kwargs)
  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3070, in __init__
    self.update_internal_state(intf_dict=intf_dict)
  File "/opt/virtual_env/py310_test/lib/python3.10/site-packages/loguru/_logger.py", line 1277, in catch_wrapper
    return function(*args, **kwargs)
  File "/home/mpenning/fixme/ciscoconfparse/ciscoconfparse/ccp_util.py", line 3161, in update_internal_state
    raise InvalidCiscoInterface(f"intf_dict={intf_dict}")
ciscoconfparse.errors.InvalidCiscoInterface: intf_dict={'prefix': 'MgmtEth', 'digit_separator': '/', 'slot': 0, 'card': None, 'port': None, 'subinterface': None, 'channel': None, 'interface_class': None}

from ciscoconfparse.

mpenning avatar mpenning commented on May 24, 2024

FYI... This is not relevant to the bug, but you should not overwrite python functions... your example is overwriting int()...

parse = CiscoConfParse(int_bad.splitlines(), syntax='ios', factory=True)
int = parse.find_objects_wo_child(r"^interf", r"^\s+^shutdown")

Would you mind donating your sanitized IOS XR config? I would like to be sure I know what else I'm dealing with before fixing this problem.

from ciscoconfparse.

mpenning avatar mpenning commented on May 24, 2024

I just pushed version 1.9.29 and added new syntax='iosxr'...

Parsing an IOS XR config from the test fixtures works with 1.9.29...

from ciscoconfparse import CiscoConfParse

parse = CiscoConfParse("tests/fixtures/configs/sample_01.iosxr", syntax='iosxr', factory=True)
active_intfs = parse.find_objects_wo_child(r"^interf", r"^\s+shutdown")

Please consider adding one or two sanitized IOS XR configs since I only have one in the test fixtures at the moment...

from ciscoconfparse.

Bierchermuesli avatar Bierchermuesli commented on May 24, 2024

Hey, thanks a lot for your quick response!

Have you been using IOS XR factory before now?

Yes, syntax='iosxr', factory=True and it worked well. Although the problem didn't occur because I used a different filter (parse.find_objects_w_child("^interface\s[\w\d\-\.\/]*$", "ipv\d\saddress.*")?) and just some simple attributes (e.g. iface.name). While debugging my old code, I noticed the chocking can also happend on some attributes. e.g. simply hovering over some attributes in vscode.

Anyway. with 1.9.29 it works well. Although lot of attributes are missing - but this might be another topic.

I can supply some XR ASR/NCS 6.3/7.2/7.10 configs. please advice whats your preffered way.

from ciscoconfparse.

mpenning avatar mpenning commented on May 24, 2024

can supply some XR ASR/NCS 6.3/7.2/7.10 configs. please advice whats your preffered way.

Please send as text file attachments to my gmail, [email protected].

Although lot of attributes are missing - but this might be another topic.

Any missing IOS XR attributes are another topic.

I also just added version 1.9.32 to pypi.

from ciscoconfparse.

mpenning avatar mpenning commented on May 24, 2024

@Bierchermuesli thank you for donating the following configs via email:

from ciscoconfparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.