netutils icon indicating copy to clipboard operation
netutils copied to clipboard

Config Parsing Helper

Open itdependsnetworks opened this issue 3 years ago • 4 comments

Environment

  • netutils version: 1.1

Proposed Functionality

Provided convinence methods to parse through a standard Ios-like (and potentially others) configurations. The idea being similar to CiscoConfParse in scope, but ideally to provide a few key features.

The ability to navigate nested configuration for a known path:

root_obj.get_path(["router bgp 45000", "address-family ipv4 unicast"])
# Returns 
  neighbor 192.168.1.2 activate
  network 172.17.1.0 mas

The ability to get configurations with parent context:

root_obj.get_path_with_parents(["router bgp 45000", "address-family ipv4 unicast"])
# Returns 
router bgp 45000
 address-family ipv4 unicast
  neighbor 192.168.1.2 activate
  network 172.17.1.0 mas

The ability to get configurations that match:

root_obj.get_multpile_parents(["interface GigabitEthernet.*"])
# Returns 
[ """interface GigabitEthernet0/1/0
 mac-address 00e0.1476.7600
 no ip address
!""", 
"""interface GigabitEthernet0/1/1
 mac-address 00e0.1476.7601
 no ip address
!"""]

The ability to get configurations that contains:

root_obj.get_contained(["interface GigabitEthernet.*"], "channel-group 1")
# Returns 
[ """interface GigabitEthernet0/1/0
 mac-address 00e0.1476.7600
 no ip address
 channel-group 1
!""", 
"""interface GigabitEthernet0/1/1
 mac-address 00e0.1476.7601
 no ip address
 channel-group 1
!"""]

And similar

Use Case

As an operator, I want the ability to find configurations based on various different characteristics. Such that I can quickly make logical choices, populate a SoT, find otherwise difficult to find configurations (offline), and quickly interrogate configurations across a large amount of data, just to name a few.

itdependsnetworks avatar Jun 26 '22 20:06 itdependsnetworks

Would the idea be to rework how the parsers work, or for these to be its own logic?

jeffkala avatar Jun 28 '22 02:06 jeffkala

I think it should just be adding convenience methods.

itdependsnetworks avatar Jun 28 '22 19:06 itdependsnetworks

Functions to be added: def find_blocks(): def find_children(): def find_children_w_parents(): def find_interface_objects(): def find_lineage(): def find_lines(): def find_object_branches(): def find_objects(): def find_objects_dna(): def find_objects_w_all_children(): def find_objects_w_child(): def find_objects_w_missing_children(): def find_objects_w_parents(): def find_objects_wo_child(): def find_parents_w_child(): def find_parents_wo_child():

mundruid avatar Aug 04 '22 22:08 mundruid

For further clarity, ciscoconfparse uses GPL and intends to keep that license, this is an intention to get similar behaviour without the constructs that come with GPL license.

itdependsnetworks avatar Mar 07 '23 13:03 itdependsnetworks