Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_qos_ipdscpmap.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_qos_ipdscpmap
15 short_description: Configure FortiSwitch QoS IP precedence/DSCP.
16 version_added: "2.0.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_qos_ipdscpmap:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 description:
34 type: str
35 description: Description of the ip-dscp map name.
36 map:
37 type: list
38 elements: dict
39 description: Map.
40 suboptions:
41 cos_queue:
42 aliases: ['cos-queue']
43 type: int
44 description: COS queue number.
45 diffserv:
46 type: list
47 elements: str
48 description: Differentiated service.
49 choices: ['CS0', 'CS1', 'AF11', 'AF12', 'AF13', 'CS2', 'AF21', 'AF22',
50 'AF23', 'CS3', 'AF31', 'AF32', 'AF33', 'CS4', 'AF41', 'AF42',
51 'AF43', 'CS5', 'EF', 'CS6', 'CS7']
52 ip_precedence:
53 aliases: ['ip-precedence']
54 type: list
55 elements: str
56 description: IP Precedence.
57 choices: ['network-control', 'internetwork-control', 'critic-ecp',
58 'flashoverride', 'flash', 'immediate', 'priority', 'routine']
59 name:
60 type: str
61 description: Dscp mapping entry name.
62 value:
63 type: str
64 description: Raw values of DSCP
65 name:
66 type: str
67 description: Dscp map name.
68 required: true
69 '''
70
71 EXAMPLES = '''
72 - name: Example playbook (generated based on argument schema)
73 hosts: fortimanagers
74 connection: httpapi
75 gather_facts: false
76 tasks:
77 - name: Configure FortiSwitch QoS IP precedence/DSCP.
78 fortinet.fortimanager.fmgr_switchcontroller_qos_ipdscpmap:
79 # workspace_locking_adom: <global or your adom name>
80 adom: <your own value>
81 state: present # <value in [present, absent]>
82 switchcontroller_qos_ipdscpmap:
83 name: "your value" # Required variable, string
84 # description: <string>
85 # map:
86 # - cos_queue: <integer>
87 # diffserv: ["CS0", "CS1", "AF11", "AF12", "AF13", "CS2", "AF21", "AF22", "AF23",
88 # "CS3", "AF31", "AF32", "AF33", "CS4", "AF41", "AF42", "AF43", "CS5",
89 # "EF", "CS6", "CS7"]
90 # ip_precedence: ["network-control", "internetwork-control", "critic-ecp",
91 # "flashoverride", "flash", "immediate", "priority", "routine"]
92 # name: <string>
93 # value: <string>
94 '''
95
96 RETURN = '''
97 meta:
98 description: The result of the request.
99 type: dict
100 returned: always
101 contains:
102 request_url:
103 description: The full url requested.
104 returned: always
105 type: str
106 sample: /sys/login/user
107 response_code:
108 description: The status of api request.
109 returned: always
110 type: int
111 sample: 0
112 response_data:
113 description: The api response.
114 type: list
115 returned: always
116 response_message:
117 description: The descriptive message of the api response.
118 type: str
119 returned: always
120 sample: OK.
121 system_information:
122 description: The information of the target system.
123 type: dict
124 returned: always
125 rc:
126 description: The status the request.
127 type: int
128 returned: always
129 sample: 0
130 version_check_warning:
131 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
132 type: list
133 returned: complex
134 '''
135 from ansible.module_utils.basic import AnsibleModule
136 from ansible.module_utils.connection import Connection
137 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
138 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
139
140
141 def main():
142 urls_list = [
143 '/pm/config/adom/{adom}/obj/switch-controller/qos/ip-dscp-map',
144 '/pm/config/global/obj/switch-controller/qos/ip-dscp-map'
145 ]
146 module_arg_spec = {
147 'adom': {'required': True, 'type': 'str'},
148 'revision_note': {'type': 'str'},
149 'switchcontroller_qos_ipdscpmap': {
150 'type': 'dict', 'v_range': [['6.0.0', '']],
151 'options': {
152 'description': {'type': 'str'},
153 'map': {
154 'type': 'list',
155 'options': {
156 'cos-queue': {'type': 'int'},
157 'diffserv': {
158 'type': 'list',
159 'choices': [
160 'CS0', 'CS1', 'AF11', 'AF12', 'AF13', 'CS2', 'AF21', 'AF22', 'AF23', 'CS3', 'AF31', 'AF32', 'AF33', 'CS4', 'AF41',
161 'AF42', 'AF43', 'CS5', 'EF', 'CS6', 'CS7'
162 ],
163 'elements': 'str'
164 },
165 'ip-precedence': {
166 'type': 'list',
167 'choices': [
168 'network-control', 'internetwork-control', 'critic-ecp', 'flashoverride', 'flash', 'immediate', 'priority', 'routine'
169 ],
170 'elements': 'str'
171 },
172 'name': {'type': 'str'},
173 'value': {'type': 'str'}
174 },
175 'elements': 'dict'
176 },
177 'name': {'required': True, 'type': 'str'}
178 }
179 }
180 }
181
182 module_option_spec = get_module_arg_spec('full crud')
183 module_arg_spec.update(module_option_spec)
184 check_galaxy_version(module_arg_spec)
185 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_qos_ipdscpmap'),
186 supports_check_mode=True)
187 if not module._socket_path:
188 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
189 connection = Connection(module._socket_path)
190 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
191 'name', 'data', module, connection)
192 fmgr.process_crud()
193 module.exit_json(meta=module.params)
194
195
196 if __name__ == '__main__':
197 main()