-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor_change] Add aci_action_rule_set_as_path and aci_action_rule_se…
…t_as_path_asn as new modules.
- Loading branch information
Showing
4 changed files
with
685 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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. | ||
|
@@ -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/ | ||
|
@@ -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"), | ||
|
@@ -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) | ||
|
@@ -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() | ||
|
||
|
Oops, something went wrong.