| 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_pkg_firewall_responseshapingpolicy |
| 15 |
short_description: Policy package firewall response shaping policy |
| 16 |
version_added: "2.12.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 |
pkg: |
| 29 |
description: The parameter (pkg) in requested url. |
| 30 |
type: str |
| 31 |
required: true |
| 32 |
pkg_firewall_responseshapingpolicy: |
| 33 |
description: The top level parameters set. |
| 34 |
required: false |
| 35 |
type: dict |
| 36 |
suboptions: |
| 37 |
class_id: |
| 38 |
aliases: ['class-id'] |
| 39 |
type: int |
| 40 |
description: Class id. |
| 41 |
class_id_reverse: |
| 42 |
aliases: ['class-id-reverse'] |
| 43 |
type: int |
| 44 |
description: Class id reverse. |
| 45 |
comment: |
| 46 |
type: str |
| 47 |
description: Comment. |
| 48 |
dstaddr: |
| 49 |
type: list |
| 50 |
elements: str |
| 51 |
description: Dstaddr. |
| 52 |
dstaddr6: |
| 53 |
type: list |
| 54 |
elements: str |
| 55 |
description: Dstaddr6. |
| 56 |
id: |
| 57 |
type: int |
| 58 |
description: Id. |
| 59 |
required: true |
| 60 |
ip_version: |
| 61 |
aliases: ['ip-version'] |
| 62 |
type: str |
| 63 |
description: Ip version. |
| 64 |
choices: ['6', '4'] |
| 65 |
name: |
| 66 |
type: str |
| 67 |
description: Name. |
| 68 |
per_ip_shaper: |
| 69 |
aliases: ['per-ip-shaper'] |
| 70 |
type: list |
| 71 |
elements: str |
| 72 |
description: Per ip shaper. |
| 73 |
schedule: |
| 74 |
type: list |
| 75 |
elements: str |
| 76 |
description: Schedule. |
| 77 |
srcaddr: |
| 78 |
type: list |
| 79 |
elements: str |
| 80 |
description: Srcaddr. |
| 81 |
status: |
| 82 |
type: str |
| 83 |
description: Status. |
| 84 |
choices: ['disable', 'enable'] |
| 85 |
traffic_shaper: |
| 86 |
aliases: ['traffic-shaper'] |
| 87 |
type: list |
| 88 |
elements: str |
| 89 |
description: Traffic shaper. |
| 90 |
traffic_shaper_reverse: |
| 91 |
aliases: ['traffic-shaper-reverse'] |
| 92 |
type: list |
| 93 |
elements: str |
| 94 |
description: Traffic shaper reverse. |
| 95 |
uuid: |
| 96 |
type: str |
| 97 |
description: Uuid. |
| 98 |
diffserv_forward: |
| 99 |
aliases: ['diffserv-forward'] |
| 100 |
type: str |
| 101 |
description: Diffserv forward. |
| 102 |
choices: ['disable', 'enable'] |
| 103 |
diffserv_reverse: |
| 104 |
aliases: ['diffserv-reverse'] |
| 105 |
type: str |
| 106 |
description: Diffserv reverse. |
| 107 |
choices: ['disable', 'enable'] |
| 108 |
diffservcode_forward: |
| 109 |
aliases: ['diffservcode-forward'] |
| 110 |
type: str |
| 111 |
description: Diffservcode forward. |
| 112 |
diffservcode_rev: |
| 113 |
aliases: ['diffservcode-rev'] |
| 114 |
type: str |
| 115 |
description: Diffservcode rev. |
| 116 |
matched_shaping_policies: |
| 117 |
aliases: ['matched-shaping-policies'] |
| 118 |
type: list |
| 119 |
elements: str |
| 120 |
description: Matched shaping policies. |
| 121 |
''' |
| 122 |
|
| 123 |
EXAMPLES = ''' |
| 124 |
- name: Example playbook (generated based on argument schema) |
| 125 |
hosts: fortimanagers |
| 126 |
connection: httpapi |
| 127 |
gather_facts: false |
| 128 |
tasks: |
| 129 |
- name: Policy package firewall response shaping policy |
| 130 |
fortinet.fortimanager.fmgr_pkg_firewall_responseshapingpolicy: |
| 131 |
# workspace_locking_adom: <global or your adom name> |
| 132 |
adom: <your own value> |
| 133 |
pkg: <your own value> |
| 134 |
state: present # <value in [present, absent]> |
| 135 |
pkg_firewall_responseshapingpolicy: |
| 136 |
id: 0 # Required variable, integer |
| 137 |
# class_id: <integer> |
| 138 |
# class_id_reverse: <integer> |
| 139 |
# comment: <string> |
| 140 |
# dstaddr: <list or string> |
| 141 |
# dstaddr6: <list or string> |
| 142 |
# ip_version: <value in [6, 4]> |
| 143 |
# name: <string> |
| 144 |
# per_ip_shaper: <list or string> |
| 145 |
# schedule: <list or string> |
| 146 |
# srcaddr: <list or string> |
| 147 |
# status: <value in [disable, enable]> |
| 148 |
# traffic_shaper: <list or string> |
| 149 |
# traffic_shaper_reverse: <list or string> |
| 150 |
# uuid: <string> |
| 151 |
# diffserv_forward: <value in [disable, enable]> |
| 152 |
# diffserv_reverse: <value in [disable, enable]> |
| 153 |
# diffservcode_forward: <string> |
| 154 |
# diffservcode_rev: <string> |
| 155 |
# matched_shaping_policies: <list or string> |
| 156 |
''' |
| 157 |
|
| 158 |
RETURN = ''' |
| 159 |
meta: |
| 160 |
description: The result of the request. |
| 161 |
type: dict |
| 162 |
returned: always |
| 163 |
contains: |
| 164 |
request_url: |
| 165 |
description: The full url requested. |
| 166 |
returned: always |
| 167 |
type: str |
| 168 |
sample: /sys/login/user |
| 169 |
response_code: |
| 170 |
description: The status of api request. |
| 171 |
returned: always |
| 172 |
type: int |
| 173 |
sample: 0 |
| 174 |
response_data: |
| 175 |
description: The api response. |
| 176 |
type: list |
| 177 |
returned: always |
| 178 |
response_message: |
| 179 |
description: The descriptive message of the api response. |
| 180 |
type: str |
| 181 |
returned: always |
| 182 |
sample: OK. |
| 183 |
system_information: |
| 184 |
description: The information of the target system. |
| 185 |
type: dict |
| 186 |
returned: always |
| 187 |
rc: |
| 188 |
description: The status the request. |
| 189 |
type: int |
| 190 |
returned: always |
| 191 |
sample: 0 |
| 192 |
version_check_warning: |
| 193 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 194 |
type: list |
| 195 |
returned: complex |
| 196 |
''' |
| 197 |
from ansible.module_utils.basic import AnsibleModule |
| 198 |
from ansible.module_utils.connection import Connection |
| 199 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 200 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 201 |
|
| 202 |
|
| 203 |
def main(): |
| 204 |
urls_list = [ |
| 205 |
'/pm/config/adom/{adom}/pkg/{pkg}/firewall/response-shaping-policy' |
| 206 |
] |
| 207 |
module_arg_spec = { |
| 208 |
'adom': {'required': True, 'type': 'str'}, |
| 209 |
'pkg': {'required': True, 'type': 'str'}, |
| 210 |
'revision_note': {'type': 'str'}, |
| 211 |
'pkg_firewall_responseshapingpolicy': { |
| 212 |
'type': 'dict', 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], |
| 213 |
'options': { |
| 214 |
'class-id': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'}, |
| 215 |
'class-id-reverse': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'int'}, |
| 216 |
'comment': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'}, |
| 217 |
'dstaddr': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 218 |
'dstaddr6': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 219 |
'id': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'required': True, 'type': 'int'}, |
| 220 |
'ip-version': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['6', '4'], 'type': 'str'}, |
| 221 |
'name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'}, |
| 222 |
'per-ip-shaper': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 223 |
'schedule': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 224 |
'srcaddr': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 225 |
'status': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 226 |
'traffic-shaper': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 227 |
'traffic-shaper-reverse': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'}, |
| 228 |
'uuid': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'}, |
| 229 |
'diffserv-forward': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 230 |
'diffserv-reverse': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 231 |
'diffservcode-forward': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'type': 'str'}, |
| 232 |
'diffservcode-rev': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'type': 'str'}, |
| 233 |
'matched-shaping-policies': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'type': 'list', 'elements': 'str'} |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
module_option_spec = get_module_arg_spec('full crud') |
| 239 |
module_arg_spec.update(module_option_spec) |
| 240 |
check_galaxy_version(module_arg_spec) |
| 241 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_responseshapingpolicy'), |
| 242 |
supports_check_mode=True) |
| 243 |
if not module._socket_path: |
| 244 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 245 |
connection = Connection(module._socket_path) |
| 246 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 247 |
'id', 'data', module, connection) |
| 248 |
fmgr.process_crud() |
| 249 |
module.exit_json(meta=module.params) |
| 250 |
|
| 251 |
|
| 252 |
if __name__ == '__main__': |
| 253 |
main() |