Skip to content

Commit

Permalink
[acl_interfaces] facts fixed and optimisation (#535)
Browse files Browse the repository at this point in the history
[acl_interfaces] facts fixed and optimisation 

SUMMARY

Depends-On: ansible/ansible-zuul-jobs#1451
Depends-On: ansible/ansible-zuul-jobs#1466
Add parsers for RM and fix facts generation using a specific pattern to config command.

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ios_acl_interfaces
ADDITIONAL INFORMATION

Reviewed-by: Ashwini Mhatre <[email protected]>
  • Loading branch information
KB-perByte authored Apr 8, 2022
1 parent 5b1a470 commit fb7be2c
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 587 deletions.
5 changes: 5 additions & 0 deletions changelogs/fragments/acl_interfaces_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bugfixes:
- "`acl_interfaces` - optimization and bugfixes."
trivial:
- "`acl_interfaces` - fix tests for action states."
76 changes: 64 additions & 12 deletions docs/cisco.ios.ios_acl_interfaces_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Parameters
<div>The states <em>rendered</em>, <em>gathered</em> and <em>parsed</em> does not perform any change on the device.</div>
<div>The state <em>rendered</em> will transform the configuration in <code>config</code> option to platform specific CLI commands which will be returned in the <em>rendered</em> key within the result. For state <em>rendered</em> active connection to remote host is not required.</div>
<div>The state <em>gathered</em> will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the <em>gathered</em> key within the result.</div>
<div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into JSON format as per the resource module parameters and the value is returned in the <em>parsed</em> key within the result. The value of <code>running_config</code> option should be the same format as the output of command <em>show running-config | include ip route|ipv6 route</em> executed on device. For state <em>parsed</em> active connection to remote host is not required.</div>
<div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into JSON format as per the resource module parameters and the value is returned in the <em>parsed</em> key within the result. The value of <code>running_config</code> option should be the same format as the output of command <em>show running-config | include ^interface|ip access-group|ipv6 traffic-filter</em> executed on device. For state <em>parsed</em> active connection to remote host is not required.</div>
</td>
</tr>
</table>
Expand All @@ -220,7 +220,7 @@ Notes
-----

.. note::
- Tested against Cisco IOSv Version 15.2 on VIRL
- Tested against Cisco IOSv Version 15.2
- This module works with connection ``network_cli``. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html


Expand Down Expand Up @@ -681,15 +681,15 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<b>after</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
<span style="color: purple">dictionary</span>
</div>
</td>
<td>when changed</td>
<td>
<div>The configuration as structured data after module completion.</div>
<div>The resulting configuration after module execution.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format of the parameters above.</div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
</td>
</tr>
<tr>
Expand All @@ -698,15 +698,15 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<b>before</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
<span style="color: purple">dictionary</span>
</div>
</td>
<td>always</td>
<td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
<td>
<div>The configuration as structured data prior to module invocation.</div>
<div>The configuration prior to the module execution.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format of the parameters above.</div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
</td>
</tr>
<tr>
Expand All @@ -718,12 +718,63 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">list</span>
</div>
</td>
<td>always</td>
<td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
<td>
<div>The set of commands pushed to the remote device.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet0/1&#x27;, &#x27;no ip access-group 123 out&#x27;, &#x27;no ipv6 traffic-filter test_v6 out&#x27;]</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>gathered</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>when <em>state</em> is <code>gathered</code></td>
<td>
<div>Facts about the network resource gathered from the remote device as structured data.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>parsed</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>when <em>state</em> is <code>parsed</code></td>
<td>
<div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>rendered</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>when <em>state</em> is <code>rendered</code></td>
<td>
<div>The set of commands pushed to the remote device</div>
<div>The provided configuration in the task rendered in device-native format (offline).</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet0/1&#x27;, &#x27;ip access-group 110 in&#x27;, &#x27;ipv6 traffic-filter test_v6 out&#x27;]</div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet0/1&#x27;, &#x27;no ip access-group 123 out&#x27;, &#x27;no ipv6 traffic-filter test_v6 out&#x27;]</div>
</td>
</tr>
</table>
Expand All @@ -738,3 +789,4 @@ Authors
~~~~~~~

- Sumit Jaiswal (@justjais)
- Sagar Paul (@KB-perByte)
Original file line number Diff line number Diff line change
@@ -1,82 +1,78 @@
#
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# Copyright 2022 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type

#############################################
# WARNING #
#############################################
#
# This file is auto generated by the resource
# module builder playbook.
# This file is auto generated by the
# cli_rm_builder.
#
# Do not edit this file manually.
# Manually editing this file is not advised.
#
# Changes to this file will be over written
# by the resource module builder.
#
# Changes should be made in the model used to
# generate this file or in the resource module
# builder template.
# To update the argspec make the desired changes
# in the module docstring and re-run
# cli_rm_builder.
#
#############################################

"""
The arg spec for the ios_acl_interfaces module
"""

from __future__ import absolute_import, division, print_function

__metaclass__ = type


class Acl_InterfacesArgs(object):
class Acl_interfacesArgs(object): # pylint: disable=R0903
"""The arg spec for the ios_acl_interfaces module"""

argument_spec = {
"config": {
"type": "list",
"elements": "dict",
"options": {
"name": {"required": True, "type": "str"},
"name": {"type": "str", "required": True},
"access_groups": {
"type": "list",
"elements": "dict",
"options": {
"afi": {
"type": "str",
"required": True,
"choices": ["ipv4", "ipv6"],
"type": "str",
},
"acls": {
"type": "list",
"elements": "dict",
"options": {
"name": {"required": True, "type": "str"},
"name": {"type": "str", "required": True},
"direction": {
"type": "str",
"required": True,
"choices": ["in", "out"],
"type": "str",
},
},
},
},
},
},
"type": "list",
},
"running_config": {"type": "str"},
"state": {
"type": "str",
"choices": [
"merged",
"replaced",
"overridden",
"deleted",
"gathered",
"rendered",
"parsed",
"rendered",
],
"default": "merged",
"type": "str",
},
}
} # pylint: disable=C0301
Loading

0 comments on commit fb7be2c

Please sign in to comment.