Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions plugins/modules/aci_switch_policy_vpc_protection_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2017, Bruno Calogero <[email protected]>
# Copyright: (c) 2025, Eric Girard @netgirard
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
Expand Down Expand Up @@ -40,6 +41,12 @@
description:
- The ID of the Second Leaf Switch for the Explicit vPC Protection Group.
type: int
pod_id:
description:
- The pod id of the VPC member nodes.
- Accepted values range between C(1) and C(255).
- The APIC defaults to C(1) when unset during creation.
type: int
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand All @@ -62,6 +69,7 @@
link: https://developer.cisco.com/docs/apic-mim-ref/
author:
- Bruno Calogero (@brunocalogero)
- Eric Girard (@netgirard)
"""

EXAMPLES = r"""
Expand Down Expand Up @@ -224,6 +232,7 @@ def main():
vpc_domain_policy=dict(type="str", aliases=["vpc_domain_policy_name"]),
switch_1_id=dict(type="int"),
switch_2_id=dict(type="int"),
pod_id=dict(type="int"),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
name_alias=dict(type="str"),
)
Expand All @@ -242,6 +251,7 @@ def main():
vpc_domain_policy = module.params.get("vpc_domain_policy")
switch_1_id = module.params.get("switch_1_id")
switch_2_id = module.params.get("switch_2_id")
pod_id = module.params.get("pod_id")
state = module.params.get("state")
name_alias = module.params.get("name_alias")

Expand Down Expand Up @@ -271,13 +281,15 @@ def main():
fabricNodePEp=dict(
attributes=dict(
id="{0}".format(switch_1_id),
podId=pod_id,
),
),
),
dict(
fabricNodePEp=dict(
attributes=dict(
id="{0}".format(switch_2_id),
podId=pod_id,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Test code for the ACI modules
# Copyright: (c) 2017, Bruno Calogero <[email protected]>
# Copyright: (c) 2025, Eric Girard <@netgirard>

# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

Expand Down Expand Up @@ -212,3 +213,44 @@
- cm_query_non_vpc_prot_grp is not changed
- nm_query_non_vpc_prot_grp is not changed
- cm_query_non_vpc_prot_grp == nm_query_non_vpc_prot_grp

# ADD VPC PROTECTION GROUP WITH POD
- name: Add vpc protection group with pod ID (check_mode)
cisco.aci.aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_present
pod_id: 2
check_mode: true
register: cm_add_vpc_prot_grp_pod

- name: Add vpc protection group with pod ID (normal mode)
cisco.aci.aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_present
pod_id: 2
register: nm_add_vpc_prot_grp_pod

- name: Add vpc protection group with pod ID again (check_mode)
cisco.aci.aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_present
pod_id: 2
check_mode: true
register: cm_add_vpc_prot_grp_pod_again

- name: Add vpc protection group with pod ID again (normal mode)
cisco.aci.aci_switch_policy_vpc_protection_group:
<<: *aci_switch_policy_vpc_protection_group_present
pod_id: 2
register: nm_add_vpc_prot_grp_pod_again

- name: Verify addvpc protection group with pod ID tasks
ansible.builtin.assert:
that:
- cm_add_vpc_prot_grp_pod is changed
- cm_add_vpc_prot_grp_pod.previous == []
- cm_add_vpc_prot_grp_pod.proposed.0.fabricExplicitGEp.children.0.fabricNodePEp.attributes.podId == '2'
- cm_add_vpc_prot_grp_pod.proposed.0.fabricExplicitGEp.children.1.fabricNodePEp.attributes.podId == '2'
- nm_add_vpc_prot_grp_pod is changed
- nm_add_vpc_prot_grp_pod.current.0.fabricExplicitGEp.children.0.fabricNodePEp.attributes.podId == '2'
- nm_add_vpc_prot_grp_pod.current.0.fabricExplicitGEp.children.1.fabricNodePEp.attributes.podId == '2'
- nm_add_vpc_prot_grp_pod.current.0.fabricExplicitGEp.attributes.annotation == 'orchestrator:ansible'
- cm_add_vpc_prot_grp_pod_again is not changed
- nm_add_vpc_prot_grp_pod_again is not changed