-
Notifications
You must be signed in to change notification settings - Fork 52
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
Adds utility functions for ios parser #139
Conversation
Remove unused link.
Move to constants, fix doctest, make dns actions more clear, clean up wording to be more clear
Updates for 0.2.0 release
update changelog
Release 0.2.0
* Add ASA parser Co-authored-by: Justin Drew <[email protected]>
* Add BASE_INTERFACES for hp_comware & checkpoint Co-authored-by: Josef Fuchs <[email protected]>
prep for 0.2.1 release
release 0.2.1
Adds docs for readthedocs
Updated attribution and contribution doc start-lines
move sphinx to dev dep, update docs, update metadata
* Small performance enhancers - remove redundant call to `str` - `get_all_host` list to generator to avoid memory overhead of very large lists * Add lookup table for netmasks There are only 32 + 128 valid IPv4/6 netmasks, so I created a lookup table for easy validation. If there are concerns about the memory overhead, a computed version is easy enough to implement. * Make netutils dual-stack I modified functions where I could to make them compatible with IPv6. Per [RFC4291](https://datatracker.ietf.org/doc/html/rfc4291#section-4), I have assumed any addresses in the ::/8 range are IPv4. The one exception is `cidr_to_netmask`. I added a v6 version of that function. * Modify/add tests for proposed functionality
* remove count_bits tests * Remove count_bits in favor of simpler/faster function
* interface_range_expansion function added
Co-authored-by: Adam Byczkowski <[email protected]>
Co-authored-by: Adam Byczkowski <[email protected]>
Add interface sorting support.
1.1.0 release
* Updated lib mapping docs * Updated per review suggestions
Switch to poetry-core
Update banner parsing for EOS
* fixes encrypt type7
* initial pass at type hinting and getting mypy to run * update tasks and ci to do mypy as well * rm unused import * fix contributing end-line number * fix contributing end-line number * Add py.typed file to signify availability of type hints to third parties. * Updates to type hinting. * Add EOS _build_banner type hints. * Address feedback. * Linting. * Remove .idea from commit and ignore in .gitignore. * Remove remnants of merge conflict. * PR feedback. * PR comments. * Ignore pylint errors for abstract-method. * Black. * add examples and better exception messaging Co-authored-by: Leo Kirchner <[email protected]>
Nice!! Two thoughts
We could use "get" instead of find potentially, worth a convo at a min. |
neighbor 192.168.1.2 activate | ||
network 172.17.1.0 mas | ||
""" | ||
children = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think method could be solved with [a.config_line for a in config_tree.build_config_relationship() if a.parents and a.parents[0] == pattern]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you are suggesting does not return anything, it returns an empty list.
neighbor 192.168.1.2 activate | ||
network 172.17.1.0 mas | ||
""" | ||
parents_and_children = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method can be handled with [a.config_line for a in config_tree.build_config_relationship() if a.parents and a.parents[0] == pattern or a.config_line == pattern]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you are suggesting does not return anything, it returns an empty list.
@@ -72,7 +72,7 @@ def test_sphinx_build(data): | |||
sphinx_dummy_build = subprocess.run( # pylint: disable=W1510 | |||
["sphinx-build", "-b", "dummy", "-W", data["source_dir"], data["build_dir"]], stdout=subprocess.PIPE | |||
) | |||
assert sphinx_dummy_build.returncode == 0 | |||
assert sphinx_dummy_build.returncode == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why docs are failing, but shouldn't expect a non-zero return code (unless testing for specific failure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed based on the suggestion, the test works now.
Example: | ||
root_obj.get_path("router bgp 45000") | ||
# Returns | ||
address-family ipv4 unicast | ||
neighbor 192.168.1.2 activate | ||
network 172.17.1.0 mas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example: | |
root_obj.get_path("router bgp 45000") | |
# Returns | |
address-family ipv4 unicast | |
neighbor 192.168.1.2 activate | |
network 172.17.1.0 mas | |
Example: | |
>>> config = ''' | |
... router bgp 45000 | |
... address-family ipv4 unicast | |
... neighbor 192.168.1.2 activate | |
... network 172.17.1.0 mas''' | |
>>> bgp_conf = IOSConfigParser.get_path(config) | |
>>> print(bgp_conf) | |
address-family ipv4 unicast | |
neighbor 192.168.1.2 activate | |
network 172.17.1.0 mas |
Sphinx doesn't like the indentation in the docstring here and the function below. The suggestion should be good though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed based on the suggestion, the test works now.
"""Returns configuration part for specific pattern not including parents. | ||
|
||
Args: | ||
pattern (str): pattern that describes for parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this full library is type hinted we no longer need to provide the "types" within the docstrings.
pattern (str): pattern that describes for parent. | |
pattern: pattern that describes for parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
pattern (str): pattern that describes for parent. | ||
|
||
Returns: | ||
list: configuration under that parent pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list: configuration under that parent pattern. | |
configuration under that parent pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
"""Returns configuration part for specific pattern including parents and children. | ||
|
||
Args: | ||
pattern (str): pattern that describes for parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pattern (str): pattern that describes for parent. | |
pattern: pattern that describes for parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
pattern (str): pattern that describes for parent. | ||
|
||
Returns: | ||
list: configuration under that parent pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list: configuration under that parent pattern. | |
configuration under that parent pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
return grouped_data | ||
|
||
def get_path(self, pattern: str) -> t.List[str]: | ||
"""Returns configuration part for specific pattern not including parents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Returns configuration part for specific pattern not including parents. | |
"""Returns child configurations for a specific pattern not including parents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
return children | ||
|
||
def get_path_with_parents(self, pattern: str) -> t.List[str]: | ||
"""Returns configuration part for specific pattern including parents and children. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Returns configuration part for specific pattern including parents and children. | |
"""Returns configuration section for a specific pattern including parents and children. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Something seemed to happen with this PR, showing 182 filles changed. |
Overlaps with #140 |
Adds:
get_path
get_path_with_children
Addresses partially issue: #124