Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_dynamicportpolicy.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_dynamicportpolicy
15 short_description: Configure Dynamic port policy to be applied on the managed FortiSwitch ports through DPP device.
16 version_added: "2.2.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 switchcontroller_dynamicportpolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description for the Dynamic port policy.
36 name:
37 type: str
38 description: Dynamic port policy name.
39 required: true
40 policy:
41 type: list
42 elements: dict
43 description: Policy.
44 suboptions:
45 802_1x:
46 aliases: ['802-1x']
47 type: str
48 description: '802.'
49 bounce_port_link:
50 aliases: ['bounce-port-link']
51 type: str
52 description: Enable/disable bouncing
53 choices: ['disable', 'enable']
54 category:
55 type: str
56 description: Category of Dynamic port policy.
57 choices: ['device', 'interface-tag']
58 description:
59 type: str
60 description: Description for the policy.
61 family:
62 type: str
63 description: Match policy based on family.
64 host:
65 type: str
66 description: Match policy based on host.
67 hw_vendor:
68 aliases: ['hw-vendor']
69 type: str
70 description: Match policy based on hardware vendor.
71 interface_tags:
72 aliases: ['interface-tags']
73 type: raw
74 description: (list) Match policy based on the FortiSwitch interface object tags.
75 lldp_profile:
76 aliases: ['lldp-profile']
77 type: str
78 description: LLDP profile to be applied when using this policy.
79 mac:
80 type: str
81 description: Match policy based on MAC address.
82 name:
83 type: str
84 description: Policy name.
85 qos_policy:
86 aliases: ['qos-policy']
87 type: str
88 description: QoS policy to be applied when using this policy.
89 status:
90 type: str
91 description: Enable/disable policy.
92 choices: ['disable', 'enable']
93 type:
94 type: str
95 description: Match policy based on type.
96 vlan_policy:
97 aliases: ['vlan-policy']
98 type: str
99 description: VLAN policy to be applied when using this policy.
100 match_period:
101 aliases: ['match-period']
102 type: int
103 description: Number of days the matched devices will be retained
104 match_type:
105 aliases: ['match-type']
106 type: str
107 description: Match and retain the devices based on the type.
108 choices: ['dynamic', 'override']
109 bounce_port_duration:
110 aliases: ['bounce-port-duration']
111 type: int
112 description: Bounce duration in seconds of a switch port where this policy is applied.
113 poe_reset:
114 aliases: ['poe-reset']
115 type: str
116 description: Enable/disable POE reset of a switch port where this policy is applied.
117 choices: ['disable', 'enable']
118 match_remove:
119 aliases: ['match-remove']
120 type: str
121 description: Options to remove the matched override devices.
122 choices: ['link-down', 'default']
123 fortilink:
124 type: raw
125 description: (list) FortiLink interface for which this Dynamic port policy belongs to.
126 '''
127
128 EXAMPLES = '''
129 - name: Example playbook (generated based on argument schema)
130 hosts: fortimanagers
131 connection: httpapi
132 gather_facts: false
133 tasks:
134 - name: Configure Dynamic port policy to be applied on the managed FortiSwitch ports through DPP device.
135 fortinet.fortimanager.fmgr_switchcontroller_dynamicportpolicy:
136 # workspace_locking_adom: <global or your adom name>
137 adom: <your own value>
138 state: present # <value in [present, absent]>
139 switchcontroller_dynamicportpolicy:
140 name: "your value" # Required variable, string
141 # description: <string>
142 # policy:
143 # - 802_1x: <string>
144 # bounce_port_link: <value in [disable, enable]>
145 # category: <value in [device, interface-tag]>
146 # description: <string>
147 # family: <string>
148 # host: <string>
149 # hw_vendor: <string>
150 # interface_tags: <list or string>
151 # lldp_profile: <string>
152 # mac: <string>
153 # name: <string>
154 # qos_policy: <string>
155 # status: <value in [disable, enable]>
156 # type: <string>
157 # vlan_policy: <string>
158 # match_period: <integer>
159 # match_type: <value in [dynamic, override]>
160 # bounce_port_duration: <integer>
161 # poe_reset: <value in [disable, enable]>
162 # match_remove: <value in [link-down, default]>
163 # fortilink: <list or string>
164 '''
165
166 RETURN = '''
167 meta:
168 description: The result of the request.
169 type: dict
170 returned: always
171 contains:
172 request_url:
173 description: The full url requested.
174 returned: always
175 type: str
176 sample: /sys/login/user
177 response_code:
178 description: The status of api request.
179 returned: always
180 type: int
181 sample: 0
182 response_data:
183 description: The api response.
184 type: list
185 returned: always
186 response_message:
187 description: The descriptive message of the api response.
188 type: str
189 returned: always
190 sample: OK.
191 system_information:
192 description: The information of the target system.
193 type: dict
194 returned: always
195 rc:
196 description: The status the request.
197 type: int
198 returned: always
199 sample: 0
200 version_check_warning:
201 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
202 type: list
203 returned: complex
204 '''
205 from ansible.module_utils.basic import AnsibleModule
206 from ansible.module_utils.connection import Connection
207 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
208 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
209
210
211 def main():
212 urls_list = [
213 '/pm/config/adom/{adom}/obj/switch-controller/dynamic-port-policy',
214 '/pm/config/global/obj/switch-controller/dynamic-port-policy'
215 ]
216 module_arg_spec = {
217 'adom': {'required': True, 'type': 'str'},
218 'revision_note': {'type': 'str'},
219 'switchcontroller_dynamicportpolicy': {
220 'type': 'dict', 'v_range': [['7.2.1', '']],
221 'options': {
222 'description': {'v_range': [['7.2.1', '']], 'type': 'str'},
223 'name': {'v_range': [['7.2.1', '']], 'required': True, 'type': 'str'},
224 'policy': {
225 'v_range': [['7.2.1', '']],
226 'type': 'list',
227 'options': {
228 '802-1x': {'v_range': [['7.2.1', '']], 'type': 'str'},
229 'bounce-port-link': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
230 'category': {'v_range': [['7.2.1', '']], 'choices': ['device', 'interface-tag'], 'type': 'str'},
231 'description': {'v_range': [['7.2.1', '']], 'type': 'str'},
232 'family': {'v_range': [['7.2.1', '']], 'type': 'str'},
233 'host': {'v_range': [['7.2.1', '']], 'type': 'str'},
234 'hw-vendor': {'v_range': [['7.2.1', '']], 'type': 'str'},
235 'interface-tags': {'v_range': [['7.2.1', '']], 'type': 'raw'},
236 'lldp-profile': {'v_range': [['7.2.1', '']], 'type': 'str'},
237 'mac': {'v_range': [['7.2.1', '']], 'type': 'str'},
238 'name': {'v_range': [['7.2.1', '']], 'type': 'str'},
239 'qos-policy': {'v_range': [['7.2.1', '']], 'type': 'str'},
240 'status': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
241 'type': {'v_range': [['7.2.1', '']], 'type': 'str'},
242 'vlan-policy': {'v_range': [['7.2.1', '']], 'type': 'str'},
243 'match-period': {'v_range': [['7.4.3', '']], 'type': 'int'},
244 'match-type': {'v_range': [['7.4.3', '']], 'choices': ['dynamic', 'override'], 'type': 'str'},
245 'bounce-port-duration': {'v_range': [['7.6.2', '']], 'type': 'int'},
246 'poe-reset': {'v_range': [['7.6.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
247 'match-remove': {'v_range': [['7.6.3', '']], 'choices': ['link-down', 'default'], 'type': 'str'}
248 },
249 'elements': 'dict'
250 },
251 'fortilink': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'}
252 }
253 }
254 }
255
256 module_option_spec = get_module_arg_spec('full crud')
257 module_arg_spec.update(module_option_spec)
258 check_galaxy_version(module_arg_spec)
259 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_dynamicportpolicy'),
260 supports_check_mode=True)
261 if not module._socket_path:
262 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
263 connection = Connection(module._socket_path)
264 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
265 'name', 'data', module, connection)
266 fmgr.process_crud()
267 module.exit_json(meta=module.params)
268
269
270 if __name__ == '__main__':
271 main()