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

Bug453 port group #455

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd60ba2
Modifying the net-group use in docs, it will now be under the port-pr…
ntl-afzaalarif Nov 17, 2023
81f66b3
BugFix #453 modifying the arguments for source/destination so that po…
ntl-afzaalarif Nov 17, 2023
872a669
BugFix #453 modifying the config acls.py for source/destination so th…
ntl-afzaalarif Nov 17, 2023
b086166
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
0d2e446
modified the error in doc for port_protocol option in src/dest
ntl-afzaalarif Nov 20, 2023
df839aa
Merge branch 'main' into bug453_port_group
roverflow Nov 23, 2023
e08a37e
Merge branch 'main' into bug453_port_group
ashwini-mhatre Nov 24, 2023
635dfd5
Added the unit test for port_group
ntl-afzaalarif Nov 24, 2023
609f41a
Added the unit test for port_group
ntl-afzaalarif Nov 24, 2023
e6f95f8
Added the unit test for port_group and also updated documentation
ntl-afzaalarif Nov 24, 2023
2c5854a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2023
22179c1
removed erros from test_iosxr_acls
ntl-afzaalarif Nov 24, 2023
d571894
Merge branch 'bug453_port_group' of https://github.com/ntl-afzaalarif…
ntl-afzaalarif Nov 24, 2023
284f2b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2023
f71591b
Merge branch 'main' into bug453_port_group
ntl-afzaalarif Dec 2, 2023
29fed21
Merge branch 'main' into bug453_port_group
ashwini-mhatre Dec 29, 2023
0c46662
Merge branch 'main' into bug453_port_group
ashwini-mhatre Jan 31, 2024
0c515a1
Merge branch 'main' into bug453_port_group
Ruchip16 Apr 12, 2024
789f802
Merge branch 'main' into bug453_port_group
NilashishC Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions plugins/module_utils/network/iosxr/argspec/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,18 @@ def __init__(self, **kwargs):
"host",
"prefix",
"net_group",
"port_group",
],
[
"wildcard_bits",
"any",
"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"},
Expand All @@ -85,6 +82,7 @@ def __init__(self, **kwargs):
"gt",
"lt",
"neq",
"port_group",
"range",
],
],
Expand All @@ -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"},
Expand Down Expand Up @@ -456,21 +455,18 @@ def __init__(self, **kwargs):
"host",
"prefix",
"net_group",
"port_group",
],
[
"wildcard_bits",
"any",
"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"},
Expand All @@ -481,6 +477,7 @@ def __init__(self, **kwargs):
"gt",
"lt",
"neq",
"port_group",
"range",
],
],
Expand All @@ -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"},
Expand Down
6 changes: 4 additions & 2 deletions plugins/module_utils/network/iosxr/config/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
36 changes: 29 additions & 7 deletions tests/unit/modules/network/iosxr/test_iosxr_acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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",
),
),
),
],
Expand All @@ -116,7 +131,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)

Expand Down Expand Up @@ -188,7 +204,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",
),
),
),
],
Expand All @@ -205,7 +224,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)

Expand Down Expand Up @@ -284,7 +303,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",
),
),
),
],
Expand All @@ -303,7 +325,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)

Expand Down Expand Up @@ -339,7 +361,7 @@ def test_iosxr_acls_overridden_idempotent(self):
wildcard_bits="0.0.255.255",
),
destination=dict(
port_group="portgroup1",
any="true",
),
),
],
Expand Down
Loading