Skip to content

Commit

Permalink
[ignore] Add the option to mirror node 1 interfaces for node 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmicol committed Dec 17, 2024
1 parent 446a2ba commit af7cd75
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
22 changes: 21 additions & 1 deletion plugins/modules/ndo_virtual_port_channel_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
- The list of used Interface IDs for the second node.
- Ranges of Interface IDs can be used.
- This parameter is required when creating a new Virtual Port Channel Interface.
- If O(interfaces_node_2=[mirror]) is defined as an empty list and O(interfaces_node_1) is clearly defined,
the interfaces of O(interfaces_node_1) will be mirrored in O(interfaces_node_2).
type: list
elements: str
aliases: [ interfaces_2, members_2 ]
Expand Down Expand Up @@ -199,6 +201,21 @@
description: My new group of Ansible Interfaces for second node
state: present
- name: Update a Virtual Port Channel Interface by mirroring node 1 and node 2 interfaces
cisco.mso.ndo_port_channel_interface:
host: mso_host
username: admin
password: SomeSecretPassword
description: My Ansible Port Channel
name: ansible_virtual_port_channel_interface
node_1: 101
node_2: 102
interfaces_node_1:
- 1/1-9
- 1/11-15
interfaces_node_2: mirror
state: present
- name: Update a Virtual Port Channel Interface's name with UUID
cisco.mso.ndo_virtual_port_channel_interface:
host: mso_host
Expand Down Expand Up @@ -328,7 +345,10 @@ def main():
interfaces_node_1 = ",".join(interfaces_node_1)
interfaces_node_2 = module.params.get("interfaces_node_2")
if isinstance(interfaces_node_2, list):
interfaces_node_2 = ",".join(interfaces_node_2)
if interfaces_node_2[0] == "mirror" and interfaces_node_1:
interfaces_node_2 = interfaces_node_1
else:
interfaces_node_2 = ",".join(interfaces_node_2)
interface_policy_group = module.params.get("interface_policy_group")
interface_policy_group_uuid = module.params.get("interface_policy_group_uuid")
interface_descriptions = module.params.get("interface_descriptions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@
description: New group of Ansible interfaces test for first node
register: nm_delete_virtual_port_channel_interface_member

- name: Update virtual port channel interface members for first node and mirror them on the second node
cisco.mso.ndo_virtual_port_channel_interface: &mirror_virtual_port_channel_interface_members
<<: *delete_virtual_port_channel_interface_member
interfaces_1: 1/1-5
interfaces_2: mirror
register: nm_mirror_virtual_port_channel_interface_members

- name: Assert virtual port channel interface update tasks
assert:
that:
Expand Down Expand Up @@ -344,6 +351,16 @@
- nm_delete_virtual_port_channel_interface_member.current.interfaceDescriptions.1.nodeID == "103"
- nm_delete_virtual_port_channel_interface_member.current.interfaceDescriptions.1.interfaceID == "1/2"
- nm_delete_virtual_port_channel_interface_member.current.interfaceDescriptions.1.description == "New group of Ansible interfaces test for first node"
- nm_mirror_virtual_port_channel_interface_members is changed
- nm_mirror_virtual_port_channel_interface_members.current.node1Details.memberInterfaces == "1/1-5"
- nm_mirror_virtual_port_channel_interface_members.current.node2Details.memberInterfaces == "1/1-5"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions | length == 2
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.0.nodeID == "103"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.0.interfaceID == "1/1"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.0.description == "New group of Ansible interfaces test for first node"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.1.nodeID == "103"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.1.interfaceID == "1/2"
- nm_mirror_virtual_port_channel_interface_members.current.interfaceDescriptions.1.description == "New group of Ansible interfaces test for first node"

# QUERY

Expand Down Expand Up @@ -471,7 +488,7 @@

- name: Delete a virtual port channel interface (check_mode)
cisco.mso.ndo_virtual_port_channel_interface: &delete_virtual_port_channel_interface
<<: *delete_virtual_port_channel_interface_member
<<: *mirror_virtual_port_channel_interface_members
state: absent
check_mode: true
register: cm_delete_virtual_port_channel_interface
Expand Down

0 comments on commit af7cd75

Please sign in to comment.