7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_switch_leaf_selector
17short_description: Bind leaf selectors to switch policy leaf profiles (infra:LeafS, infra:NodeBlk, infra:RsAccNodePGrep)
19- Bind leaf selectors (with node block range and policy group) to switch policy leaf profiles on Cisco ACI fabrics.
24 - The description to assign to the C(leaf).
28 - Name of the Leaf Profile to which we add a Selector.
30 aliases: [ leaf_profile_name ]
33 - Name of Leaf Selector.
35 aliases: [ name, leaf_name, leaf_profile_leaf_name, leaf_selector_name ]
38 - Name of Node Block range to be added to Leaf Selector of given Leaf Profile.
40 aliases: [ leaf_node_blk_name, node_blk_name ]
41 leaf_node_blk_description:
43 - The description to assign to the C(leaf_node_blk)
47 - Start of Node Block range.
49 aliases: [ node_blk_range_from, from_range, range_from ]
52 - Start of Node Block range.
54 aliases: [ node_blk_range_to, to_range, range_to ]
57 - Name of the Policy Group to be added to Leaf Selector of given Leaf Profile.
59 aliases: [ name, policy_group_name ]
62 - Use C(present)
or C(absent)
for adding
or removing.
63 - Use C(query)
for listing an object
or multiple objects.
65 choices: [ absent, present, query ]
67extends_documentation_fragment: aci
69- This module
is to be used
with M(aci_switch_policy_leaf_profile).
70 One first creates a leaf profile (infra:NodeP)
and then creates an associated selector (infra:LeafS),
72- module: aci_switch_policy_leaf_profile
73- name: APIC Management Information Model reference
74 description: More information about the internal APIC classes B(infra:LeafS),
75 B(infra:NodeBlk)
and B(infra:RsAccNodePGrp).
76 link: https://developer.cisco.com/docs/apic-mim-ref/
78- Bruno Calogero (
@brunocalogero)
82- name: adding a switch policy leaf profile selector associated Node Block range (w/ policy group)
83 aci_switch_leaf_selector:
86 password: SomeSecretPassword
88 leaf: leaf_selector_name
89 leaf_node_blk: node_blk_name
92 policy_group: somepolicygroupname
94 delegate_to: localhost
96- name: adding a switch policy leaf profile selector associated Node Block range (w/o policy group)
97 aci_switch_leaf_selector:
100 password: SomeSecretPassword
101 leaf_profile: sw_name
102 leaf: leaf_selector_name
103 leaf_node_blk: node_blk_name
107 delegate_to: localhost
109- name: Removing a switch policy leaf profile selector
110 aci_switch_leaf_selector:
113 password: SomeSecretPassword
114 leaf_profile: sw_name
115 leaf: leaf_selector_name
117 delegate_to: localhost
119- name: Querying a switch policy leaf profile selector
120 aci_switch_leaf_selector:
123 password: SomeSecretPassword
124 leaf_profile: sw_name
125 leaf: leaf_selector_name
127 delegate_to: localhost
128 register: query_result
133 description: The existing configuration from the APIC after the module has finished
141 "descr":
"Production environment",
142 "dn":
"uni/tn-production",
143 "name":
"production",
152 description: The error information
as returned
from the APIC
158 "text":
"unknown managed object class foo"
161 description: The raw output returned by the APIC REST API (xml
or json)
162 returned: parse error
164 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
166 description: The actual/minimal configuration pushed to the APIC
173 "descr":
"Production environment"
178 description: The original configuration
from the APIC before the module has started
186 "descr":
"Production",
187 "dn":
"uni/tn-production",
188 "name":
"production",
197 description: The assembled configuration
from the user-provided parameters
204 "descr":
"Production environment",
210 description: The filter string used
for the request
211 returned: failure
or debug
213 sample: ?rsp-prop-include=config-only
215 description: The HTTP method used
for the request to the APIC
216 returned: failure
or debug
220 description: The HTTP response
from the APIC
221 returned: failure
or debug
223 sample: OK (30 bytes)
225 description: The HTTP status
from the APIC
226 returned: failure
or debug
230 description: The HTTP url used
for the request to the APIC
231 returned: failure
or debug
233 sample: https://10.11.12.13/api/mo/uni/tn-production.json
236from ansible.module_utils.basic import AnsibleModule
237from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
242 argument_spec.update({
243 'description': dict(type=
'str'),
244 'leaf_profile': dict(type=
'str', aliases=[
'leaf_profile_name']),
245 'leaf': dict(type=
'str', aliases=[
'name',
'leaf_name',
'leaf_profile_leaf_name',
'leaf_selector_name']),
246 'leaf_node_blk': dict(type=
'str', aliases=[
'leaf_node_blk_name',
'node_blk_name']),
247 'leaf_node_blk_description': dict(type=
'str'),
249 'from': dict(type=
'int', aliases=[
'node_blk_range_from',
'from_range',
'range_from']),
250 'to': dict(type=
'int', aliases=[
'node_blk_range_to',
'to_range',
'range_to']),
251 'policy_group': dict(type=
'str', aliases=[
'policy_group_name']),
252 'state': dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
256 argument_spec=argument_spec,
257 supports_check_mode=
True,
259 [
'state',
'absent', [
'leaf_profile',
'leaf']],
260 [
'state',
'present', [
'leaf_profile',
'leaf',
'leaf_node_blk',
'from',
'to']]
264 description = module.params[
'description']
265 leaf_profile = module.params[
'leaf_profile']
266 leaf = module.params[
'leaf']
267 leaf_node_blk = module.params[
'leaf_node_blk']
268 leaf_node_blk_description = module.params[
'leaf_node_blk_description']
269 from_ = module.params[
'from']
270 to_ = module.params[
'to']
271 policy_group = module.params[
'policy_group']
272 state = module.params[
'state']
279 descr=leaf_node_blk_description,
289 if policy_group
is not None:
290 child_configs.append(dict(
291 infraRsAccNodePGrp=dict(
293 tDn=
'uni/infra/funcprof/accnodepgrp-{0}'.
format(policy_group),
301 aci_class=
'infraNodeP',
302 aci_rn=
'infra/nprof-{0}'.
format(leaf_profile),
303 module_object=leaf_profile,
304 target_filter={
'name': leaf_profile},
307 aci_class=
'infraLeafS',
309 aci_rn=
'leaves-{0}-typ-range'.
format(leaf),
311 target_filter={
'name': leaf},
314 child_classes=[
'infraNodeBlk',
'infraRsAccNodePGrp'],
320 if state ==
'present':
322 aci_class=
'infraLeafS',
327 child_configs=child_configs,
330 aci.get_diff(aci_class=
'infraLeafS')
334 elif state ==
'absent':
340if __name__ ==
"__main__":