Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_npu_swtrhash.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_swtrhash
15 short_description: Configure switch traditional hashing.
16 version_added: "2.2.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_swtrhash:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 draco15:
34 type: str
35 description: Enable/disable DRACO15 hashing.
36 choices: ['disable', 'enable']
37 tcp_udp_port:
38 aliases: ['tcp-udp-port']
39 type: str
40 description: Include/exclude TCP/UDP source and destination port for unicast trunk traffic.
41 choices: ['include', 'exclude']
42 '''
43
44 EXAMPLES = '''
45 - name: Example playbook (generated based on argument schema)
46 hosts: fortimanagers
47 connection: httpapi
48 gather_facts: false
49 tasks:
50 - name: Configure switch traditional hashing.
51 fortinet.fortimanager.fmgr_system_npu_swtrhash:
52 # workspace_locking_adom: <global or your adom name>
53 adom: <your own value>
54 system_npu_swtrhash:
55 # draco15: <value in [disable, enable]>
56 # tcp_udp_port: <value in [include, exclude]>
57 '''
58
59 RETURN = '''
60 meta:
61 description: The result of the request.
62 type: dict
63 returned: always
64 contains:
65 request_url:
66 description: The full url requested.
67 returned: always
68 type: str
69 sample: /sys/login/user
70 response_code:
71 description: The status of api request.
72 returned: always
73 type: int
74 sample: 0
75 response_data:
76 description: The api response.
77 type: list
78 returned: always
79 response_message:
80 description: The descriptive message of the api response.
81 type: str
82 returned: always
83 sample: OK.
84 system_information:
85 description: The information of the target system.
86 type: dict
87 returned: always
88 rc:
89 description: The status the request.
90 type: int
91 returned: always
92 sample: 0
93 version_check_warning:
94 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
95 type: list
96 returned: complex
97 '''
98 from ansible.module_utils.basic import AnsibleModule
99 from ansible.module_utils.connection import Connection
100 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
101 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
102
103
104 def main():
105 urls_list = [
106 '/pm/config/adom/{adom}/obj/system/npu/sw-tr-hash',
107 '/pm/config/global/obj/system/npu/sw-tr-hash'
108 ]
109 module_arg_spec = {
110 'adom': {'required': True, 'type': 'str'},
111 'revision_note': {'type': 'str'},
112 'system_npu_swtrhash': {
113 'type': 'dict', 'v_range': [['7.2.4', '']],
114 'options': {
115 'draco15': {'v_range': [['7.2.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
116 'tcp-udp-port': {'v_range': [['7.2.4', '']], 'choices': ['include', 'exclude'], 'type': 'str'}
117 }
118 }
119 }
120
121 module_option_spec = get_module_arg_spec('partial crud')
122 module_arg_spec.update(module_option_spec)
123 check_galaxy_version(module_arg_spec)
124 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_npu_swtrhash'),
125 supports_check_mode=True)
126 if not module._socket_path:
127 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
128 connection = Connection(module._socket_path)
129 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
130 None, 'data', module, connection)
131 fmgr.process_partial_crud()
132 module.exit_json(meta=module.params)
133
134
135 if __name__ == '__main__':
136 main()