Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_npu_swehhash.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_system_npu_swehhash
15 short_description: Configure switch enhanced hashing.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_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 system_npu_swehhash:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 computation:
34 type: str
35 description: Set hashing computation.
36 choices: ['xor16', 'xor8', 'xor4', 'crc16']
37 destination_ip_lower_16:
38 aliases: ['destination-ip-lower-16']
39 type: str
40 description: Include/exclude destination IP address lower 16 bits.
41 choices: ['include', 'exclude']
42 destination_ip_upper_16:
43 aliases: ['destination-ip-upper-16']
44 type: str
45 description: Include/exclude destination IP address upper 16 bits.
46 choices: ['include', 'exclude']
47 destination_port:
48 aliases: ['destination-port']
49 type: str
50 description: Include/exclude destination port if TCP/UDP.
51 choices: ['include', 'exclude']
52 ip_protocol:
53 aliases: ['ip-protocol']
54 type: str
55 description: Include/exclude IP protocol.
56 choices: ['include', 'exclude']
57 netmask_length:
58 aliases: ['netmask-length']
59 type: int
60 description: Network mask length.
61 source_ip_lower_16:
62 aliases: ['source-ip-lower-16']
63 type: str
64 description: Include/exclude source IP address lower 16 bits.
65 choices: ['include', 'exclude']
66 source_ip_upper_16:
67 aliases: ['source-ip-upper-16']
68 type: str
69 description: Include/exclude source IP address upper 16 bits.
70 choices: ['include', 'exclude']
71 source_port:
72 aliases: ['source-port']
73 type: str
74 description: Include/exclude source port if TCP/UDP.
75 choices: ['include', 'exclude']
76 '''
77
78 EXAMPLES = '''
79 - name: Example playbook (generated based on argument schema)
80 hosts: fortimanagers
81 connection: httpapi
82 gather_facts: false
83 tasks:
84 - name: Configure switch enhanced hashing.
85 fortinet.fortimanager.fmgr_system_npu_swehhash:
86 # workspace_locking_adom: <global or your adom name>
87 adom: <your own value>
88 system_npu_swehhash:
89 # computation: <value in [xor16, xor8, xor4, ...]>
90 # destination_ip_lower_16: <value in [include, exclude]>
91 # destination_ip_upper_16: <value in [include, exclude]>
92 # destination_port: <value in [include, exclude]>
93 # ip_protocol: <value in [include, exclude]>
94 # netmask_length: <integer>
95 # source_ip_lower_16: <value in [include, exclude]>
96 # source_ip_upper_16: <value in [include, exclude]>
97 # source_port: <value in [include, exclude]>
98 '''
99
100 RETURN = '''
101 meta:
102 description: The result of the request.
103 type: dict
104 returned: always
105 contains:
106 request_url:
107 description: The full url requested.
108 returned: always
109 type: str
110 sample: /sys/login/user
111 response_code:
112 description: The status of api request.
113 returned: always
114 type: int
115 sample: 0
116 response_data:
117 description: The api response.
118 type: list
119 returned: always
120 response_message:
121 description: The descriptive message of the api response.
122 type: str
123 returned: always
124 sample: OK.
125 system_information:
126 description: The information of the target system.
127 type: dict
128 returned: always
129 rc:
130 description: The status the request.
131 type: int
132 returned: always
133 sample: 0
134 version_check_warning:
135 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
136 type: list
137 returned: complex
138 '''
139 from ansible.module_utils.basic import AnsibleModule
140 from ansible.module_utils.connection import Connection
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
142 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
143
144
145 def main():
146 urls_list = [
147 '/pm/config/adom/{adom}/obj/system/npu/sw-eh-hash',
148 '/pm/config/global/obj/system/npu/sw-eh-hash'
149 ]
150 module_arg_spec = {
151 'adom': {'required': True, 'type': 'str'},
152 'revision_note': {'type': 'str'},
153 'system_npu_swehhash': {
154 'type': 'dict', 'v_range': [['7.0.1', '']],
155 'options': {
156 'computation': {'v_range': [['7.0.1', '']], 'choices': ['xor16', 'xor8', 'xor4', 'crc16'], 'type': 'str'},
157 'destination-ip-lower-16': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
158 'destination-ip-upper-16': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
159 'destination-port': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
160 'ip-protocol': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
161 'netmask-length': {'v_range': [['7.0.1', '']], 'type': 'int'},
162 'source-ip-lower-16': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
163 'source-ip-upper-16': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'},
164 'source-port': {'v_range': [['7.0.1', '']], 'choices': ['include', 'exclude'], 'type': 'str'}
165 }
166 }
167 }
168
169 module_option_spec = get_module_arg_spec('partial crud')
170 module_arg_spec.update(module_option_spec)
171 check_galaxy_version(module_arg_spec)
172 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_npu_swehhash'),
173 supports_check_mode=True)
174 if not module._socket_path:
175 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
176 connection = Connection(module._socket_path)
177 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
178 None, 'data', module, connection)
179 fmgr.process_partial_crud()
180 module.exit_json(meta=module.params)
181
182
183 if __name__ == '__main__':
184 main()