Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_log_npuserver_servergroup.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_log_npuserver_servergroup
15 short_description: create server group.
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 log_npuserver_servergroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 group_name:
34 aliases: ['group-name']
35 type: str
36 description: Server group name.
37 log_format:
38 aliases: ['log-format']
39 type: str
40 description: Set the log format
41 choices: ['syslog', 'netflow']
42 log_mode:
43 aliases: ['log-mode']
44 type: str
45 description: Set the log mode
46 choices: ['per-session', 'per-nat-mapping', 'per-session-ending']
47 log_tx_mode:
48 aliases: ['log-tx-mode']
49 type: str
50 description: Configure log transmit mode.
51 choices: ['multicast', 'roundrobin']
52 server_number:
53 aliases: ['server-number']
54 type: int
55 description: Server number in this group.
56 server_start_id:
57 aliases: ['server-start-id']
58 type: int
59 description: The start id of the continuous server series in this group,[1,16].
60 sw_log_flags:
61 aliases: ['sw-log-flags']
62 type: raw
63 description: (int or str) Set flags for software logging via driver.
64 log_gen_event:
65 aliases: ['log-gen-event']
66 type: str
67 description: Enable/disbale generating event for Per-Mapping log
68 choices: ['disable', 'enable']
69 log_user_info:
70 aliases: ['log-user-info']
71 type: str
72 description: Enable/disbale logging user information.
73 choices: ['disable', 'enable']
74 '''
75
76 EXAMPLES = '''
77 - name: Example playbook (generated based on argument schema)
78 hosts: fortimanagers
79 connection: httpapi
80 gather_facts: false
81 tasks:
82 - name: Create server group.
83 fortinet.fortimanager.fmgr_log_npuserver_servergroup:
84 # workspace_locking_adom: <global or your adom name>
85 adom: <your own value>
86 state: present # <value in [present, absent]>
87 log_npuserver_servergroup:
88 # group_name: <string>
89 # log_format: <value in [syslog, netflow]>
90 # log_mode: <value in [per-session, per-nat-mapping, per-session-ending]>
91 # log_tx_mode: <value in [multicast, roundrobin]>
92 # server_number: <integer>
93 # server_start_id: <integer>
94 # sw_log_flags: <value in [tcp-udp-only, enable-all-log, disable-all-log]>
95 # log_gen_event: <value in [disable, enable]>
96 # log_user_info: <value in [disable, enable]>
97 '''
98
99 RETURN = '''
100 meta:
101 description: The result of the request.
102 type: dict
103 returned: always
104 contains:
105 request_url:
106 description: The full url requested.
107 returned: always
108 type: str
109 sample: /sys/login/user
110 response_code:
111 description: The status of api request.
112 returned: always
113 type: int
114 sample: 0
115 response_data:
116 description: The api response.
117 type: list
118 returned: always
119 response_message:
120 description: The descriptive message of the api response.
121 type: str
122 returned: always
123 sample: OK.
124 system_information:
125 description: The information of the target system.
126 type: dict
127 returned: always
128 rc:
129 description: The status the request.
130 type: int
131 returned: always
132 sample: 0
133 version_check_warning:
134 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
135 type: list
136 returned: complex
137 '''
138 from ansible.module_utils.basic import AnsibleModule
139 from ansible.module_utils.connection import Connection
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
142
143
144 def main():
145 urls_list = [
146 '/pm/config/adom/{adom}/obj/log/npu-server/server-group',
147 '/pm/config/global/obj/log/npu-server/server-group'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'revision_note': {'type': 'str'},
152 'log_npuserver_servergroup': {
153 'type': 'dict', 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']],
154 'options': {
155 'group-name': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']], 'type': 'str'},
156 'log-format': {
157 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']],
158 'choices': ['syslog', 'netflow'],
159 'type': 'str'
160 },
161 'log-mode': {
162 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']],
163 'choices': ['per-session', 'per-nat-mapping', 'per-session-ending'],
164 'type': 'str'
165 },
166 'log-tx-mode': {
167 'v_range': [['6.4.7', '6.4.15'], ['7.0.2', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']],
168 'choices': ['multicast', 'roundrobin'],
169 'type': 'str'
170 },
171 'server-number': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']], 'type': 'int'},
172 'server-start-id': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']], 'type': 'int'},
173 'sw-log-flags': {'v_range': [['6.4.8', '6.4.15'], ['7.0.3', '7.0.14'], ['7.2.0', '7.4.7'], ['7.6.0', '7.6.4']], 'type': 'raw'},
174 'log-gen-event': {
175 'v_range': [['7.0.4', '7.0.14'], ['7.2.1', '7.4.7'], ['7.6.0', '7.6.4']],
176 'choices': ['disable', 'enable'],
177 'type': 'str'
178 },
179 'log-user-info': {
180 'v_range': [['7.0.4', '7.0.14'], ['7.2.1', '7.4.7'], ['7.6.0', '7.6.4']],
181 'choices': ['disable', 'enable'],
182 'type': 'str'
183 }
184 }
185 }
186 }
187
188 module_option_spec = get_module_arg_spec('full crud')
189 module_arg_spec.update(module_option_spec)
190 check_galaxy_version(module_arg_spec)
191 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'log_npuserver_servergroup'),
192 supports_check_mode=True)
193 if not module._socket_path:
194 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
195 connection = Connection(module._socket_path)
196 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
197 None, 'data', module, connection)
198 fmgr.process_crud()
199 module.exit_json(meta=module.params)
200
201
202 if __name__ == '__main__':
203 main()