Skip to content

Commit fd40f3c

Browse files
authored
[minor_change] Add support for nameAlias attribute in aci_l4l7_device module (#833)
1 parent b356e56 commit fd40f3c

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
4+
5+
from __future__ import absolute_import, division, print_function
6+
7+
__metaclass__ = type
8+
9+
10+
class ModuleDocFragment(object):
11+
# Standard files documentation fragment
12+
DOCUMENTATION = r"""
13+
options:
14+
name_alias:
15+
description:
16+
- The alias for the current object. This relates to the nameAlias field in ACI.
17+
type: str
18+
"""

plugins/module_utils/aci.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ def aci_annotation_spec():
155155
)
156156

157157

158+
def aci_name_alias_spec():
159+
return dict(
160+
name_alias=dict(type="str"),
161+
)
162+
163+
158164
def aci_owner_spec():
159165
return dict(
160166
owner_key=dict(type="str", no_log=False, fallback=(env_fallback, ["ACI_OWNER_KEY"])),

plugins/modules/aci_l4l7_device.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
extends_documentation_fragment:
9494
- cisco.aci.aci
9595
- cisco.aci.annotation
96+
- cisco.aci.name_alias
9697
notes:
9798
- The I(tenant) must exist before using this module in your playbook.
9899
The M(cisco.aci.aci_tenant) modules can be used for this.
@@ -263,13 +264,14 @@
263264

264265

265266
from ansible.module_utils.basic import AnsibleModule
266-
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec
267+
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_name_alias_spec
267268
from ansible_collections.cisco.aci.plugins.module_utils.constants import L4L7_FUNC_TYPES_MAPPING
268269

269270

270271
def main():
271272
argument_spec = aci_argument_spec()
272273
argument_spec.update(aci_annotation_spec())
274+
argument_spec.update(aci_name_alias_spec())
273275
argument_spec.update(
274276
tenant=dict(type="str", aliases=["tenant_name"]),
275277
name=dict(type="str", aliases=["device", "device_name", "logical_device", "logical_device_name"]),
@@ -308,6 +310,7 @@ def main():
308310
trunking = aci.boolean(module.params.get("trunking"))
309311
domain = module.params.get("domain")
310312
active_active_mode = aci.boolean(module.params.get("active_active_mode"))
313+
name_alias = module.params.get("name_alias")
311314

312315
aci.construct_url(
313316
root_class=dict(
@@ -349,6 +352,7 @@ def main():
349352
svcType=service_type.upper(),
350353
trunking=trunking,
351354
activeActive=active_active_mode,
355+
nameAlias=name_alias,
352356
),
353357
child_configs=child_configs,
354358
)

tests/integration/targets/aci_l4l7_device/tasks/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
svc_type: adc
8181
trunking: false
8282
prom_mode: true
83+
name_alias: ansible_device_alias
8384
state: present
8485
check_mode: true
8586
register: create_l4l7_device_cm
@@ -132,6 +133,7 @@
132133
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.promMode == "yes"
133134
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.svcType == "ADC"
134135
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.trunking == "no"
136+
- create_l4l7_device_cm.proposed.vnsLDevVip.attributes.nameAlias == "ansible_device_alias"
135137
- create_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_device"
136138
- create_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_device"
137139
- create_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "single-Context"
@@ -142,6 +144,7 @@
142144
- create_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "yes"
143145
- create_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "ADC"
144146
- create_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "no"
147+
- create_l4l7_device.current.0.vnsLDevVip.attributes.nameAlias == "ansible_device_alias"
145148
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.dn == "uni/tn-ansible_tenant/lDevVip-ansible_virt_device"
146149
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.name == "ansible_virt_device"
147150
- create_virt_l4l7_device.current.0.vnsLDevVip.attributes.contextAware == "single-Context"
@@ -183,6 +186,7 @@
183186
svc_type: fw
184187
trunking: true
185188
prom_mode: false
189+
name_alias: ansible_device_alias_updated
186190
state: present
187191
register: update_l4l7_device
188192

@@ -200,6 +204,7 @@
200204
- update_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "no"
201205
- update_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "FW"
202206
- update_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "yes"
207+
- update_l4l7_device.current.0.vnsLDevVip.attributes.nameAlias == "ansible_device_alias_updated"
203208

204209
- name: Verify domain binding object
205210
ansible.builtin.assert:
@@ -253,6 +258,7 @@
253258
- query_l4l7_device.current.0.vnsLDevVip.attributes.promMode == "no"
254259
- query_l4l7_device.current.0.vnsLDevVip.attributes.svcType == "FW"
255260
- query_l4l7_device.current.0.vnsLDevVip.attributes.trunking == "yes"
261+
- query_l4l7_device.current.0.vnsLDevVip.attributes.nameAlias == "ansible_device_alias_updated"
256262

257263
- name: Query all L4-L7 Devices
258264
cisco.aci.aci_l4l7_device:

0 commit comments

Comments
 (0)