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 jinja2 filters for working with network devices #24216
Conversation
privateip
commented
May 2, 2017
- adds network textfsm filters
- adds network config filter
@privateip Greetings! Thanks for taking the time to open this pullrequest. In order for the community to handle your pullrequest effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this pullrequest with this template: |
* adds network textfsm filters * adds network config filter
|
||
.. versionadded:: 2.4 | ||
|
||
To generate a list of command diffs for a network configuration: |
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.
For code blocks in RST you use ::
, blank line, four spaces
e.g.
To generate a list of command diffs for a network configuration::
{{ myvar | diff_network_config(current_config, indent=1 }}
from ansible.utils.display import Display | ||
display = Display() | ||
|
||
NETWORK_OS = { |
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 wonder if this should be called NETWORK_OS_INDENT
, or similar
if url.scheme.startswith('http'): | ||
try: | ||
handler = {} | ||
if 'HTTP_PROXY' in os.environ: |
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.
Might be worth adding some comments to say why you set the proxy to localhost.
The test
The test
The test
|
Glad to see TextFSM integration going into core. Few questions for now.
|
|
||
To generate a list of command diffs for a network configuration: | ||
|
||
{{ myvar | diff_network_config(current_config, indent=1 }} |
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.
need to close out the function: e.g.
{{ myvar | diff_network_config(current_config, indent=1 ) }}
Also might be a good idea to show example using a file lookup.
assert replace in ('line', 'block') | ||
assert network_os in NETWORK_OS.keys() | ||
|
||
if network_os: |
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.
Not sure how this would ever hit base on the previous assert? Perhaps the assert should be here?
Just want to confirm there is no namespace issue with filter_plugins, like there is with modules, e.g. the setup.py issue. Otherwise network.py may be too generic. |
No, nothing planned
Can you elaborate more what you are thinking here?
I'm not sure this is needed as we the same thing can be easily accomplished in the playbook unless I'm not completely understanding what you are asking here. WRT |
filters same as modules aren't namespaced, not sure what the concern here is |
I wonder if it would be worth adding this to |