Skip to content

Commit b2d05b4

Browse files
committed
[ignore] Modify test case and logic for ndo_port_channel_interface module when handling null value.
1 parent 263ef9a commit b2d05b4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

plugins/modules/ndo_port_channel_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def main():
303303
existing_port_channel_interfaces = mso_template.template.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", [])
304304
object_description = "Port Channel Interface"
305305

306-
if state in ["query", "absent"] and existing_port_channel_interfaces == []:
306+
if state in ["query", "absent"] and not existing_port_channel_interfaces:
307307
mso.exit_json()
308308
elif state == "query" and not (name or uuid):
309309
mso.existing = existing_port_channel_interfaces
@@ -361,7 +361,7 @@ def main():
361361

362362
if not module.check_mode and ops:
363363
response = mso.request(mso_template.template_path, method="PATCH", data=ops)
364-
port_channel_interfaces = response.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", [])
364+
port_channel_interfaces = response.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", []) or []
365365
match = mso_template.get_object_by_key_value_pairs(
366366
object_description,
367367
port_channel_interfaces,

tests/integration/targets/ndo_port_channel_interface/tasks/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
that:
397397
- nm_create_missing_node.msg == "Missing parameter 'node' for creating a Port Channel Interface"
398398
- nm_create_invalid_range.msg == "Range start is greater than or equal to range stop for range of IDs '1/2-1'"
399-
- nm_create_invalid_range.msg == "Incorrect interface ID or range of IDs. Got 'invalid_id'"
399+
- nm_create_invalid_id.msg == "Incorrect interface ID or range of IDs. Got 'invalid_id'"
400400
- nm_create_without_existing_policy.msg == "Provided Interface Policy Groups with '[KVPair(key='name', value='ansible_test_interface_policy_group_port_channel')]' not matching existing object(s): ansible_test_interface_policy_group_port_channel_2"
401401

402402
# DELETE
@@ -418,6 +418,12 @@
418418
<<: *delete_port_channel_interface
419419
register: nm_delete_port_channel_interface_again
420420

421+
- name: Delete a second port channel interface
422+
cisco.mso.ndo_port_channel_interface:
423+
<<: *create_port_channel_interface_2
424+
state: absent
425+
register: nm_delete_port_channel_interface_2
426+
421427
- name: Assert port channel interface deletion tasks
422428
assert:
423429
that:
@@ -430,6 +436,9 @@
430436
- nm_delete_port_channel_interface_again is not changed
431437
- nm_delete_port_channel_interface_again.previous == {}
432438
- nm_delete_port_channel_interface_again.current == {}
439+
- nm_delete_port_channel_interface_2 is changed
440+
- nm_delete_port_channel_interface_2.previous.name == "ansible_port_channel_interface_2"
441+
- nm_delete_port_channel_interface_2.current == {}
433442

434443
# ERRORS AND NO PORT CHANNEL INTERFACES FOUND
435444

0 commit comments

Comments
 (0)