Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_macpolicy.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_macpolicy
15 short_description: Configure MAC policy to be applied on the managed FortiSwitch devices through NAC 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_macpolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 bounce_port_link:
34 aliases: ['bounce-port-link']
35 type: str
36 description: Enable/disable bouncing
37 choices: ['disable', 'enable']
38 count:
39 type: str
40 description: Enable/disable packet count on the NAC device.
41 choices: ['disable', 'enable']
42 description:
43 type: str
44 description: Description for the MAC policy.
45 name:
46 type: str
47 description: MAC policy name.
48 required: true
49 traffic_policy:
50 aliases: ['traffic-policy']
51 type: str
52 description: Traffic policy to be applied when using this MAC policy.
53 vlan:
54 type: str
55 description: Ingress traffic VLAN assignment for the MAC address matching this MAC policy.
56 drop:
57 type: str
58 description: Drop.
59 choices: ['disable', 'enable']
60 fortilink:
61 type: raw
62 description: (list) FortiLink interface for which this MAC policy belongs to.
63 bounce_port_duration:
64 aliases: ['bounce-port-duration']
65 type: int
66 description: Bounce duration in seconds of a switch port where this mac-policy is applied.
67 poe_reset:
68 aliases: ['poe-reset']
69 type: str
70 description: Enable/disable POE reset of a switch port where this mac-policy is applied.
71 choices: ['disable', 'enable']
72 '''
73
74 EXAMPLES = '''
75 - name: Example playbook (generated based on argument schema)
76 hosts: fortimanagers
77 connection: httpapi
78 gather_facts: false
79 tasks:
80 - name: Configure MAC policy to be applied on the managed FortiSwitch devices through NAC device.
81 fortinet.fortimanager.fmgr_switchcontroller_macpolicy:
82 # workspace_locking_adom: <global or your adom name>
83 adom: <your own value>
84 state: present # <value in [present, absent]>
85 switchcontroller_macpolicy:
86 name: "your value" # Required variable, string
87 # bounce_port_link: <value in [disable, enable]>
88 # count: <value in [disable, enable]>
89 # description: <string>
90 # traffic_policy: <string>
91 # vlan: <string>
92 # drop: <value in [disable, enable]>
93 # fortilink: <list or string>
94 # bounce_port_duration: <integer>
95 # poe_reset: <value in [disable, enable]>
96 '''
97
98 RETURN = '''
99 meta:
100 description: The result of the request.
101 type: dict
102 returned: always
103 contains:
104 request_url:
105 description: The full url requested.
106 returned: always
107 type: str
108 sample: /sys/login/user
109 response_code:
110 description: The status of api request.
111 returned: always
112 type: int
113 sample: 0
114 response_data:
115 description: The api response.
116 type: list
117 returned: always
118 response_message:
119 description: The descriptive message of the api response.
120 type: str
121 returned: always
122 sample: OK.
123 system_information:
124 description: The information of the target system.
125 type: dict
126 returned: always
127 rc:
128 description: The status the request.
129 type: int
130 returned: always
131 sample: 0
132 version_check_warning:
133 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
134 type: list
135 returned: complex
136 '''
137 from ansible.module_utils.basic import AnsibleModule
138 from ansible.module_utils.connection import Connection
139 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
141
142
143 def main():
144 urls_list = [
145 '/pm/config/adom/{adom}/obj/switch-controller/mac-policy',
146 '/pm/config/global/obj/switch-controller/mac-policy'
147 ]
148 module_arg_spec = {
149 'adom': {'required': True, 'type': 'str'},
150 'revision_note': {'type': 'str'},
151 'switchcontroller_macpolicy': {
152 'type': 'dict', 'v_range': [['7.2.1', '']],
153 'options': {
154 'bounce-port-link': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
155 'count': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
156 'description': {'v_range': [['7.2.1', '']], 'type': 'str'},
157 'name': {'v_range': [['7.2.1', '']], 'required': True, 'type': 'str'},
158 'traffic-policy': {'v_range': [['7.2.1', '']], 'type': 'str'},
159 'vlan': {'v_range': [['7.2.1', '']], 'type': 'str'},
160 'drop': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
161 'fortilink': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
162 'bounce-port-duration': {'v_range': [['7.6.2', '']], 'type': 'int'},
163 'poe-reset': {'v_range': [['7.6.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
164 }
165 }
166 }
167
168 module_option_spec = get_module_arg_spec('full crud')
169 module_arg_spec.update(module_option_spec)
170 check_galaxy_version(module_arg_spec)
171 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_macpolicy'),
172 supports_check_mode=True)
173 if not module._socket_path:
174 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
175 connection = Connection(module._socket_path)
176 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
177 'name', 'data', module, connection)
178 fmgr.process_crud()
179 module.exit_json(meta=module.params)
180
181
182 if __name__ == '__main__':
183 main()