Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_sniffer.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_sniffer
15 short_description: Interface sniffer.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_sniffer:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 host:
27 type: str
28 description: Hosts to filter for in sniffer traffic
29 id:
30 type: int
31 description: Sniffer ID.
32 required: true
33 interface:
34 type: str
35 description: Interface.
36 ipv6:
37 type: str
38 description:
39 - Enable/disable sniffing IPv6 packets.
40 - disable - Disable sniffer for IPv6 packets.
41 - enable - Enable sniffer for IPv6 packets.
42 choices: ['disable', 'enable']
43 max_packet_count:
44 aliases: ['max-packet-count']
45 type: int
46 description: Maximum packet count
47 non_ip:
48 aliases: ['non-ip']
49 type: str
50 description:
51 - Enable/disable sniffing non-IP packets.
52 - disable - Disable sniffer for non-IP packets.
53 - enable - Enable sniffer for non-IP packets.
54 choices: ['disable', 'enable']
55 port:
56 type: str
57 description: Ports to sniff
58 protocol:
59 type: str
60 description: Integer value for the protocol type as defined by IANA
61 vlan:
62 type: str
63 description: List of VLANs to sniff.
64 '''
65
66 EXAMPLES = '''
67 - name: Example playbook (generated based on argument schema)
68 hosts: fortimanagers
69 connection: httpapi
70 gather_facts: false
71 tasks:
72 - name: Interface sniffer.
73 fortinet.fortimanager.fmgr_system_sniffer:
74 # workspace_locking_adom: <global or your adom name>
75 state: present # <value in [present, absent]>
76 system_sniffer:
77 id: 0 # Required variable, integer
78 # host: <string>
79 # interface: <string>
80 # ipv6: <value in [disable, enable]>
81 # max_packet_count: <integer>
82 # non_ip: <value in [disable, enable]>
83 # port: <string>
84 # protocol: <string>
85 # vlan: <string>
86 '''
87
88 RETURN = '''
89 meta:
90 description: The result of the request.
91 type: dict
92 returned: always
93 contains:
94 request_url:
95 description: The full url requested.
96 returned: always
97 type: str
98 sample: /sys/login/user
99 response_code:
100 description: The status of api request.
101 returned: always
102 type: int
103 sample: 0
104 response_data:
105 description: The api response.
106 type: list
107 returned: always
108 response_message:
109 description: The descriptive message of the api response.
110 type: str
111 returned: always
112 sample: OK.
113 system_information:
114 description: The information of the target system.
115 type: dict
116 returned: always
117 rc:
118 description: The status the request.
119 type: int
120 returned: always
121 sample: 0
122 version_check_warning:
123 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
124 type: list
125 returned: complex
126 '''
127 from ansible.module_utils.basic import AnsibleModule
128 from ansible.module_utils.connection import Connection
129 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
130 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
131
132
133 def main():
134 urls_list = [
135 '/cli/global/system/sniffer'
136 ]
137 module_arg_spec = {
138 'system_sniffer': {
139 'type': 'dict', 'v_range': [['6.2.2', '']],
140 'options': {
141 'host': {'v_range': [['6.2.2', '']], 'type': 'str'},
142 'id': {'v_range': [['6.2.2', '']], 'required': True, 'type': 'int'},
143 'interface': {'v_range': [['6.2.2', '']], 'type': 'str'},
144 'ipv6': {'v_range': [['6.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
145 'max-packet-count': {'v_range': [['6.2.2', '']], 'type': 'int'},
146 'non-ip': {'v_range': [['6.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
147 'port': {'v_range': [['6.2.2', '']], 'type': 'str'},
148 'protocol': {'v_range': [['6.2.2', '']], 'type': 'str'},
149 'vlan': {'v_range': [['6.2.2', '']], 'type': 'str'}
150 }
151 }
152 }
153
154 module_option_spec = get_module_arg_spec('full crud')
155 module_arg_spec.update(module_option_spec)
156 check_galaxy_version(module_arg_spec)
157 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_sniffer'),
158 supports_check_mode=True)
159 if not module._socket_path:
160 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
161 connection = Connection(module._socket_path)
162 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
163 'id', 'data', module, connection)
164 fmgr.process_crud()
165 module.exit_json(meta=module.params)
166
167
168 if __name__ == '__main__':
169 main()