Skip to content

Commit

Permalink
Merge branch 'main' into ana_443
Browse files Browse the repository at this point in the history
  • Loading branch information
NilashishC authored May 22, 2024
2 parents c2b9d6e + 3e0ef7d commit af7cc4d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: update-docs

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-symlinks
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
args: ["--filter-files"]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.4.2
hooks:
- id: black

Expand Down
4 changes: 4 additions & 0 deletions changelogs/fragments/route_maps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- "route_maps - support simple route-maps that do not contain set or match statements.
it allows for the creation and management of purely basic route-map entries like 'route-map test-1 permit 10'."
12 changes: 6 additions & 6 deletions plugins/module_utils/network/nxos/config/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ def convert_values(self, want):
end = int(ace[x]["port_protocol"]["range"]["end"])

if st in port_protocol.keys():
ace[x]["port_protocol"]["range"][
"start"
] = port_protocol[st]
ace[x]["port_protocol"]["range"]["start"] = (
port_protocol[st]
)
if end in port_protocol.keys():
ace[x]["port_protocol"]["range"][
"end"
] = port_protocol[end]
ace[x]["port_protocol"]["range"]["end"] = (
port_protocol[end]
)
return want

def set_state(self, want, have):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, module):
tmplt=Route_mapsTemplate(),
)
self.linear_parsers = [
"route_map",
"description",
"continue_sequence",
"set.as_path.prepend.last_as",
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/nxos_file_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ def copy_file_from_remote(self, local, local_file_directory, file_system):
self.result["copy_cmd"] = copy_cmd
pulled = self._connection.pull_file(command=copy_cmd, remotepassword=rserverpassword)
if pulled:
self.result[
"transfer_status"
] = "Received: File copied/pulled to nxos device from remote scp server."
self.result["transfer_status"] = (
"Received: File copied/pulled to nxos device from remote scp server."
)
else:
self.result["failed"] = True

Expand Down
89 changes: 89 additions & 0 deletions tests/unit/modules/network/nxos/test_nxos_route_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,3 +1493,92 @@ def test_nxos_route_maps_extcomm_rt(self):
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_merged(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-1",
entries=[
dict(
action="permit",
sequence=20,
),
],
),
],
state="merged",
),
)
commands = [
"route-map test-1 permit 20",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_overridden(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-2",
entries=[
dict(
action="permit",
sequence=10,
),
],
),
],
state="overridden",
),
)
commands = [
"no route-map test-1 permit 10",
"route-map test-2 permit 10",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

def test_nxos_route_maps_without_match_and_set_replaced(self):
self.get_config.return_value = dedent(
"""\
route-map test-1 permit 10
route-map test-1 permit 20
route-map test-2 permit 10
""",
)
set_module_args(
dict(
config=[
dict(
route_map="test-1",
entries=[
dict(
action="permit",
sequence=30,
),
],
),
],
state="replaced",
),
)
commands = [
"no route-map test-1 permit 10",
"no route-map test-1 permit 20",
"route-map test-1 permit 30",
]
result = self.execute_module(changed=True)
self.assertEqual(set(result["commands"]), set(commands))

0 comments on commit af7cc4d

Please sign in to comment.