From bd60ba2289002e789c3c64ba441fc964cd77a666 Mon Sep 17 00:00:00 2001 From: AfzaalArif Date: Sat, 18 Nov 2023 00:28:25 +0500 Subject: [PATCH 01/10] Modifying the net-group use in docs, it will now be under the port-protocol section instead of source/destination options. --- docs/cisco.iosxr.iosxr_acls_module.rst | 50 +++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/cisco.iosxr.iosxr_acls_module.rst b/docs/cisco.iosxr.iosxr_acls_module.rst index e5ddf3321..d9a60ea1e 100644 --- a/docs/cisco.iosxr.iosxr_acls_module.rst +++ b/docs/cisco.iosxr.iosxr_acls_module.rst @@ -233,38 +233,39 @@ Parameters
- port_group +
- string + dictionary
-
Name of port-group.
+
Specify the source port or protocol.
- + - + +
- port_protocol + eq
- dictionary + string
-
Specify the source port or protocol.
+
Match only packets on a given port number.
- + @@ -272,7 +273,7 @@ Parameters
- eq + port-group
string @@ -281,7 +282,7 @@ Parameters -
Match only packets on a given port number.
+
Match only packets with group of port numbers.
@@ -3561,38 +3562,39 @@ Parameters
- port_group + port_protocol
- string + dictionary
-
Name of port-group.
+
Specify the source port or protocol.
- + - + +
- port_protocol + eq
- dictionary + string
-
Specify the source port or protocol.
+
Match only packets on a given port number.
- + @@ -3600,7 +3602,7 @@ Parameters
- eq + gt
string @@ -3609,7 +3611,7 @@ Parameters -
Match only packets on a given port number.
+
Match only packets with a greater port number.
@@ -3620,7 +3622,7 @@ Parameters
- gt + port-group
string @@ -3629,7 +3631,7 @@ Parameters -
Match only packets with a greater port number.
+
Match only packets with group of port numbers.
From 81f66b32389cf038d5d31b09d1a1283e29ea63ae Mon Sep 17 00:00:00 2001 From: AfzaalArif Date: Sat, 18 Nov 2023 00:37:52 +0500 Subject: [PATCH 02/10] BugFix #453 modifying the arguments for source/destination so that port-group is not mutually exclusive to [host,any,address,prefix,net-group] and also removed it as direct opton of src/dest instead added port-group to argument of port_protocol --- .../module_utils/network/iosxr/argspec/acls/acls.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/module_utils/network/iosxr/argspec/acls/acls.py b/plugins/module_utils/network/iosxr/argspec/acls/acls.py index e8cb5f9cb..0a5ceef27 100644 --- a/plugins/module_utils/network/iosxr/argspec/acls/acls.py +++ b/plugins/module_utils/network/iosxr/argspec/acls/acls.py @@ -60,7 +60,6 @@ def __init__(self, **kwargs): "host", "prefix", "net_group", - "port_group", ], [ "wildcard_bits", @@ -68,13 +67,11 @@ def __init__(self, **kwargs): "host", "prefix", "net_group", - "port_group", ], ], "options": { "host": {"type": "str"}, "net_group": {"type": "str"}, - "port_group": {"type": "str"}, "address": {"type": "str"}, "any": {"type": "bool"}, "prefix": {"type": "str"}, @@ -85,6 +82,7 @@ def __init__(self, **kwargs): "gt", "lt", "neq", + "port_group", "range", ], ], @@ -93,6 +91,7 @@ def __init__(self, **kwargs): "gt": {"type": "str"}, "lt": {"type": "str"}, "neq": {"type": "str"}, + "port_group": {"type": "str"}, "range": { "options": { "end": {"type": "str"}, @@ -456,7 +455,6 @@ def __init__(self, **kwargs): "host", "prefix", "net_group", - "port_group", ], [ "wildcard_bits", @@ -464,13 +462,11 @@ def __init__(self, **kwargs): "host", "prefix", "net_group", - "port_group", ], ], "options": { "host": {"type": "str"}, "net_group": {"type": "str"}, - "port_group": {"type": "str"}, "address": {"type": "str"}, "any": {"type": "bool"}, "prefix": {"type": "str"}, @@ -481,6 +477,7 @@ def __init__(self, **kwargs): "gt", "lt", "neq", + "port_group", "range", ], ], @@ -489,6 +486,7 @@ def __init__(self, **kwargs): "gt": {"type": "str"}, "lt": {"type": "str"}, "neq": {"type": "str"}, + "port_group": {"type": "str"}, "range": { "options": { "end": {"type": "str"}, From 872a669f34413b474b9163dc75a62ad097ac9eca Mon Sep 17 00:00:00 2001 From: AfzaalArif Date: Sat, 18 Nov 2023 00:46:55 +0500 Subject: [PATCH 03/10] BugFix #453 modifying the config acls.py for source/destination so that port-group is not direct opton of src/dest instead added port-group to argument of port_protocol --- plugins/module_utils/network/iosxr/config/acls/acls.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/network/iosxr/config/acls/acls.py b/plugins/module_utils/network/iosxr/config/acls/acls.py index 0e0ea7d00..e41af7a91 100644 --- a/plugins/module_utils/network/iosxr/config/acls/acls.py +++ b/plugins/module_utils/network/iosxr/config/acls/acls.py @@ -374,8 +374,6 @@ def _compute_src_dest(dir_dict): cmd += "host {0} ".format(dir_dict["host"]) elif "net_group" in dir_dict: cmd += "net-group {0} ".format(dir_dict["net_group"]) - elif "port_group" in dir_dict: - cmd += "port-group {0} ".format(dir_dict["port_group"]) elif "prefix" in dir_dict: cmd += "{0} ".format(dir_dict["prefix"]) else: @@ -386,11 +384,15 @@ def _compute_src_dest(dir_dict): if "port_protocol" in dir_dict: protocol_range = dir_dict["port_protocol"].get("range") + port_group = dir_dict["port_protocol"].get("port_group") if protocol_range: cmd += "range {0} {1} ".format( protocol_range["start"], protocol_range["end"], ) + elif port_group: + for key, value in iteritems(dir_dict["port_protocol"]): + cmd += "port-group {1} ".format(key, value) else: for key, value in iteritems(dir_dict["port_protocol"]): cmd += "{0} {1} ".format(key, value) From b086166b19087bf7fec62cb7abbefc882c2bfb08 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 20:02:27 +0000 Subject: [PATCH 04/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/cisco.iosxr.iosxr_acls_module.rst | 50 +++++++++++++------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/docs/cisco.iosxr.iosxr_acls_module.rst b/docs/cisco.iosxr.iosxr_acls_module.rst index d9a60ea1e..e5ddf3321 100644 --- a/docs/cisco.iosxr.iosxr_acls_module.rst +++ b/docs/cisco.iosxr.iosxr_acls_module.rst @@ -233,39 +233,38 @@ Parameters
- + port_group
- dictionary + string
-
Specify the source port or protocol.
+
Name of port-group.
- - + - +
- eq + port_protocol
- string + dictionary
-
Match only packets on a given port number.
+
Specify the source port or protocol.
- + @@ -273,7 +272,7 @@ Parameters
- port-group + eq
string @@ -282,7 +281,7 @@ Parameters -
Match only packets with group of port numbers.
+
Match only packets on a given port number.
@@ -3562,39 +3561,38 @@ Parameters
- port_protocol + port_group
- dictionary + string
-
Specify the source port or protocol.
+
Name of port-group.
- - + - +
- eq + port_protocol
- string + dictionary
-
Match only packets on a given port number.
+
Specify the source port or protocol.
- + @@ -3602,7 +3600,7 @@ Parameters
- gt + eq
string @@ -3611,7 +3609,7 @@ Parameters -
Match only packets with a greater port number.
+
Match only packets on a given port number.
@@ -3622,7 +3620,7 @@ Parameters
- port-group + gt
string @@ -3631,7 +3629,7 @@ Parameters -
Match only packets with group of port numbers.
+
Match only packets with a greater port number.
From 0d2e44638585d8d627d8e2919b954be5b3e3bf13 Mon Sep 17 00:00:00 2001 From: AfzaalArif Date: Mon, 20 Nov 2023 18:48:37 +0500 Subject: [PATCH 05/10] modified the error in doc for port_protocol option in src/dest --- docs/cisco.iosxr.iosxr_acls_module.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cisco.iosxr.iosxr_acls_module.rst b/docs/cisco.iosxr.iosxr_acls_module.rst index d9a60ea1e..f01ed1812 100644 --- a/docs/cisco.iosxr.iosxr_acls_module.rst +++ b/docs/cisco.iosxr.iosxr_acls_module.rst @@ -233,7 +233,7 @@ Parameters
- + port_protocol
dictionary From 635dfd574ca0382f7338e8d1272fe670569b0474 Mon Sep 17 00:00:00 2001 From: ntl-afzaalarif Date: Fri, 24 Nov 2023 21:00:52 +0500 Subject: [PATCH 06/10] Added the unit test for port_group --- .../modules/network/iosxr/test_iosxr_acls.py | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acls.py b/tests/unit/modules/network/iosxr/test_iosxr_acls.py index 181b239d8..29f538580 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acls.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acls.py @@ -100,7 +100,22 @@ def test_iosxr_acls_merged(self): wildcard_bits="0.0.255.255", ), destination=dict( - port_group="portgroup1", + prefix="192.168.0.0/24", + ), + ), + dict( + sequence="60", + grant="deny", + protocol="ipv4", + source=dict( + address="10.233.0.0", + wildcard_bits="0.0.255.255", + ), + destination=dict( + host="1.1.1.1", + port_protocol=dict( + port_group="portgroup1", + ), ), ), ], @@ -115,7 +130,8 @@ def test_iosxr_acls_merged(self): "ipv4 access-list acl_1", "30 permit ospf 192.168.1.0 0.0.0.255 any log", "40 deny ipv4 10.233.0.0 0.0.255.255 net-group netgroup1", - "50 deny ipv4 10.233.0.0 0.0.255.255 port-group portgroup1", + "50 deny ipv4 10.233.0.0 0.0.255.255 192.168.0.0 0.0.0.255", + "60 deny ipv4 10.233.0.0 0.0.255.255 net-group netgroup1 port-group portgroup1", ] self.execute_module(changed=True, commands=commands) @@ -187,7 +203,10 @@ def test_iosxr_acls_replaced(self): wildcard_bits="0.0.255.255", ), destination=dict( - port_group="portgroup1", + host="1.1.1.1", + port_protocol=dict( + port_group="portgroup1", + ), ), ), ], @@ -204,7 +223,7 @@ def test_iosxr_acls_replaced(self): "no 20", "30 permit ospf 10.0.0.0 0.255.255.255 any log", "40 deny ipv4 10.233.0.0 0.0.255.255 net-group netgroup1", - "50 deny ipv4 10.233.0.0 0.0.255.255 port-group portgroup1", + "50 deny ipv4 10.233.0.0 0.0.255.255 host 1.1.1.1 port-group portgroup1", ] self.execute_module(changed=True, commands=commands) @@ -283,7 +302,10 @@ def test_iosxr_acls_overridden(self): wildcard_bits="0.0.255.255", ), destination=dict( - port_group="portgroup1", + host="1.1.1.1", + port_protocol=dict( + port_group="portgroup1", + ), ), ), ], @@ -302,7 +324,7 @@ def test_iosxr_acls_overridden(self): "no 20", "40 permit ospf any any log", "50 deny ipv4 10.233.0.0 0.0.255.255 net-group netgroup1", - "60 deny ipv4 10.233.0.0 0.0.255.255 port-group portgroup1", + "60 deny ipv4 10.233.0.0 0.0.255.255 host 1.1.1.1 port-group portgroup1", ] self.execute_module(changed=True, commands=commands) @@ -338,7 +360,7 @@ def test_iosxr_acls_overridden_idempotent(self): wildcard_bits="0.0.255.255", ), destination=dict( - port_group="portgroup1", + any="true", ), ), ], From 609f41ab2e778b86a0e452ba21a4ff19f1c2e97e Mon Sep 17 00:00:00 2001 From: ntl-afzaalarif Date: Fri, 24 Nov 2023 21:03:36 +0500 Subject: [PATCH 07/10] Added the unit test for port_group --- tests/unit/modules/network/iosxr/test_iosxr_acls.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acls.py b/tests/unit/modules/network/iosxr/test_iosxr_acls.py index 29f538580..d42ef94bd 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acls.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acls.py @@ -343,6 +343,9 @@ def test_iosxr_acls_overridden_idempotent(self): sequence="10", grant="deny", protocol="ipv4", + source=dict( + address="10.233.0.0", + wildcard_bits="0.0.255.255", source=dict( address="10.233.0.0", wildcard_bits="0.0.255.255", @@ -530,9 +533,6 @@ def test_iosxr_acls_replaced_remark(self): aces=[ dict( sequence="10", - grant="permit", - protocol="ipv4", - source=dict( any=True, ), destination=dict( From 2c5854a9352df823f470f9387d3c05302f94755b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:29:55 +0000 Subject: [PATCH 08/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/cisco.iosxr.iosxr_acls_module.rst | 74 +++++++++++++------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/docs/cisco.iosxr.iosxr_acls_module.rst b/docs/cisco.iosxr.iosxr_acls_module.rst index 0c8b795bf..32cf48121 100644 --- a/docs/cisco.iosxr.iosxr_acls_module.rst +++ b/docs/cisco.iosxr.iosxr_acls_module.rst @@ -233,39 +233,38 @@ Parameters
- port_protocol + port_group
- dictionary + string
-
Specify the source port or protocol.
+
Name of port-group.
- - + - +
- eq + port_protocol
- string + dictionary
-
Match only packets on a given port number.
+
Specify the source port or protocol.
- + @@ -273,7 +272,7 @@ Parameters
- gt + eq
string @@ -282,7 +281,7 @@ Parameters -
Match only packets with a greater port number.
+
Match only packets on a given port number.
@@ -293,7 +292,7 @@ Parameters
- lt + gt
string @@ -302,7 +301,7 @@ Parameters -
Match only packets with a lower port number.
+
Match only packets with a greater port number.
@@ -313,7 +312,7 @@ Parameters
- neq + lt
string @@ -322,10 +321,10 @@ Parameters -
Match only packets not on a given port number.
+
Match only packets with a lower port number.
- + @@ -333,7 +332,7 @@ Parameters
- port-group + neq
string @@ -342,7 +341,7 @@ Parameters -
Match only packets in a given set/group of ports.
+
Match only packets not on a given port number.
@@ -3562,39 +3561,38 @@ Parameters
- port_protocol + port_group
- dictionary + string
-
Specify the source port or protocol.
+
Name of port-group.
- - + - +
- eq + port_protocol
- string + dictionary
-
Match only packets on a given port number.
+
Specify the source port or protocol.
- + @@ -3602,7 +3600,7 @@ Parameters
- gt + eq
string @@ -3611,7 +3609,7 @@ Parameters -
Match only packets with a greater port number.
+
Match only packets on a given port number.
@@ -3622,7 +3620,7 @@ Parameters
- lt + gt
string @@ -3631,7 +3629,7 @@ Parameters -
Match only packets with a lower port number.
+
Match only packets with a greater port number.
@@ -3642,7 +3640,7 @@ Parameters
- neq + lt
string @@ -3651,10 +3649,10 @@ Parameters -
Match only packets not on a given port number.
+
Match only packets with a lower port number.
- + @@ -3662,7 +3660,7 @@ Parameters
- port-group + neq
string @@ -3671,7 +3669,7 @@ Parameters -
Match only packets in a given set/group of ports.
+
Match only packets not on a given port number.
From 22179c173945148d3adaa70aad1c8705a866f270 Mon Sep 17 00:00:00 2001 From: ntl-afzaalarif Date: Fri, 24 Nov 2023 22:02:36 +0500 Subject: [PATCH 09/10] removed erros from test_iosxr_acls --- tests/unit/modules/network/iosxr/test_iosxr_acls.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acls.py b/tests/unit/modules/network/iosxr/test_iosxr_acls.py index d42ef94bd..8de4de9aa 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acls.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acls.py @@ -343,9 +343,6 @@ def test_iosxr_acls_overridden_idempotent(self): sequence="10", grant="deny", protocol="ipv4", - source=dict( - address="10.233.0.0", - wildcard_bits="0.0.255.255", source=dict( address="10.233.0.0", wildcard_bits="0.0.255.255", @@ -533,6 +530,9 @@ def test_iosxr_acls_replaced_remark(self): aces=[ dict( sequence="10", + grant="permit", + protocol="ipv4", + source=dict( any=True, ), destination=dict( @@ -551,4 +551,4 @@ def test_iosxr_acls_replaced_remark(self): "ipv4 access-list ACL-TEST", "10 permit ipv4 any host 1.1.1.1", ] - self.execute_module(changed=True, commands=commands) + self.execute_module(changed=True, commands=commands) \ No newline at end of file From 284f2b8ad4737b89b545738c3daa93bf13ea6f19 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:05:05 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/modules/network/iosxr/test_iosxr_acls.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acls.py b/tests/unit/modules/network/iosxr/test_iosxr_acls.py index 8de4de9aa..30ed0f8e0 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acls.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acls.py @@ -115,7 +115,7 @@ def test_iosxr_acls_merged(self): host="1.1.1.1", port_protocol=dict( port_group="portgroup1", - ), + ), ), ), ], @@ -305,7 +305,7 @@ def test_iosxr_acls_overridden(self): host="1.1.1.1", port_protocol=dict( port_group="portgroup1", - ), + ), ), ), ], @@ -551,4 +551,4 @@ def test_iosxr_acls_replaced_remark(self): "ipv4 access-list ACL-TEST", "10 permit ipv4 any host 1.1.1.1", ] - self.execute_module(changed=True, commands=commands) \ No newline at end of file + self.execute_module(changed=True, commands=commands)