Skip to content

Commit

Permalink
[ignore_changes] Removed extra tasks from tests and updated documenta…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
anvitha-jain committed Jan 9, 2025
1 parent e837262 commit e41c811
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
19 changes: 9 additions & 10 deletions plugins/modules/ndo_physical_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
interface_descriptions:
description:
- The interface settings defined in the interface settings policy will be applied to the interfaces on the node IDs configured in C(nodes).
- This parameter when set to an empty list during an update will clear all the existing interface descriptions.
- The API will trigger an error when there are duplicate interface IDs in the list.
type: list
elements: dict
suboptions:
Expand Down Expand Up @@ -297,6 +299,7 @@ def main():
[KVPair("uuid", uuid) if uuid else KVPair("name", name)],
)
if match:
physical_interface_attrs_path = "{0}/{1}".format(path, match.index)
mso.existing = mso.previous = copy.deepcopy(match.details)
else:
mso.existing = mso.previous = existing_physical_interfaces
Expand All @@ -310,10 +313,6 @@ def main():
fabric_policy_template.validate_template("fabricPolicy")
physical_policy_uuid = fabric_policy_template.get_interface_policy_group_uuid(physical_policy.get("name"))

if mso.existing:
proposed_payload = copy.deepcopy(mso.existing)
mso_values_remove = list()

mso_values = dict(
name=name,
description=description,
Expand All @@ -329,19 +328,19 @@ def main():
mso_values["breakoutMode"] = breakout_mode

if interface_descriptions:
mso_values["interfaceDescriptions"] = format_interface_descriptions(interface_descriptions, "")
mso_values["interfaceDescriptions"] = format_interface_descriptions(mso, interface_descriptions, "")

if match:
if mso.existing:
proposed_payload = copy.deepcopy(mso.existing)
mso_values_remove = list()

if physical_interface_type and match.details.get("policyGroupType") != physical_interface_type:
mso.fail_json(msg="ERROR: Physical Interface type cannot be changed.")

update_path = "{0}/{1}".format(path, match.index)

if interface_descriptions == [] and proposed_payload.get("interfaceDescriptions"):
mso_values_remove.append("interfaceDescriptions")

append_update_ops_data(ops, match.details, update_path, mso_values, mso_values_remove)
append_update_ops_data(ops, match.details, physical_interface_attrs_path, mso_values, mso_values_remove)
mso.sanitize(match.details, collate=True)

else:
Expand All @@ -356,7 +355,7 @@ def main():

elif state == "absent":
if match:
ops.append(dict(op="remove", path="{0}/{1}".format(path, match.index)))
ops.append(dict(op="remove", path=physical_interface_attrs_path))

if not module.check_mode and ops:
response = mso.request(mso_template.template_path, method="PATCH", data=ops)
Expand Down
37 changes: 29 additions & 8 deletions tests/integration/targets/ndo_physical_interface/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
state: query
register: version

- name: Execute tasks only for MSO version > 4.3
when: version.current.version is version('4.3', '>=')
- name: Execute tasks only for MSO version > 4.4
when: version.current.version is version('4.4', '>=')
block:
- name: Remove fabric resource policy template
cisco.mso.ndo_template: &template_absent
Expand Down Expand Up @@ -331,7 +331,32 @@
- query_physical_interface_with_uuid.current.interfaceDescriptions[0].interfaceID == "1/1"
- query_physical_interface_with_uuid.current.interfaceDescriptions[0].description == "First interface"
- query_physical_interface_with_uuid.current.uuid is defined
# - query_all_physical_interfaces.current | length == 3
- query_all_physical_interfaces.current | length == 3

- name: Update interface descriptions of Physical Interface of type 'breakout'
cisco.mso.ndo_physical_interface:
<<: *update_physical_interface_uuid
interface_descriptions:
- interface_id: "1/1"
description: "Updated interface description"
- interface_id: "1/2"
description: "Updated interface description 2"
register: update_interface_description

- name: Assert updating with interface descriptions of Physical Interface of type 'breakout'
ansible.builtin.assert:
that:
- update_interface_description is changed
- update_interface_description.previous.name == "ansible_physical_interface_changed"
- update_interface_description.current.name == "ansible_physical_interface_changed"
- update_interface_description.previous.breakoutMode == "4x25G"
- update_interface_description.current.breakoutMode == "4x25G"
- update_interface_description.previous.interfaceDescriptions | length == 1
- update_interface_description.current.interfaceDescriptions | length == 2
- update_interface_description.current.interfaceDescriptions[0].interfaceID == "1/1"
- update_interface_description.current.interfaceDescriptions[0].description == "Updated interface description"
- update_interface_description.current.interfaceDescriptions[1].interfaceID == "1/2"
- update_interface_description.current.interfaceDescriptions[1].description == "Updated interface description 2"

# Remove interface descriptions
- name: Update Physical Interface of type 'breakout' by removing interface interface_descriptions
Expand All @@ -348,7 +373,7 @@
- rm_physical_interface_name_interface_descriptions.current.name == "ansible_physical_interface_changed"
- rm_physical_interface_name_interface_descriptions.previous.breakoutMode == "4x25G"
- rm_physical_interface_name_interface_descriptions.current.breakoutMode == "4x25G"
- rm_physical_interface_name_interface_descriptions.previous.interfaceDescriptions | length == 1
- rm_physical_interface_name_interface_descriptions.previous.interfaceDescriptions | length == 2
- rm_physical_interface_name_interface_descriptions.previous.uuid is defined
- rm_physical_interface_name_interface_descriptions.current.uuid is defined
- rm_physical_interface_name_interface_descriptions.current.interfaceDescriptions == None
Expand Down Expand Up @@ -437,10 +462,6 @@
- nm_delete_physical_interface_again.previous == nm_delete_physical_interface_again.current == {}
- nm_delete_physical_interface_again.current.uuid is not defined

- name: Query all tests
cisco.mso.ndo_physical_interface:
<<: *query_all_physical_interface

- name: Delete Physical Interface of type 'breakout' with UUID
cisco.mso.ndo_physical_interface:
<<: *mso_info
Expand Down

0 comments on commit e41c811

Please sign in to comment.