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

Config Parsing Helper #124

Open
itdependsnetworks opened this issue Jun 26, 2022 · 4 comments
Open

Config Parsing Helper #124

itdependsnetworks opened this issue Jun 26, 2022 · 4 comments

Comments

@itdependsnetworks
Copy link
Contributor

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.

@jeffkala
Copy link
Collaborator

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

@itdependsnetworks
Copy link
Contributor Author

I think it should just be adding convenience methods.

@mundruid
Copy link
Contributor

mundruid commented Aug 4, 2022

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():

@itdependsnetworks
Copy link
Contributor Author

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.

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

No branches or pull requests

3 participants