Skip to content

Commit

Permalink
[ignore] Modify test case and logic for ndo_port_channel_interface mo…
Browse files Browse the repository at this point in the history
…dule when handling null value.
  • Loading branch information
gmicol committed Dec 17, 2024
1 parent 263ef9a commit af83ff4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugins/modules/ndo_port_channel_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
description:
- The UUID of the Port Channel Interface.
- This parameter can be used instead of O(port_channel_interface)
when an existing Virtual Port Channel Interface is updated.
when an existing Port Channel Interface is updated.
- This parameter is required when parameter O(port_channel_interface) is updated.
type: str
aliases: [ port_channel_interface_uuid, port_channel_uuid ]
Expand Down Expand Up @@ -303,7 +303,7 @@ def main():
existing_port_channel_interfaces = mso_template.template.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", [])
object_description = "Port Channel Interface"

if state in ["query", "absent"] and existing_port_channel_interfaces == []:
if state in ["query", "absent"] and not existing_port_channel_interfaces:
mso.exit_json()
elif state == "query" and not (name or uuid):
mso.existing = existing_port_channel_interfaces
Expand Down Expand Up @@ -361,7 +361,7 @@ def main():

if not module.check_mode and ops:
response = mso.request(mso_template.template_path, method="PATCH", data=ops)
port_channel_interfaces = response.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", [])
port_channel_interfaces = response.get("fabricResourceTemplate", {}).get("template", {}).get("portChannels", []) or []
match = mso_template.get_object_by_key_value_pairs(
object_description,
port_channel_interfaces,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@
state: query
register: query_one

- name: Query a port channel with template_name and UUID
cisco.mso.ndo_tenant_custom_qos_policy: &query_port_channel_interface_uuid
<<: *create_port_channel_interface_2
uuid: '{{ query_one.current.uuid }}'
name: '{{ fakevar | default(omit)}}'
state: query
register: query_one_uuid

- name: Query all port channel interfaces in the template
cisco.mso.ndo_port_channel_interface:
<<: *mso_info
Expand All @@ -315,6 +323,8 @@
that:
- query_one is not changed
- query_one.current.name == "ansible_port_channel_interface_2"
- query_one_uuid is not changed
- query_one_uuid.current.name == "ansible_port_channel_interface_2"
- query_all is not changed
- query_all.current | length == 2
- query_all.current.0.name == "ansible_port_channel_interface_changed"
Expand Down Expand Up @@ -396,7 +406,7 @@
that:
- nm_create_missing_node.msg == "Missing parameter 'node' for creating a Port Channel Interface"
- nm_create_invalid_range.msg == "Range start is greater than or equal to range stop for range of IDs '1/2-1'"
- nm_create_invalid_range.msg == "Incorrect interface ID or range of IDs. Got 'invalid_id'"
- nm_create_invalid_id.msg == "Incorrect interface ID or range of IDs. Got 'invalid_id'"
- 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"

# DELETE
Expand All @@ -418,6 +428,12 @@
<<: *delete_port_channel_interface
register: nm_delete_port_channel_interface_again

- name: Delete a port channel interface with UUID
cisco.mso.ndo_port_channel_interface:
<<: *query_port_channel_interface_uuid
state: absent
register: nm_delete_port_channel_interface_uuid

- name: Assert port channel interface deletion tasks
assert:
that:
Expand All @@ -430,6 +446,9 @@
- nm_delete_port_channel_interface_again is not changed
- nm_delete_port_channel_interface_again.previous == {}
- nm_delete_port_channel_interface_again.current == {}
- nm_delete_port_channel_interface_uuid is changed
- nm_delete_port_channel_interface_uuid.previous.name == "ansible_port_channel_interface_2"
- nm_delete_port_channel_interface_uuid.current == {}

# ERRORS AND NO PORT CHANNEL INTERFACES FOUND

Expand Down

0 comments on commit af83ff4

Please sign in to comment.