| 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_telemetrycontroller_profile |
| 15 |
short_description: Configure FortiTelemetry profiles. |
| 16 |
version_added: "2.10.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 |
telemetrycontroller_profile: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
application: |
| 34 |
type: list |
| 35 |
elements: dict |
| 36 |
description: Application. |
| 37 |
suboptions: |
| 38 |
app_name: |
| 39 |
aliases: ['app-name'] |
| 40 |
type: list |
| 41 |
elements: str |
| 42 |
description: Application name. |
| 43 |
app_throughput: |
| 44 |
aliases: ['app-throughput'] |
| 45 |
type: int |
| 46 |
description: Application throughput in megabytes |
| 47 |
atdt_threshold: |
| 48 |
aliases: ['atdt-threshold'] |
| 49 |
type: int |
| 50 |
description: Threshold of application total downloading time in milliseconds |
| 51 |
dns_time_threshold: |
| 52 |
aliases: ['dns-time-threshold'] |
| 53 |
type: int |
| 54 |
description: Threshold of DNS resolution time in milliseconds |
| 55 |
experience_score_threshold: |
| 56 |
aliases: ['experience-score-threshold'] |
| 57 |
type: int |
| 58 |
description: Threshold of experience score |
| 59 |
failure_rate_threshold: |
| 60 |
aliases: ['failure-rate-threshold'] |
| 61 |
type: int |
| 62 |
description: Threshold of failure rate |
| 63 |
id: |
| 64 |
type: int |
| 65 |
description: ID. |
| 66 |
interval: |
| 67 |
type: int |
| 68 |
description: Time in milliseconds to check the application |
| 69 |
jitter_threshold: |
| 70 |
aliases: ['jitter-threshold'] |
| 71 |
type: int |
| 72 |
description: Threshold of jitter in milliseconds |
| 73 |
latency_threshold: |
| 74 |
aliases: ['latency-threshold'] |
| 75 |
type: int |
| 76 |
description: Threshold of latency in milliseconds |
| 77 |
monitor: |
| 78 |
type: str |
| 79 |
description: Enable/disable monitoring of the application. |
| 80 |
choices: ['disable', 'enable'] |
| 81 |
packet_loss_threshold: |
| 82 |
aliases: ['packet-loss-threshold'] |
| 83 |
type: int |
| 84 |
description: Threshold of packet loss |
| 85 |
sla: |
| 86 |
type: dict |
| 87 |
description: Sla. |
| 88 |
suboptions: |
| 89 |
app_throughput_threshold: |
| 90 |
aliases: ['app-throughput-threshold'] |
| 91 |
type: int |
| 92 |
description: Threshold of application throughput in megabytes |
| 93 |
atdt_threshold: |
| 94 |
aliases: ['atdt-threshold'] |
| 95 |
type: int |
| 96 |
description: Threshold of application total downloading time in milliseconds |
| 97 |
dns_time_threshold: |
| 98 |
aliases: ['dns-time-threshold'] |
| 99 |
type: int |
| 100 |
description: Threshold of 95th percentile of DNS resolution time in milliseconds |
| 101 |
experience_score_threshold: |
| 102 |
aliases: ['experience-score-threshold'] |
| 103 |
type: int |
| 104 |
description: Threshold of experience score |
| 105 |
failure_rate_threshold: |
| 106 |
aliases: ['failure-rate-threshold'] |
| 107 |
type: int |
| 108 |
description: Threshold of failure rate |
| 109 |
jitter_threshold: |
| 110 |
aliases: ['jitter-threshold'] |
| 111 |
type: int |
| 112 |
description: Threshold of jitter in milliseconds |
| 113 |
latency_threshold: |
| 114 |
aliases: ['latency-threshold'] |
| 115 |
type: int |
| 116 |
description: Threshold of latency in milliseconds |
| 117 |
packet_loss_threshold: |
| 118 |
aliases: ['packet-loss-threshold'] |
| 119 |
type: int |
| 120 |
description: Threshold of packet loss |
| 121 |
sla_factor: |
| 122 |
aliases: ['sla-factor'] |
| 123 |
type: list |
| 124 |
elements: str |
| 125 |
description: Criteria on which metric to SLA threshold list. |
| 126 |
choices: ['latency', 'jitter', 'packet-loss', 'experience-score', |
| 127 |
'failure-rate', 'ttfb', 'atdt', 'tcp-rtt', 'dns-time', |
| 128 |
'tls-time', 'app-throughput'] |
| 129 |
tcp_rtt_threshold: |
| 130 |
aliases: ['tcp-rtt-threshold'] |
| 131 |
type: int |
| 132 |
description: Threshold of TCP round-trip time in milliseconds |
| 133 |
tls_time_threshold: |
| 134 |
aliases: ['tls-time-threshold'] |
| 135 |
type: int |
| 136 |
description: Threshold of 95th percentile of TLS handshake time in milliseconds |
| 137 |
ttfb_threshold: |
| 138 |
aliases: ['ttfb-threshold'] |
| 139 |
type: int |
| 140 |
description: Threshold of time to first byte in milliseconds |
| 141 |
tcp_rtt_threshold: |
| 142 |
aliases: ['tcp-rtt-threshold'] |
| 143 |
type: int |
| 144 |
description: Threshold of TCP round-trip time in milliseconds |
| 145 |
tls_time_threshold: |
| 146 |
aliases: ['tls-time-threshold'] |
| 147 |
type: int |
| 148 |
description: Threshold of TLS handshake time in milliseconds |
| 149 |
ttfb_threshold: |
| 150 |
aliases: ['ttfb-threshold'] |
| 151 |
type: int |
| 152 |
description: Threshold of time to first byte in milliseconds |
| 153 |
comment: |
| 154 |
type: str |
| 155 |
description: Comment. |
| 156 |
name: |
| 157 |
type: str |
| 158 |
description: Name of the profile. |
| 159 |
required: true |
| 160 |
''' |
| 161 |
|
| 162 |
EXAMPLES = ''' |
| 163 |
- name: Example playbook (generated based on argument schema) |
| 164 |
hosts: fortimanagers |
| 165 |
connection: httpapi |
| 166 |
gather_facts: false |
| 167 |
tasks: |
| 168 |
- name: Configure FortiTelemetry profiles. |
| 169 |
fortinet.fortimanager.fmgr_telemetrycontroller_profile: |
| 170 |
# workspace_locking_adom: <global or your adom name> |
| 171 |
adom: <your own value> |
| 172 |
state: present # <value in [present, absent]> |
| 173 |
telemetrycontroller_profile: |
| 174 |
name: "your value" # Required variable, string |
| 175 |
# application: |
| 176 |
# - app_name: <list or string> |
| 177 |
# app_throughput: <integer> |
| 178 |
# atdt_threshold: <integer> |
| 179 |
# dns_time_threshold: <integer> |
| 180 |
# experience_score_threshold: <integer> |
| 181 |
# failure_rate_threshold: <integer> |
| 182 |
# id: <integer> |
| 183 |
# interval: <integer> |
| 184 |
# jitter_threshold: <integer> |
| 185 |
# latency_threshold: <integer> |
| 186 |
# monitor: <value in [disable, enable]> |
| 187 |
# packet_loss_threshold: <integer> |
| 188 |
# sla: |
| 189 |
# app_throughput_threshold: <integer> |
| 190 |
# atdt_threshold: <integer> |
| 191 |
# dns_time_threshold: <integer> |
| 192 |
# experience_score_threshold: <integer> |
| 193 |
# failure_rate_threshold: <integer> |
| 194 |
# jitter_threshold: <integer> |
| 195 |
# latency_threshold: <integer> |
| 196 |
# packet_loss_threshold: <integer> |
| 197 |
# sla_factor: ["latency", "jitter", "packet-loss", "experience-score", |
| 198 |
# "failure-rate", "ttfb", "atdt", "tcp-rtt", "dns-time", "tls-time", |
| 199 |
# "app-throughput"] |
| 200 |
# tcp_rtt_threshold: <integer> |
| 201 |
# tls_time_threshold: <integer> |
| 202 |
# ttfb_threshold: <integer> |
| 203 |
# tcp_rtt_threshold: <integer> |
| 204 |
# tls_time_threshold: <integer> |
| 205 |
# ttfb_threshold: <integer> |
| 206 |
# comment: <string> |
| 207 |
''' |
| 208 |
|
| 209 |
RETURN = ''' |
| 210 |
meta: |
| 211 |
description: The result of the request. |
| 212 |
type: dict |
| 213 |
returned: always |
| 214 |
contains: |
| 215 |
request_url: |
| 216 |
description: The full url requested. |
| 217 |
returned: always |
| 218 |
type: str |
| 219 |
sample: /sys/login/user |
| 220 |
response_code: |
| 221 |
description: The status of api request. |
| 222 |
returned: always |
| 223 |
type: int |
| 224 |
sample: 0 |
| 225 |
response_data: |
| 226 |
description: The api response. |
| 227 |
type: list |
| 228 |
returned: always |
| 229 |
response_message: |
| 230 |
description: The descriptive message of the api response. |
| 231 |
type: str |
| 232 |
returned: always |
| 233 |
sample: OK. |
| 234 |
system_information: |
| 235 |
description: The information of the target system. |
| 236 |
type: dict |
| 237 |
returned: always |
| 238 |
rc: |
| 239 |
description: The status the request. |
| 240 |
type: int |
| 241 |
returned: always |
| 242 |
sample: 0 |
| 243 |
version_check_warning: |
| 244 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 245 |
type: list |
| 246 |
returned: complex |
| 247 |
''' |
| 248 |
from ansible.module_utils.basic import AnsibleModule |
| 249 |
from ansible.module_utils.connection import Connection |
| 250 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 251 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 252 |
|
| 253 |
|
| 254 |
def main(): |
| 255 |
urls_list = [ |
| 256 |
'/pm/config/adom/{adom}/obj/telemetry-controller/profile', |
| 257 |
'/pm/config/global/obj/telemetry-controller/profile' |
| 258 |
] |
| 259 |
module_arg_spec = { |
| 260 |
'adom': {'required': True, 'type': 'str'}, |
| 261 |
'revision_note': {'type': 'str'}, |
| 262 |
'telemetrycontroller_profile': { |
| 263 |
'type': 'dict', 'v_range': [['7.6.3', '']], |
| 264 |
'options': { |
| 265 |
'application': { |
| 266 |
'v_range': [['7.6.3', '']], |
| 267 |
'type': 'list', |
| 268 |
'options': { |
| 269 |
'app-name': {'v_range': [['7.6.3', '']], 'type': 'list', 'elements': 'str'}, |
| 270 |
'app-throughput': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 271 |
'atdt-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 272 |
'dns-time-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 273 |
'experience-score-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 274 |
'failure-rate-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 275 |
'id': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 276 |
'interval': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 277 |
'jitter-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 278 |
'latency-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 279 |
'monitor': {'v_range': [['7.6.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 280 |
'packet-loss-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 281 |
'sla': { |
| 282 |
'v_range': [['7.6.3', '']], |
| 283 |
'type': 'dict', |
| 284 |
'options': { |
| 285 |
'app-throughput-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 286 |
'atdt-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 287 |
'dns-time-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 288 |
'experience-score-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 289 |
'failure-rate-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 290 |
'jitter-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 291 |
'latency-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 292 |
'packet-loss-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 293 |
'sla-factor': { |
| 294 |
'v_range': [['7.6.3', '']], |
| 295 |
'type': 'list', |
| 296 |
'choices': [ |
| 297 |
'latency', 'jitter', 'packet-loss', 'experience-score', 'failure-rate', 'ttfb', 'atdt', 'tcp-rtt', 'dns-time', |
| 298 |
'tls-time', 'app-throughput' |
| 299 |
], |
| 300 |
'elements': 'str' |
| 301 |
}, |
| 302 |
'tcp-rtt-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 303 |
'tls-time-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'}, |
| 304 |
'ttfb-threshold': {'v_range': [['7.6.3', '']], 'type': 'int'} |
| 305 |
} |
| 306 |
}, |
| 307 |
'tcp-rtt-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 308 |
'tls-time-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'}, |
| 309 |
'ttfb-threshold': {'v_range': [['7.6.3', '7.6.3']], 'type': 'int'} |
| 310 |
}, |
| 311 |
'elements': 'dict' |
| 312 |
}, |
| 313 |
'comment': {'v_range': [['7.6.3', '']], 'type': 'str'}, |
| 314 |
'name': {'v_range': [['7.6.3', '']], 'required': True, 'type': 'str'} |
| 315 |
} |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
module_option_spec = get_module_arg_spec('full crud') |
| 320 |
module_arg_spec.update(module_option_spec) |
| 321 |
check_galaxy_version(module_arg_spec) |
| 322 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'telemetrycontroller_profile'), |
| 323 |
supports_check_mode=True) |
| 324 |
if not module._socket_path: |
| 325 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 326 |
connection = Connection(module._socket_path) |
| 327 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 328 |
'name', 'data', module, connection) |
| 329 |
fmgr.process_crud() |
| 330 |
module.exit_json(meta=module.params) |
| 331 |
|
| 332 |
|
| 333 |
if __name__ == '__main__': |
| 334 |
main() |