Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_managedswitch_snmpcommunity.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_switchcontroller_managedswitch_snmpcommunity
15 short_description: Configuration method to edit Simple Network Management Protocol
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 managed-switch:
29 description: Deprecated, please use "managed_switch"
30 type: str
31 managed_switch:
32 description: The parameter (managed-switch) in requested url.
33 type: str
34 switchcontroller_managedswitch_snmpcommunity:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 events:
40 type: list
41 elements: str
42 description: SNMP notifications
43 choices: ['cpu-high', 'mem-low', 'log-full', 'intf-ip', 'ent-conf-change']
44 hosts:
45 type: list
46 elements: dict
47 description: Hosts.
48 suboptions:
49 id:
50 type: int
51 description: Host entry ID.
52 ip:
53 type: str
54 description: IPv4 address of the SNMP manager
55 id:
56 type: int
57 description: SNMP community ID.
58 required: true
59 name:
60 type: str
61 description: SNMP community name.
62 query_v1_port:
63 aliases: ['query-v1-port']
64 type: int
65 description: SNMP v1 query port
66 query_v1_status:
67 aliases: ['query-v1-status']
68 type: str
69 description: Enable/disable SNMP v1 queries.
70 choices: ['disable', 'enable']
71 query_v2c_port:
72 aliases: ['query-v2c-port']
73 type: int
74 description: SNMP v2c query port
75 query_v2c_status:
76 aliases: ['query-v2c-status']
77 type: str
78 description: Enable/disable SNMP v2c queries.
79 choices: ['disable', 'enable']
80 status:
81 type: str
82 description: Enable/disable this SNMP community.
83 choices: ['disable', 'enable']
84 trap_v1_lport:
85 aliases: ['trap-v1-lport']
86 type: int
87 description: SNMP v2c trap local port
88 trap_v1_rport:
89 aliases: ['trap-v1-rport']
90 type: int
91 description: SNMP v2c trap remote port
92 trap_v1_status:
93 aliases: ['trap-v1-status']
94 type: str
95 description: Enable/disable SNMP v1 traps.
96 choices: ['disable', 'enable']
97 trap_v2c_lport:
98 aliases: ['trap-v2c-lport']
99 type: int
100 description: SNMP v2c trap local port
101 trap_v2c_rport:
102 aliases: ['trap-v2c-rport']
103 type: int
104 description: SNMP v2c trap remote port
105 trap_v2c_status:
106 aliases: ['trap-v2c-status']
107 type: str
108 description: Enable/disable SNMP v2c traps.
109 choices: ['disable', 'enable']
110 '''
111
112 EXAMPLES = '''
113 - name: Example playbook (generated based on argument schema)
114 hosts: fortimanagers
115 connection: httpapi
116 gather_facts: false
117 tasks:
118 - name: Configuration method to edit Simple Network Management Protocol
119 fortinet.fortimanager.fmgr_switchcontroller_managedswitch_snmpcommunity:
120 # workspace_locking_adom: <global or your adom name>
121 adom: <your own value>
122 managed_switch: <your own value>
123 state: present # <value in [present, absent]>
124 switchcontroller_managedswitch_snmpcommunity:
125 id: 0 # Required variable, integer
126 # events: ["cpu-high", "mem-low", "log-full", "intf-ip", "ent-conf-change"]
127 # hosts:
128 # - id: <integer>
129 # ip: <string>
130 # name: <string>
131 # query_v1_port: <integer>
132 # query_v1_status: <value in [disable, enable]>
133 # query_v2c_port: <integer>
134 # query_v2c_status: <value in [disable, enable]>
135 # status: <value in [disable, enable]>
136 # trap_v1_lport: <integer>
137 # trap_v1_rport: <integer>
138 # trap_v1_status: <value in [disable, enable]>
139 # trap_v2c_lport: <integer>
140 # trap_v2c_rport: <integer>
141 # trap_v2c_status: <value in [disable, enable]>
142 '''
143
144 RETURN = '''
145 meta:
146 description: The result of the request.
147 type: dict
148 returned: always
149 contains:
150 request_url:
151 description: The full url requested.
152 returned: always
153 type: str
154 sample: /sys/login/user
155 response_code:
156 description: The status of api request.
157 returned: always
158 type: int
159 sample: 0
160 response_data:
161 description: The api response.
162 type: list
163 returned: always
164 response_message:
165 description: The descriptive message of the api response.
166 type: str
167 returned: always
168 sample: OK.
169 system_information:
170 description: The information of the target system.
171 type: dict
172 returned: always
173 rc:
174 description: The status the request.
175 type: int
176 returned: always
177 sample: 0
178 version_check_warning:
179 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
180 type: list
181 returned: complex
182 '''
183 from ansible.module_utils.basic import AnsibleModule
184 from ansible.module_utils.connection import Connection
185 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
186 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
187
188
189 def main():
190 urls_list = [
191 '/pm/config/adom/{adom}/obj/switch-controller/managed-switch/{managed-switch}/snmp-community',
192 '/pm/config/global/obj/switch-controller/managed-switch/{managed-switch}/snmp-community'
193 ]
194 module_arg_spec = {
195 'adom': {'required': True, 'type': 'str'},
196 'managed-switch': {'type': 'str', 'api_name': 'managed_switch'},
197 'managed_switch': {'type': 'str'},
198 'revision_note': {'type': 'str'},
199 'switchcontroller_managedswitch_snmpcommunity': {
200 'type': 'dict', 'v_range': [['6.2.1', '6.2.3']],
201 'options': {
202 'events': {
203 'v_range': [['6.2.1', '6.2.3']],
204 'type': 'list',
205 'choices': ['cpu-high', 'mem-low', 'log-full', 'intf-ip', 'ent-conf-change'],
206 'elements': 'str'
207 },
208 'hosts': {
209 'v_range': [['6.2.1', '6.2.3']],
210 'type': 'list',
211 'options': {'id': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'}, 'ip': {'v_range': [['6.2.1', '6.2.3']], 'type': 'str'}},
212 'elements': 'dict'
213 },
214 'id': {'v_range': [['6.2.1', '6.2.3']], 'required': True, 'type': 'int'},
215 'name': {'v_range': [['6.2.1', '6.2.3']], 'type': 'str'},
216 'query-v1-port': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
217 'query-v1-status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
218 'query-v2c-port': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
219 'query-v2c-status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
220 'status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
221 'trap-v1-lport': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
222 'trap-v1-rport': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
223 'trap-v1-status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
224 'trap-v2c-lport': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
225 'trap-v2c-rport': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
226 'trap-v2c-status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'}
227 }
228 }
229 }
230
231 module_option_spec = get_module_arg_spec('full crud')
232 module_arg_spec.update(module_option_spec)
233 check_galaxy_version(module_arg_spec)
234 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_managedswitch_snmpcommunity'),
235 supports_check_mode=True)
236 if not module._socket_path:
237 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
238 connection = Connection(module._socket_path)
239 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
240 'id', 'data', module, connection)
241 fmgr.process_crud()
242 module.exit_json(meta=module.params)
243
244
245 if __name__ == '__main__':
246 main()