Debian Codegraph @

ansible_collections/cisco/aci/plugins/modules/aci_system.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2020, Lionel Hercot (@lhercot) <[email protected]>
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 from __future__ import absolute_import, division, print_function
8
9 __metaclass__ = type
10
11 DOCUMENTATION = r"""
12 ---
13 module: aci_system
14 short_description: Query the ACI system information (top:System)
15 description:
16 - Query the ACI system information on Cisco ACI.
17 author:
18 - Lionel Hercot (@lhercot)
19 options:
20 id:
21 description:
22 - The controller node ID
23 aliases: [ controller, node ]
24 type: int
25 state:
26 description:
27 - Use C(query) for listing an object or multiple objects.
28 choices: [ query ]
29 default: query
30 type: str
31
32 notes:
33 - This module is used to query system information for both cloud and on-premises controllers.
34 seealso:
35 - name: APIC Management Information Model reference
36 description: More information about the internal APIC class B(top:System).
37 link: https://developer.cisco.com/docs/apic-mim-ref/
38 extends_documentation_fragment:
39 - cisco.aci.aci
40 """
41
42 EXAMPLES = r"""
43 - name: Query all controllers system information
44 cisco.aci.aci_system:
45 host: apic
46 username: userName
47 password: somePassword
48 validate_certs: false
49 state: query
50 delegate_to: localhost
51
52 - name: Query controller 1 specific system information
53 cisco.aci.aci_system:
54 host: apic
55 username: userName
56 password: somePassword
57 validate_certs: false
58 id: 1
59 state: query
60 delegate_to: localhost
61 """
62
63 RETURN = r"""
64 current:
65 description: The existing configuration from the APIC after the module has finished
66 returned: success
67 type: list
68 sample:
69 [
70 {
71 "fvTenant": {
72 "attributes": {
73 "descr": "Production environment",
74 "dn": "uni/tn-production",
75 "name": "production",
76 "nameAlias": "",
77 "ownerKey": "",
78 "ownerTag": ""
79 }
80 }
81 }
82 ]
83 error:
84 description: The error information as returned from the APIC
85 returned: failure
86 type: dict
87 sample:
88 {
89 "code": "122",
90 "text": "unknown managed object class foo"
91 }
92 raw:
93 description: The raw output returned by the APIC REST API (xml or json)
94 returned: parse error
95 type: str
96 sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
97 sent:
98 description: The actual/minimal configuration pushed to the APIC
99 returned: info
100 type: list
101 sample:
102 {
103 "fvTenant": {
104 "attributes": {
105 "descr": "Production environment"
106 }
107 }
108 }
109 previous:
110 description: The original configuration from the APIC before the module has started
111 returned: info
112 type: list
113 sample:
114 [
115 {
116 "fvTenant": {
117 "attributes": {
118 "descr": "Production",
119 "dn": "uni/tn-production",
120 "name": "production",
121 "nameAlias": "",
122 "ownerKey": "",
123 "ownerTag": ""
124 }
125 }
126 }
127 ]
128 proposed:
129 description: The assembled configuration from the user-provided parameters
130 returned: info
131 type: dict
132 sample:
133 {
134 "fvTenant": {
135 "attributes": {
136 "descr": "Production environment",
137 "name": "production"
138 }
139 }
140 }
141 filter_string:
142 description: The filter string used for the request
143 returned: failure or debug
144 type: str
145 sample: ?rsp-prop-include=config-only
146 method:
147 description: The HTTP method used for the request to the APIC
148 returned: failure or debug
149 type: str
150 sample: POST
151 response:
152 description: The HTTP response from the APIC
153 returned: failure or debug
154 type: str
155 sample: OK (30 bytes)
156 status:
157 description: The HTTP status from the APIC
158 returned: failure or debug
159 type: int
160 sample: 200
161 url:
162 description: The HTTP url used for the request to the APIC
163 returned: failure or debug
164 type: str
165 sample: https://10.11.12.13/api/mo/uni/tn-production.json
166 """
167
168 from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec
169 from ansible.module_utils.basic import AnsibleModule
170
171
172 def main():
173 argument_spec = aci_argument_spec()
174 argument_spec.update(
175 id=dict(type="int", aliases=["controller", "node"]),
176 state=dict(type="str", default="query", choices=["query"]),
177 )
178
179 module = AnsibleModule(
180 argument_spec=argument_spec,
181 supports_check_mode=True,
182 )
183
184 id = module.params.get("id")
185
186 aci = ACIModule(module)
187 aci.construct_url(root_class=dict(aci_class="topSystem", target_filter={"id": id}))
188
189 aci.get_existing()
190
191 aci.exit_json()
192
193
194 if __name__ == "__main__":
195 main()