Skip to content

Commit

Permalink
[minor_change] Add aci_action_rule_set_as_path and aci_action_rule_se…
Browse files Browse the repository at this point in the history
…t_as_path_asn as new modules.
  • Loading branch information
gmicol committed Oct 13, 2023
1 parent 60a78c8 commit d0edb3e
Show file tree
Hide file tree
Showing 4 changed files with 685 additions and 21 deletions.
55 changes: 39 additions & 16 deletions plugins/modules/aci_action_rule_additional_communities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: (c) 2023, Gaspard Micol (@gmicol) <[email protected]>
# 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 All @@ -12,25 +13,35 @@
DOCUMENTATION = r"""
---
module: aci_tenant_action_rule_profile
short_description: Manage Set Additional Communities (rtctrl:SetAddComm)
short_description: Manage Action Rules based on Additional Communities (rtctrl:SetAddComm)
description:
- Set additional communities for the action rule profiles on Cisco ACI fabrics.
options:
tenant:
description:
- The name of the tenant.
type: str
aliases: [ tenant_name ]
action_rule:
description:
- The name of the action rule profile.
type: str
aliases: [ action_rule_name, name ]
aliases: [ action_rule_name ]
community:
description:
- The community value
type: str
set_criteria:
description:
- The community criteria.
- The option to append or replace the community value.
type: str
choices: [ append, replace, none ]
description:
description:
- The description for the action rule profile.
type: str
aliases: [ descr ]
tenant:
description:
- The name of the tenant.
type: str
aliases: [ tenant_name ]
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand All @@ -47,10 +58,11 @@
- cisco.aci.annotation
notes:
- The C(tenant) used must exist before using this module in your playbook.
The M(cisco.aci.aci_tenant) module can be used for this.
- The C(tenant) and the C(action_rule) used must exist before using this module in your playbook.
The M(cisco.aci.aci_tenant) and M(cisco.aci.aci_tenant_action_rule_profile) modules can be used for this.
seealso:
- module: cisco.aci.aci_tenant
- module: cisco.aci.aci_tenant_action_rule_profile
- name: APIC Management Information Model reference
description: More information about the internal APIC class B(rtctrl:SetAddComm).
link: https://developer.cisco.com/docs/apic-mim-ref/
Expand Down Expand Up @@ -213,8 +225,10 @@ def main():
argument_spec = aci_argument_spec()
argument_spec.update(aci_annotation_spec())
argument_spec.update(
action_rule=dict(type="str", aliases=["action_rule_name", "name"]), # Not required for querying all objects
tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects
action_rule=dict(type="str", aliases=["action_rule_name", "name"]), # Not required for querying all objects
community=dict(type="str"),
set_criteria=dict(type="str", choices=["append", "replace", "none"]),
description=dict(type="str", aliases=["descr"]),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
name_alias=dict(type="str"),
Expand All @@ -224,15 +238,17 @@ def main():
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
["state", "absent", ["action_rule", "tenant"]],
["state", "present", ["action_rule", "tenant"]],
["state", "absent", ["action_rule", "tenant", "community"]],
["state", "present", ["action_rule", "tenant", "community"]],
],
)

action_rule = module.params.get("action_rule")
community = module.params.get("community")
set_criteria = module.params.get("set_criteria")
description = module.params.get("description")
state = module.params.get("state")
tenant = module.params.get("tenant")
action_rule = module.params.get("action_rule")
name_alias = module.params.get("name_alias")

aci = ACIModule(module)
Expand All @@ -249,21 +265,28 @@ def main():
module_object=action_rule,
target_filter={"name": action_rule},
),
subclass_2=dict(
aci_class="rtctrlSetAddComm",
aci_rn="saddcomm-{0}".format(community),
module_object=community,
target_filter={"community": community},
),
)

aci.get_existing()

if state == "present":
aci.payload(
aci_class="rtctrlAttrP",
aci_class="rtctrlSetAddComm",
class_config=dict(
name=action_rule,
community=community,
setCriteria=set_criteria,
descr=description,
nameAlias=name_alias,
),
)

aci.get_diff(aci_class="rtctrlAttrP")
aci.get_diff(aci_class="rtctrlSetAddComm")

aci.post_config()

Expand Down
Loading

0 comments on commit d0edb3e

Please sign in to comment.