| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 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_hpe |
| 15 |
short_description: Host protection engine configuration. |
| 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_hpe: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
all_protocol: |
| 34 |
aliases: ['all-protocol'] |
| 35 |
type: int |
| 36 |
description: Maximum packet rate of each host queue except high priority traffic |
| 37 |
arp_max: |
| 38 |
aliases: ['arp-max'] |
| 39 |
type: int |
| 40 |
description: Maximum ARP packet rate |
| 41 |
enable_shaper: |
| 42 |
aliases: ['enable-shaper'] |
| 43 |
type: str |
| 44 |
description: Enable/Disable NPU Host Protection Engine |
| 45 |
choices: ['disable', 'enable'] |
| 46 |
esp_max: |
| 47 |
aliases: ['esp-max'] |
| 48 |
type: int |
| 49 |
description: Maximum ESP packet rate |
| 50 |
high_priority: |
| 51 |
aliases: ['high-priority'] |
| 52 |
type: int |
| 53 |
description: Maximum packet rate for high priority traffic packets |
| 54 |
icmp_max: |
| 55 |
aliases: ['icmp-max'] |
| 56 |
type: int |
| 57 |
description: Maximum ICMP packet rate |
| 58 |
ip_frag_max: |
| 59 |
aliases: ['ip-frag-max'] |
| 60 |
type: int |
| 61 |
description: Maximum fragmented IP packet rate |
| 62 |
ip_others_max: |
| 63 |
aliases: ['ip-others-max'] |
| 64 |
type: int |
| 65 |
description: Maximum IP packet rate for other packets |
| 66 |
l2_others_max: |
| 67 |
aliases: ['l2-others-max'] |
| 68 |
type: int |
| 69 |
description: Maximum L2 packet rate for L2 packets that are not ARP packets |
| 70 |
pri_type_max: |
| 71 |
aliases: ['pri-type-max'] |
| 72 |
type: int |
| 73 |
description: Maximum overflow rate of priority type traffic |
| 74 |
sctp_max: |
| 75 |
aliases: ['sctp-max'] |
| 76 |
type: int |
| 77 |
description: Maximum SCTP packet rate |
| 78 |
tcp_max: |
| 79 |
aliases: ['tcp-max'] |
| 80 |
type: int |
| 81 |
description: Maximum TCP packet rate |
| 82 |
tcpfin_rst_max: |
| 83 |
aliases: ['tcpfin-rst-max'] |
| 84 |
type: int |
| 85 |
description: Maximum TCP carries FIN or RST flags packet rate |
| 86 |
tcpsyn_ack_max: |
| 87 |
aliases: ['tcpsyn-ack-max'] |
| 88 |
type: int |
| 89 |
description: Maximum TCP carries SYN and ACK flags packet rate |
| 90 |
tcpsyn_max: |
| 91 |
aliases: ['tcpsyn-max'] |
| 92 |
type: int |
| 93 |
description: Maximum TCP SYN packet rate |
| 94 |
udp_max: |
| 95 |
aliases: ['udp-max'] |
| 96 |
type: int |
| 97 |
description: Maximum UDP packet rate |
| 98 |
enable_queue_shaper: |
| 99 |
aliases: ['enable-queue-shaper'] |
| 100 |
type: str |
| 101 |
description: Enable/Disable NPU host protection engine |
| 102 |
choices: ['disable', 'enable'] |
| 103 |
exception_code: |
| 104 |
aliases: ['exception-code'] |
| 105 |
type: int |
| 106 |
description: Maximum exception code rate of traffic |
| 107 |
fragment_with_sess: |
| 108 |
aliases: ['fragment-with-sess'] |
| 109 |
type: int |
| 110 |
description: Maximum fragment with session rate of traffic |
| 111 |
fragment_without_session: |
| 112 |
aliases: ['fragment-without-session'] |
| 113 |
type: int |
| 114 |
description: Maximum fragment without session rate of traffic |
| 115 |
queue_shaper_max: |
| 116 |
aliases: ['queue-shaper-max'] |
| 117 |
type: int |
| 118 |
description: Maximum per queue byte rate of traffic |
| 119 |
''' |
| 120 |
|
| 121 |
EXAMPLES = ''' |
| 122 |
- name: Example playbook (generated based on argument schema) |
| 123 |
hosts: fortimanagers |
| 124 |
connection: httpapi |
| 125 |
gather_facts: false |
| 126 |
tasks: |
| 127 |
- name: Host protection engine configuration. |
| 128 |
fortinet.fortimanager.fmgr_system_npu_hpe: |
| 129 |
# workspace_locking_adom: <global or your adom name> |
| 130 |
adom: <your own value> |
| 131 |
system_npu_hpe: |
| 132 |
# all_protocol: <integer> |
| 133 |
# arp_max: <integer> |
| 134 |
# enable_shaper: <value in [disable, enable]> |
| 135 |
# esp_max: <integer> |
| 136 |
# high_priority: <integer> |
| 137 |
# icmp_max: <integer> |
| 138 |
# ip_frag_max: <integer> |
| 139 |
# ip_others_max: <integer> |
| 140 |
# l2_others_max: <integer> |
| 141 |
# pri_type_max: <integer> |
| 142 |
# sctp_max: <integer> |
| 143 |
# tcp_max: <integer> |
| 144 |
# tcpfin_rst_max: <integer> |
| 145 |
# tcpsyn_ack_max: <integer> |
| 146 |
# tcpsyn_max: <integer> |
| 147 |
# udp_max: <integer> |
| 148 |
# enable_queue_shaper: <value in [disable, enable]> |
| 149 |
# exception_code: <integer> |
| 150 |
# fragment_with_sess: <integer> |
| 151 |
# fragment_without_session: <integer> |
| 152 |
# queue_shaper_max: <integer> |
| 153 |
''' |
| 154 |
|
| 155 |
RETURN = ''' |
| 156 |
meta: |
| 157 |
description: The result of the request. |
| 158 |
type: dict |
| 159 |
returned: always |
| 160 |
contains: |
| 161 |
request_url: |
| 162 |
description: The full url requested. |
| 163 |
returned: always |
| 164 |
type: str |
| 165 |
sample: /sys/login/user |
| 166 |
response_code: |
| 167 |
description: The status of api request. |
| 168 |
returned: always |
| 169 |
type: int |
| 170 |
sample: 0 |
| 171 |
response_data: |
| 172 |
description: The api response. |
| 173 |
type: list |
| 174 |
returned: always |
| 175 |
response_message: |
| 176 |
description: The descriptive message of the api response. |
| 177 |
type: str |
| 178 |
returned: always |
| 179 |
sample: OK. |
| 180 |
system_information: |
| 181 |
description: The information of the target system. |
| 182 |
type: dict |
| 183 |
returned: always |
| 184 |
rc: |
| 185 |
description: The status the request. |
| 186 |
type: int |
| 187 |
returned: always |
| 188 |
sample: 0 |
| 189 |
version_check_warning: |
| 190 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 191 |
type: list |
| 192 |
returned: complex |
| 193 |
''' |
| 194 |
from ansible.module_utils.basic import AnsibleModule |
| 195 |
from ansible.module_utils.connection import Connection |
| 196 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 197 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 198 |
|
| 199 |
|
| 200 |
def main(): |
| 201 |
urls_list = [ |
| 202 |
'/pm/config/adom/{adom}/obj/system/npu/hpe', |
| 203 |
'/pm/config/global/obj/system/npu/hpe' |
| 204 |
] |
| 205 |
module_arg_spec = { |
| 206 |
'adom': {'required': True, 'type': 'str'}, |
| 207 |
'revision_note': {'type': 'str'}, |
| 208 |
'system_npu_hpe': { |
| 209 |
'type': 'dict', 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], |
| 210 |
'options': { |
| 211 |
'all-protocol': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 212 |
'arp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 213 |
'enable-shaper': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 214 |
'esp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 215 |
'high-priority': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 216 |
'icmp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 217 |
'ip-frag-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 218 |
'ip-others-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 219 |
'l2-others-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 220 |
'pri-type-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 221 |
'sctp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 222 |
'tcp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 223 |
'tcpfin-rst-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 224 |
'tcpsyn-ack-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 225 |
'tcpsyn-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 226 |
'udp-max': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'}, |
| 227 |
'enable-queue-shaper': { |
| 228 |
'v_range': [['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.2', '']], |
| 229 |
'choices': ['disable', 'enable'], |
| 230 |
'type': 'str' |
| 231 |
}, |
| 232 |
'exception-code': {'v_range': [['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.2', '']], 'type': 'int'}, |
| 233 |
'fragment-with-sess': {'v_range': [['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.2', '']], 'type': 'int'}, |
| 234 |
'fragment-without-session': {'v_range': [['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.2', '']], 'type': 'int'}, |
| 235 |
'queue-shaper-max': {'v_range': [['7.0.9', '7.0.16'], ['7.2.4', '7.2.12'], ['7.4.2', '']], 'type': 'int'} |
| 236 |
} |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
module_option_spec = get_module_arg_spec('partial crud') |
| 241 |
module_arg_spec.update(module_option_spec) |
| 242 |
check_galaxy_version(module_arg_spec) |
| 243 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_npu_hpe'), |
| 244 |
supports_check_mode=True) |
| 245 |
if not module._socket_path: |
| 246 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 247 |
connection = Connection(module._socket_path) |
| 248 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 249 |
None, 'data', module, connection) |
| 250 |
fmgr.process_partial_crud() |
| 251 |
module.exit_json(meta=module.params) |
| 252 |
|
| 253 |
|
| 254 |
if __name__ == '__main__': |
| 255 |
main() |