Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_managedswitch_systeminterface.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_systeminterface
15 short_description: Configure system interface on FortiSwitch.
16 version_added: "2.12.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_systeminterface:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 allowaccess:
40 type: list
41 elements: str
42 description: Permitted types of management access to this interface.
43 choices: ['https', 'ping', 'ssh', 'snmp', 'http', 'telnet', 'radius-acct']
44 interface:
45 type: list
46 elements: str
47 description: Interface name.
48 ip:
49 type: list
50 elements: str
51 description: IP and mask for this interface.
52 mode:
53 type: str
54 description: Interface addressing mode.
55 choices: ['static', 'dhcp']
56 name:
57 type: str
58 description: Interface name.
59 required: true
60 status:
61 type: str
62 description: Enable/disable interface status.
63 choices: ['disable', 'enable']
64 switch_id:
65 aliases: ['switch-id']
66 type: list
67 elements: str
68 description: Switch ID.
69 type:
70 type: str
71 description: Interface type.
72 choices: ['physical', 'vlan']
73 vlan:
74 type: list
75 elements: str
76 description: VLAN name.
77 vrf:
78 type: list
79 elements: str
80 description: VRF for this route.
81 '''
82
83 EXAMPLES = '''
84 - name: Example playbook (generated based on argument schema)
85 hosts: fortimanagers
86 connection: httpapi
87 gather_facts: false
88 tasks:
89 - name: Configure system interface on FortiSwitch.
90 fortinet.fortimanager.fmgr_switchcontroller_managedswitch_systeminterface:
91 # workspace_locking_adom: <global or your adom name>
92 adom: <your own value>
93 managed_switch: <your own value>
94 state: present # <value in [present, absent]>
95 switchcontroller_managedswitch_systeminterface:
96 name: "your value" # Required variable, string
97 # allowaccess: ["https", "ping", "ssh", "snmp", "http", "telnet", "radius-acct"]
98 # interface: <list or string>
99 # ip: <list or string>
100 # mode: <value in [static, dhcp]>
101 # status: <value in [disable, enable]>
102 # switch_id: <list or string>
103 # type: <value in [physical, vlan]>
104 # vlan: <list or string>
105 # vrf: <list or string>
106 '''
107
108 RETURN = '''
109 meta:
110 description: The result of the request.
111 type: dict
112 returned: always
113 contains:
114 request_url:
115 description: The full url requested.
116 returned: always
117 type: str
118 sample: /sys/login/user
119 response_code:
120 description: The status of api request.
121 returned: always
122 type: int
123 sample: 0
124 response_data:
125 description: The api response.
126 type: list
127 returned: always
128 response_message:
129 description: The descriptive message of the api response.
130 type: str
131 returned: always
132 sample: OK.
133 system_information:
134 description: The information of the target system.
135 type: dict
136 returned: always
137 rc:
138 description: The status the request.
139 type: int
140 returned: always
141 sample: 0
142 version_check_warning:
143 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
144 type: list
145 returned: complex
146 '''
147 from ansible.module_utils.basic import AnsibleModule
148 from ansible.module_utils.connection import Connection
149 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
150 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
151
152
153 def main():
154 urls_list = [
155 '/pm/config/adom/{adom}/obj/switch-controller/managed-switch/{managed-switch}/system-interface'
156 ]
157 module_arg_spec = {
158 'adom': {'required': True, 'type': 'str'},
159 'managed-switch': {'type': 'str', 'api_name': 'managed_switch'},
160 'managed_switch': {'type': 'str'},
161 'revision_note': {'type': 'str'},
162 'switchcontroller_managedswitch_systeminterface': {
163 'type': 'dict', 'v_range': [['7.6.4', '']],
164 'options': {
165 'allowaccess': {
166 'v_range': [['7.6.4', '']],
167 'type': 'list',
168 'choices': ['https', 'ping', 'ssh', 'snmp', 'http', 'telnet', 'radius-acct'],
169 'elements': 'str'
170 },
171 'interface': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
172 'ip': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
173 'mode': {'v_range': [['7.6.4', '']], 'choices': ['static', 'dhcp'], 'type': 'str'},
174 'name': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'str'},
175 'status': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
176 'switch-id': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
177 'type': {'v_range': [['7.6.4', '']], 'choices': ['physical', 'vlan'], 'type': 'str'},
178 'vlan': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'},
179 'vrf': {'v_range': [['7.6.4', '']], 'type': 'list', 'elements': 'str'}
180 }
181 }
182 }
183
184 module_option_spec = get_module_arg_spec('full crud')
185 module_arg_spec.update(module_option_spec)
186 check_galaxy_version(module_arg_spec)
187 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_managedswitch_systeminterface'),
188 supports_check_mode=True)
189 if not module._socket_path:
190 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
191 connection = Connection(module._socket_path)
192 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
193 'name', 'data', module, connection)
194 fmgr.process_crud()
195 module.exit_json(meta=module.params)
196
197
198 if __name__ == '__main__':
199 main()