ansible  2.9.27
About: Ansible is an IT Configuration Management, Deployment \
About: Ansible (2.x) is an IT Configuration Management, Deployment & Orchestration tool.
ansible download page.
  Fossies Dox: ansible-2.9.27.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

aci_interface_policy_leaf_profile.py
Go to the documentation of this file.
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
4# Copyright: (c) 2017, Bruno Calogero <brunocalogero@hotmail.com>
5# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7from __future__ import absolute_import, division, print_function
8__metaclass__ = type
9
10ANSIBLE_METADATA = {'metadata_version': '1.1',
11 'status': ['preview'],
12 'supported_by': 'certified'}
13
14DOCUMENTATION = r'''
15---
16module: aci_interface_policy_leaf_profile
17short_description: Manage fabric interface policy leaf profiles (infra:AccPortP)
18description:
19- Manage fabric interface policy leaf profiles on Cisco ACI fabrics.
20version_added: '2.5'
21options:
22 leaf_interface_profile:
23 description:
24 - The name of the Fabric access policy leaf interface profile.
25 type: str
26 required: yes
27 aliases: [ name, leaf_interface_profile_name ]
28 description:
29 description:
30 - Description for the Fabric access policy leaf interface profile.
31 type: str
32 aliases: [ descr ]
33 state:
34 description:
35 - Use C(present) or C(absent) for adding or removing.
36 - Use C(query) for listing an object or multiple objects.
37 type: str
38 choices: [ absent, present, query ]
39 default: present
40extends_documentation_fragment: aci
41seealso:
42- name: APIC Management Information Model reference
43 description: More information about the internal APIC class B(infra:AccPortP).
44 link: https://developer.cisco.com/docs/apic-mim-ref/
45author:
46- Bruno Calogero (@brunocalogero)
47'''
48
49EXAMPLES = r'''
50- name: Add a new leaf_interface_profile
51 aci_interface_policy_leaf_profile:
52 host: apic
53 username: admin
54 password: SomeSecretPassword
55 leaf_interface_profile: leafintprfname
56 description: leafintprfname description
57 state: present
58 delegate_to: localhost
59
60- name: Remove a leaf_interface_profile
61 aci_interface_policy_leaf_profile:
62 host: apic
63 username: admin
64 password: SomeSecretPassword
65 leaf_interface_profile: leafintprfname
66 state: absent
67 delegate_to: localhost
68
69- name: Remove all leaf_interface_profiles
70 aci_interface_policy_leaf_profile:
71 host: apic
72 username: admin
73 password: SomeSecretPassword
74 state: absent
75 delegate_to: localhost
76
77- name: Query a leaf_interface_profile
78 aci_interface_policy_leaf_profile:
79 host: apic
80 username: admin
81 password: SomeSecretPassword
82 leaf_interface_profile: leafintprfname
83 state: query
84 delegate_to: localhost
85 register: query_result
86'''
87
88RETURN = r'''
89current:
90 description: The existing configuration from the APIC after the module has finished
91 returned: success
92 type: list
93 sample:
94 [
95 {
96 "fvTenant": {
97 "attributes": {
98 "descr": "Production environment",
99 "dn": "uni/tn-production",
100 "name": "production",
101 "nameAlias": "",
102 "ownerKey": "",
103 "ownerTag": ""
104 }
105 }
106 }
107 ]
108error:
109 description: The error information as returned from the APIC
110 returned: failure
111 type: dict
112 sample:
113 {
114 "code": "122",
115 "text": "unknown managed object class foo"
116 }
117raw:
118 description: The raw output returned by the APIC REST API (xml or json)
119 returned: parse error
120 type: str
121 sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
122sent:
123 description: The actual/minimal configuration pushed to the APIC
124 returned: info
125 type: list
126 sample:
127 {
128 "fvTenant": {
129 "attributes": {
130 "descr": "Production environment"
131 }
132 }
133 }
134previous:
135 description: The original configuration from the APIC before the module has started
136 returned: info
137 type: list
138 sample:
139 [
140 {
141 "fvTenant": {
142 "attributes": {
143 "descr": "Production",
144 "dn": "uni/tn-production",
145 "name": "production",
146 "nameAlias": "",
147 "ownerKey": "",
148 "ownerTag": ""
149 }
150 }
151 }
152 ]
153proposed:
154 description: The assembled configuration from the user-provided parameters
155 returned: info
156 type: dict
157 sample:
158 {
159 "fvTenant": {
160 "attributes": {
161 "descr": "Production environment",
162 "name": "production"
163 }
164 }
165 }
166filter_string:
167 description: The filter string used for the request
168 returned: failure or debug
169 type: str
170 sample: ?rsp-prop-include=config-only
171method:
172 description: The HTTP method used for the request to the APIC
173 returned: failure or debug
174 type: str
175 sample: POST
176response:
177 description: The HTTP response from the APIC
178 returned: failure or debug
179 type: str
180 sample: OK (30 bytes)
181status:
182 description: The HTTP status from the APIC
183 returned: failure or debug
184 type: int
185 sample: 200
186url:
187 description: The HTTP url used for the request to the APIC
188 returned: failure or debug
189 type: str
190 sample: https://10.11.12.13/api/mo/uni/tn-production.json
191'''
192
193from ansible.module_utils.basic import AnsibleModule
194from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
195
196
197def main():
198 argument_spec = aci_argument_spec()
199 argument_spec.update(
200 leaf_interface_profile=dict(type='str', aliases=['name', 'leaf_interface_profile_name']), # Not required for querying all objects
201 description=dict(type='str', aliases=['descr']),
202 state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
203 )
204
205 module = AnsibleModule(
206 argument_spec=argument_spec,
207 supports_check_mode=True,
208 required_if=[
209 ['state', 'absent', ['leaf_interface_profile']],
210 ['state', 'present', ['leaf_interface_profile']],
211 ],
212 )
213
214 leaf_interface_profile = module.params['leaf_interface_profile']
215 description = module.params['description']
216 state = module.params['state']
217
218 aci = ACIModule(module)
219 aci.construct_url(
220 root_class=dict(
221 aci_class='infraAccPortP',
222 aci_rn='infra/accportprof-{0}'.format(leaf_interface_profile),
223 module_object=leaf_interface_profile,
224 target_filter={'name': leaf_interface_profile},
225 ),
226 )
227 aci.get_existing()
228
229 if state == 'present':
230 aci.payload(
231 aci_class='infraAccPortP',
232 class_config=dict(
233 name=leaf_interface_profile,
234 descr=description,
235 ),
236 )
237
238 aci.get_diff(aci_class='infraAccPortP')
239
240 aci.post_config()
241
242 elif state == 'absent':
243 aci.delete_config()
244
245 aci.exit_json()
246
247
248if __name__ == "__main__":
249 main()