| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
from __future__ import absolute_import, division, print_function |
| 8 |
__metaclass__ = type |
| 9 |
|
| 10 |
DOCUMENTATION = r''' |
| 11 |
--- |
| 12 |
module: bigip_profile_fastl4 |
| 13 |
short_description: Manages Fast L4 profiles |
| 14 |
description: |
| 15 |
- Manages Fast L4 profiles. Using the FastL4 profile can increase virtual server |
| 16 |
performance and throughput for supported platforms by using the embedded Packet |
| 17 |
Velocity Acceleration (ePVA) chip to accelerate traffic. |
| 18 |
version_added: "1.0.0" |
| 19 |
options: |
| 20 |
name: |
| 21 |
description: |
| 22 |
- Specifies the name of the profile. |
| 23 |
type: str |
| 24 |
required: True |
| 25 |
parent: |
| 26 |
description: |
| 27 |
- Specifies the profile from which this profile inherits settings. |
| 28 |
- When creating a new profile, if this parameter is not specified, the default |
| 29 |
is the system-supplied C(fastL4) profile. |
| 30 |
type: str |
| 31 |
idle_timeout: |
| 32 |
description: |
| 33 |
- Specifies the length of time a connection is idle (has no traffic) before |
| 34 |
the connection is eligible for deletion. |
| 35 |
- When creating a new profile, if this parameter is not specified, the remote |
| 36 |
device will choose a default value appropriate for the profile, based on its |
| 37 |
C(parent) profile. |
| 38 |
- When a number is specified, indicates the number of seconds the TCP |
| 39 |
connection can remain idle before the system deletes it. |
| 40 |
- When C(indefinite), specifies the system does not delete TCP connections |
| 41 |
regardless of how long they remain idle. |
| 42 |
- When C(0), or C(immediate), specifies the system deletes connections |
| 43 |
immediately when they become idle. |
| 44 |
type: str |
| 45 |
client_timeout: |
| 46 |
description: |
| 47 |
- Specifies a timeout for Late Binding. |
| 48 |
- This is the time limit for the client to provide the application data required to |
| 49 |
select a back-end server, meaning the maximum time the BIG-IP system |
| 50 |
waits for information about the sender and the target. |
| 51 |
- This information typically arrives at the beginning of the FIX logon packet. |
| 52 |
- When C(0), or C(immediate), allows for no time beyond the moment of the first packet |
| 53 |
transmission. |
| 54 |
- When C(indefinite), disables the limit. This allows the client unlimited time |
| 55 |
to send the sender and target information. |
| 56 |
type: str |
| 57 |
description: |
| 58 |
description: |
| 59 |
- Description of the profile. |
| 60 |
type: str |
| 61 |
explicit_flow_migration: |
| 62 |
description: |
| 63 |
- Specifies whether a qualified late-binding connection requires an explicit iRule |
| 64 |
command to migrate down to ePVA hardware. |
| 65 |
- When C(false), a late-binding connection migrates down to ePVA immediately after |
| 66 |
establishing the server-side connection. |
| 67 |
- When C(true), this parameter stops automatic migration to ePVA, and requires |
| 68 |
the iRule explicitly trigger ePVA processing by invoking the C(release_flow) |
| 69 |
iRule command. This allows an iRule author to control when the connection uses the |
| 70 |
ePVA hardware. |
| 71 |
type: bool |
| 72 |
ip_df_mode: |
| 73 |
description: |
| 74 |
- Specifies the Don't Fragment (DF) bit setting in the IP Header of the outgoing TCP packet. |
| 75 |
- When C(pmtu), sets the outgoing IP Header DF bit based on IP pmtu setting. |
| 76 |
- When C(preserve), sets the outgoing Packet's IP Header DF bit to be same as incoming IP |
| 77 |
Header DF bit. |
| 78 |
- When C(set), sets the outgoing packet's IP Header DF bit. |
| 79 |
- When C(clear), clears the outgoing packet's IP Header DF bit. |
| 80 |
type: str |
| 81 |
choices: |
| 82 |
- pmtu |
| 83 |
- preserve |
| 84 |
- set |
| 85 |
- clear |
| 86 |
ip_tos_to_client: |
| 87 |
description: |
| 88 |
- For IP traffic passing through the system to clients, specifies whether the system |
| 89 |
modifies the IP type-of-service (ToS) setting in an IP packet header. |
| 90 |
- May be a number between 0 and 255 (inclusive). When a number, specifies the IP ToS |
| 91 |
setting that the system inserts in the IP packet header. |
| 92 |
- When C(pass-through), specifies the IP ToS setting remains unchanged. |
| 93 |
- When C(mimic), specifies the system sets the ToS level of outgoing packets to |
| 94 |
the same ToS level of the most-recently received incoming packet. |
| 95 |
type: str |
| 96 |
ip_tos_to_server: |
| 97 |
description: |
| 98 |
- For IP traffic passing through the system to back-end servers, specifies whether |
| 99 |
the system modifies the IP type-of-service (ToS) setting in an IP packet header. |
| 100 |
- May be a number between 0 and 255 (inclusive). When a number, specifies the IP ToS |
| 101 |
setting that the system inserts in the IP packet header. |
| 102 |
- When C(pass-through), specifies that IP ToS setting remains unchanged. |
| 103 |
- When C(mimic), specifies the system sets the ToS level of outgoing packets to |
| 104 |
the same ToS level of the most-recently received incoming packet. |
| 105 |
type: str |
| 106 |
ip_ttl_mode: |
| 107 |
description: |
| 108 |
- Specifies the outgoing TCP packet's IP Header TTL mode. |
| 109 |
- When C(proxy), sets the outgoing IP Header TTL value to 255/64 for IPv4/IPv6 respectively. |
| 110 |
- When C(preserve), sets the outgoing IP Header TTL value to be same as the incoming |
| 111 |
IP Header TTL value. |
| 112 |
- When C(decrement), sets the outgoing IP Header TTL value to be one less than the |
| 113 |
incoming TTL value. |
| 114 |
- When C(set), sets the outgoing IP Header TTL value to a specific value(as specified |
| 115 |
by C(ip_ttl_v4) or C(ip_ttl_v6). |
| 116 |
type: str |
| 117 |
choices: |
| 118 |
- proxy |
| 119 |
- preserve |
| 120 |
- decrement |
| 121 |
- set |
| 122 |
ip_ttl_v4: |
| 123 |
description: |
| 124 |
- Specifies the outgoing packet's IP Header TTL value for IPv4 traffic. |
| 125 |
- The maximum TTL value is 255. |
| 126 |
type: int |
| 127 |
ip_ttl_v6: |
| 128 |
description: |
| 129 |
- Specifies the outgoing packet's IP Header TTL value for IPv6 traffic. |
| 130 |
- The maximum TTL value is 255. |
| 131 |
type: int |
| 132 |
keep_alive_interval: |
| 133 |
description: |
| 134 |
- Specifies the keep-alive probe interval, in seconds. |
| 135 |
type: int |
| 136 |
late_binding: |
| 137 |
description: |
| 138 |
- Enables intelligent selection of a back-end server or pool, using an |
| 139 |
iRule to make the selection. |
| 140 |
- "Enabling C(late_binding) on BIG-IP running TMOS 12.x branch requires software syn cookie is enabled." |
| 141 |
type: bool |
| 142 |
link_qos_to_client: |
| 143 |
description: |
| 144 |
- For IP traffic passing through the system to clients, specifies |
| 145 |
whether the system modifies the link quality-of-service (QoS) setting |
| 146 |
in an IP packet header. |
| 147 |
- The link QoS value prioritizes the IP packet relative to other Layer |
| 148 |
2 traffic. |
| 149 |
- You can specify a number between 0 (lowest priority) and 7 (highest priority). |
| 150 |
- When a number, specifies the link QoS setting that the system inserts |
| 151 |
in the IP packet header. |
| 152 |
- When C(pass-through), specifies the link QoS setting remains unchanged. |
| 153 |
type: str |
| 154 |
link_qos_to_server: |
| 155 |
description: |
| 156 |
- For IP traffic passing through the system to back-end servers, specifies |
| 157 |
whether the system modifies the link quality-of-service (QoS) setting |
| 158 |
in an IP packet header. |
| 159 |
- The link QoS value prioritizes the IP packet relative to other Layer |
| 160 |
2 traffic. |
| 161 |
- You can specify a number between 0 (lowest priority) and 7 (highest priority). |
| 162 |
- When a number, specifies the link QoS setting that the system inserts |
| 163 |
in the IP packet header. |
| 164 |
- When C(pass-through), specifies the link QoS setting remains unchanged. |
| 165 |
type: str |
| 166 |
loose_close: |
| 167 |
description: |
| 168 |
- When C(true), specifies the system closes a loosely-initiated connection |
| 169 |
when the system receives the first FIN packet from either the client or the server. |
| 170 |
type: bool |
| 171 |
loose_initialization: |
| 172 |
description: |
| 173 |
- When C(true), specifies the system initializes a connection when it |
| 174 |
receives any TCP packet, rather than requiring a SYN packet for connection |
| 175 |
initiation. |
| 176 |
type: bool |
| 177 |
mss_override: |
| 178 |
description: |
| 179 |
- Specifies a maximum segment size (MSS) override for server-side connections. |
| 180 |
- Valid range is 256 to 9162 or 0 to disable. |
| 181 |
type: int |
| 182 |
reassemble_fragments: |
| 183 |
description: |
| 184 |
- When C(true), specifies the system reassembles IP fragments. |
| 185 |
type: bool |
| 186 |
receive_window_size: |
| 187 |
description: |
| 188 |
- Specifies the amount of data the BIG-IP system can accept without acknowledging |
| 189 |
the server. |
| 190 |
type: int |
| 191 |
reset_on_timeout: |
| 192 |
description: |
| 193 |
- When C(true), specifies the system sends a reset packet (RST) in addition |
| 194 |
to deleting the connection, when a connection exceeds the idle timeout value. |
| 195 |
type: bool |
| 196 |
rtt_from_client: |
| 197 |
description: |
| 198 |
- When C(true), specifies the system uses TCP timestamp options to measure |
| 199 |
the round-trip time to the client. |
| 200 |
type: bool |
| 201 |
rtt_from_server: |
| 202 |
description: |
| 203 |
- When C(true), specifies the system uses TCP timestamp options to measure |
| 204 |
the round-trip time to the server. |
| 205 |
type: bool |
| 206 |
server_sack: |
| 207 |
description: |
| 208 |
- Specifies whether the BIG-IP system processes Selective ACK (Sack) packets |
| 209 |
in cookie responses from the server. |
| 210 |
type: bool |
| 211 |
server_timestamp: |
| 212 |
description: |
| 213 |
- Specifies whether the BIG-IP system processes timestamp request packets in |
| 214 |
cookie responses from the server. |
| 215 |
type: bool |
| 216 |
syn_cookie_mss: |
| 217 |
description: |
| 218 |
- Specifies a value that overrides the SYN cookie maximum segment size (MSS) |
| 219 |
value in the SYN-ACK packet that is returned to the client. |
| 220 |
- Valid values are 0, and values from 256 through 9162. |
| 221 |
- Parameter only available on TMOS 13.0.0 and higher. |
| 222 |
type: int |
| 223 |
tcp_close_timeout: |
| 224 |
description: |
| 225 |
- Specifies the length of time a connection can remain idle before deletion. |
| 226 |
type: str |
| 227 |
tcp_generate_isn: |
| 228 |
description: |
| 229 |
- When C(true), specifies the system generates initial sequence numbers |
| 230 |
for SYN packets, according to RFC 1948. |
| 231 |
type: bool |
| 232 |
tcp_handshake_timeout: |
| 233 |
description: |
| 234 |
- Specifies the acceptable duration for a TCP handshake (the maximum |
| 235 |
idle time between a client synchronization (SYN) and a client acknowledgment |
| 236 |
(ACK)). If the TCP handshake takes longer than the timeout, the system |
| 237 |
automatically closes the connection. |
| 238 |
- When a number, specifies how long the system can try to establish a TCP |
| 239 |
handshake before timing out. |
| 240 |
- When C(disabled), specifies the system does not apply a timeout to a |
| 241 |
TCP handshake. |
| 242 |
- When C(indefinite), specifies attempting a TCP handshake never times out. |
| 243 |
type: str |
| 244 |
tcp_strip_sack: |
| 245 |
description: |
| 246 |
- When C(true), specifies the system blocks a TCP selective ACK SackOK |
| 247 |
option from passing to the server on an initiating SYN. |
| 248 |
type: bool |
| 249 |
tcp_time_wait_timeout: |
| 250 |
description: |
| 251 |
- Specifies the number of milliseconds a connection is in the TIME-WAIT |
| 252 |
state before closing. |
| 253 |
- This parameter is only available on TMOS 13.0.0 and later. |
| 254 |
type: int |
| 255 |
tcp_timestamp_mode: |
| 256 |
description: |
| 257 |
- Specifies the action the system should take on TCP timestamps. |
| 258 |
type: str |
| 259 |
choices: |
| 260 |
- preserve |
| 261 |
- rewrite |
| 262 |
- strip |
| 263 |
tcp_wscale_mode: |
| 264 |
description: |
| 265 |
- Specifies the action the system should take on TCP windows. |
| 266 |
type: str |
| 267 |
choices: |
| 268 |
- preserve |
| 269 |
- rewrite |
| 270 |
- strip |
| 271 |
timeout_recovery: |
| 272 |
description: |
| 273 |
- Specifies how to handle client-timeout errors for Late Binding. |
| 274 |
- Timeout errors may be caused by a DoS attack or a lossy connection. |
| 275 |
- When C(disconnect), causes the BIG-IP system to drop the connection. |
| 276 |
- When C(fallback), reverts the connection to normal FastL4 load-balancing, |
| 277 |
based on the client's TCP header. This causes the BIG-IP system to choose |
| 278 |
a back-end server based only on the source address and port. |
| 279 |
type: str |
| 280 |
choices: |
| 281 |
- disconnect |
| 282 |
- fallback |
| 283 |
hardware_syn_cookie: |
| 284 |
description: |
| 285 |
- Enables or disables hardware SYN cookie support when PVA10 is present on the system. |
| 286 |
type: bool |
| 287 |
syn_cookie_enable: |
| 288 |
description: |
| 289 |
- Specifies whether or not to use SYN Cookie. |
| 290 |
type: bool |
| 291 |
version_added: "1.11.0" |
| 292 |
pva_acceleration: |
| 293 |
description: |
| 294 |
- Specifies the Packet Velocity ASIC acceleration policy. |
| 295 |
type: str |
| 296 |
choices: |
| 297 |
- full |
| 298 |
- dedicated |
| 299 |
- partial |
| 300 |
- none |
| 301 |
version_added: "1.3.0" |
| 302 |
partition: |
| 303 |
description: |
| 304 |
- Device partition to manage resources on. |
| 305 |
type: str |
| 306 |
default: Common |
| 307 |
state: |
| 308 |
description: |
| 309 |
- When C(present), ensures the profile exists. |
| 310 |
- When C(absent), ensures the profile is removed. |
| 311 |
type: str |
| 312 |
choices: |
| 313 |
- present |
| 314 |
- absent |
| 315 |
default: present |
| 316 |
extends_documentation_fragment: f5networks.f5_modules.f5 |
| 317 |
author: |
| 318 |
- Tim Rupp (@caphrim007) |
| 319 |
- Wojciech Wypior (@wojtek0806) |
| 320 |
''' |
| 321 |
|
| 322 |
EXAMPLES = r''' |
| 323 |
- name: Create a fastL4 profile |
| 324 |
bigip_profile_fastl4: |
| 325 |
name: foo |
| 326 |
provider: |
| 327 |
password: secret |
| 328 |
server: lb.mydomain.com |
| 329 |
user: admin |
| 330 |
delegate_to: localhost |
| 331 |
''' |
| 332 |
|
| 333 |
RETURN = r''' |
| 334 |
client_timeout: |
| 335 |
description: The new client timeout value of the resource. |
| 336 |
returned: changed |
| 337 |
type: str |
| 338 |
sample: true |
| 339 |
description: |
| 340 |
description: The new description. |
| 341 |
returned: changed |
| 342 |
type: str |
| 343 |
sample: My description |
| 344 |
explicit_flow_migration: |
| 345 |
description: The new flow migration setting. |
| 346 |
returned: changed |
| 347 |
type: bool |
| 348 |
sample: true |
| 349 |
idle_timeout: |
| 350 |
description: The new idle timeout setting. |
| 351 |
returned: changed |
| 352 |
type: str |
| 353 |
sample: 123 |
| 354 |
ip_df_mode: |
| 355 |
description: The new Don't Fragment Flag (DF) setting. |
| 356 |
returned: changed |
| 357 |
type: str |
| 358 |
sample: clear |
| 359 |
ip_tos_to_client: |
| 360 |
description: The new IP ToS to Client setting. |
| 361 |
returned: changed |
| 362 |
type: str |
| 363 |
sample: 100 |
| 364 |
ip_tos_to_server: |
| 365 |
description: The new IP ToS to Server setting. |
| 366 |
returned: changed |
| 367 |
type: str |
| 368 |
sample: 100 |
| 369 |
ip_ttl_mode: |
| 370 |
description: The new Time To Live (TTL) setting. |
| 371 |
returned: changed |
| 372 |
type: str |
| 373 |
sample: proxy |
| 374 |
ip_ttl_v4: |
| 375 |
description: The new Time To Live (TTL) v4 setting. |
| 376 |
returned: changed |
| 377 |
type: int |
| 378 |
sample: 200 |
| 379 |
ip_ttl_v6: |
| 380 |
description: The new Time To Live (TTL) v6 setting. |
| 381 |
returned: changed |
| 382 |
type: int |
| 383 |
sample: 200 |
| 384 |
keep_alive_interval: |
| 385 |
description: The new TCP Keep Alive Interval setting. |
| 386 |
returned: changed |
| 387 |
type: int |
| 388 |
sample: 100 |
| 389 |
late_binding: |
| 390 |
description: The new Late Binding setting. |
| 391 |
returned: changed |
| 392 |
type: bool |
| 393 |
sample: true |
| 394 |
link_qos_to_client: |
| 395 |
description: The new Link QoS to Client setting. |
| 396 |
returned: changed |
| 397 |
type: str |
| 398 |
sample: pass-through |
| 399 |
link_qos_to_server: |
| 400 |
description: The new Link QoS to Server setting. |
| 401 |
returned: changed |
| 402 |
type: str |
| 403 |
sample: 123 |
| 404 |
loose_close: |
| 405 |
description: The new Loose Close setting. |
| 406 |
returned: changed |
| 407 |
type: bool |
| 408 |
sample: false |
| 409 |
loose_initialization: |
| 410 |
description: The new Loose Initiation setting. |
| 411 |
returned: changed |
| 412 |
type: bool |
| 413 |
sample: false |
| 414 |
mss_override: |
| 415 |
description: The new Maximum Segment Size Override setting. |
| 416 |
returned: changed |
| 417 |
type: int |
| 418 |
sample: 300 |
| 419 |
reassemble_fragments: |
| 420 |
description: The new Reassemble IP Fragments setting. |
| 421 |
returned: changed |
| 422 |
type: bool |
| 423 |
sample: true |
| 424 |
receive_window_size: |
| 425 |
description: The new Receive Window setting. |
| 426 |
returned: changed |
| 427 |
type: int |
| 428 |
sample: 1024 |
| 429 |
reset_on_timeout: |
| 430 |
description: The new Reset on Timeout setting. |
| 431 |
returned: changed |
| 432 |
type: bool |
| 433 |
sample: false |
| 434 |
rtt_from_client: |
| 435 |
description: The new RTT from Client setting. |
| 436 |
returned: changed |
| 437 |
type: bool |
| 438 |
sample: false |
| 439 |
rtt_from_server: |
| 440 |
description: The new RTT from Server setting. |
| 441 |
returned: changed |
| 442 |
type: bool |
| 443 |
sample: false |
| 444 |
server_sack: |
| 445 |
description: The new Server Sack setting. |
| 446 |
returned: changed |
| 447 |
type: bool |
| 448 |
sample: true |
| 449 |
server_timestamp: |
| 450 |
description: The new Server Timestamp setting. |
| 451 |
returned: changed |
| 452 |
type: bool |
| 453 |
sample: true |
| 454 |
syn_cookie_mss: |
| 455 |
description: The new SYN Cookie MSS setting. |
| 456 |
returned: changed |
| 457 |
type: int |
| 458 |
sample: 1024 |
| 459 |
tcp_close_timeout: |
| 460 |
description: The new TCP Close Timeout setting. |
| 461 |
returned: changed |
| 462 |
type: str |
| 463 |
sample: 100 |
| 464 |
tcp_generate_isn: |
| 465 |
description: The new Generate Initial Sequence Number setting. |
| 466 |
returned: changed |
| 467 |
type: bool |
| 468 |
sample: false |
| 469 |
tcp_handshake_timeout: |
| 470 |
description: The new TCP Handshake Timeout setting. |
| 471 |
returned: changed |
| 472 |
type: int |
| 473 |
sample: 5 |
| 474 |
tcp_strip_sack: |
| 475 |
description: The new Strip Sack OK setting. |
| 476 |
returned: changed |
| 477 |
type: bool |
| 478 |
sample: false |
| 479 |
tcp_time_wait_timeout: |
| 480 |
description: The new TCP Time Wait Timeout setting. |
| 481 |
returned: changed |
| 482 |
type: int |
| 483 |
sample: 100 |
| 484 |
tcp_timestamp_mode: |
| 485 |
description: The new TCP Timestamp Mode setting. |
| 486 |
returned: changed |
| 487 |
type: str |
| 488 |
sample: rewrite |
| 489 |
tcp_wscale_mode: |
| 490 |
description: The new TCP Window Scale Mode setting. |
| 491 |
returned: changed |
| 492 |
type: str |
| 493 |
sample: strip |
| 494 |
timeout_recovery: |
| 495 |
description: The new Timeout Recovery setting. |
| 496 |
returned: changed |
| 497 |
type: str |
| 498 |
sample: fallback |
| 499 |
hardware_syn_cookie: |
| 500 |
description: Enables or disables hardware SYN cookie support when PVA10 is present on the system. |
| 501 |
returned: changed |
| 502 |
type: bool |
| 503 |
sample: false |
| 504 |
syn_cookie_enable: |
| 505 |
description: Specifies whether or not to use SYN Cookie. |
| 506 |
returned: changed |
| 507 |
type: bool |
| 508 |
sample: false |
| 509 |
pva_acceleration: |
| 510 |
description: Specifies the Packet Velocity ASIC acceleration policy. |
| 511 |
returned: changed |
| 512 |
type: str |
| 513 |
sample: full |
| 514 |
''' |
| 515 |
from datetime import datetime |
| 516 |
|
| 517 |
from ansible.module_utils.basic import ( |
| 518 |
AnsibleModule, env_fallback |
| 519 |
) |
| 520 |
|
| 521 |
from ..module_utils.bigip import F5RestClient |
| 522 |
from ..module_utils.common import ( |
| 523 |
F5ModuleError, AnsibleF5Parameters, transform_name, f5_argument_spec, flatten_boolean, fq_name |
| 524 |
) |
| 525 |
from ..module_utils.icontrol import tmos_version |
| 526 |
from ..module_utils.teem import send_teem |
| 527 |
|
| 528 |
|
| 529 |
class Parameters(AnsibleF5Parameters): |
| 530 |
api_map = { |
| 531 |
'clientTimeout': 'client_timeout', |
| 532 |
'defaultsFrom': 'parent', |
| 533 |
'explicitFlowMigration': 'explicit_flow_migration', |
| 534 |
'idleTimeout': 'idle_timeout', |
| 535 |
'ipDfMode': 'ip_df_mode', |
| 536 |
'ipTosToClient': 'ip_tos_to_client', |
| 537 |
'ipTosToServer': 'ip_tos_to_server', |
| 538 |
'ipTtlMode': 'ip_ttl_mode', |
| 539 |
'ipTtlV4': 'ip_ttl_v4', |
| 540 |
'ipTtlV6': 'ip_ttl_v6', |
| 541 |
'keepAliveInterval': 'keep_alive_interval', |
| 542 |
'lateBinding': 'late_binding', |
| 543 |
'linkQosToClient': 'link_qos_to_client', |
| 544 |
'linkQosToServer': 'link_qos_to_server', |
| 545 |
'looseClose': 'loose_close', |
| 546 |
'looseInitialization': 'loose_initialization', |
| 547 |
'mssOverride': 'mss_override', |
| 548 |
'reassembleFragments': 'reassemble_fragments', |
| 549 |
'receiveWindowSize': 'receive_window_size', |
| 550 |
'resetOnTimeout': 'reset_on_timeout', |
| 551 |
'rttFromClient': 'rtt_from_client', |
| 552 |
'rttFromServer': 'rtt_from_server', |
| 553 |
'serverSack': 'server_sack', |
| 554 |
'serverTimestamp': 'server_timestamp', |
| 555 |
'synCookieMss': 'syn_cookie_mss', |
| 556 |
'tcpCloseTimeout': 'tcp_close_timeout', |
| 557 |
'tcpGenerateIsn': 'tcp_generate_isn', |
| 558 |
'tcpHandshakeTimeout': 'tcp_handshake_timeout', |
| 559 |
'tcpStripSack': 'tcp_strip_sack', |
| 560 |
'tcpTimeWaitTimeout': 'tcp_time_wait_timeout', |
| 561 |
'tcpTimestampMode': 'tcp_timestamp_mode', |
| 562 |
'tcpWscaleMode': 'tcp_wscale_mode', |
| 563 |
'timeoutRecovery': 'timeout_recovery', |
| 564 |
'hardwareSynCookie': 'hardware_syn_cookie', |
| 565 |
'synCookieEnable': 'syn_cookie_enable', |
| 566 |
'pvaAcceleration': 'pva_acceleration', |
| 567 |
} |
| 568 |
|
| 569 |
api_attributes = [ |
| 570 |
'clientTimeout', |
| 571 |
'defaultsFrom', |
| 572 |
'description', |
| 573 |
'explicitFlowMigration', |
| 574 |
'idleTimeout', |
| 575 |
'ipDfMode', |
| 576 |
'ipTosToClient', |
| 577 |
'ipTosToServer', |
| 578 |
'ipTtlMode', |
| 579 |
'ipTtlV4', |
| 580 |
'ipTtlV6', |
| 581 |
'keepAliveInterval', |
| 582 |
'lateBinding', |
| 583 |
'linkQosToClient', |
| 584 |
'linkQosToServer', |
| 585 |
'looseClose', |
| 586 |
'looseInitialization', |
| 587 |
'mssOverride', |
| 588 |
'reassembleFragments', |
| 589 |
'receiveWindowSize', |
| 590 |
'resetOnTimeout', |
| 591 |
'rttFromClient', |
| 592 |
'rttFromServer', |
| 593 |
'serverSack', |
| 594 |
'serverTimestamp', |
| 595 |
'synCookieMss', |
| 596 |
'tcpCloseTimeout', |
| 597 |
'tcpGenerateIsn', |
| 598 |
'tcpHandshakeTimeout', |
| 599 |
'tcpStripSack', |
| 600 |
'tcpTimeWaitTimeout', |
| 601 |
'tcpTimestampMode', |
| 602 |
'tcpWscaleMode', |
| 603 |
'timeoutRecovery', |
| 604 |
'hardwareSynCookie', |
| 605 |
'synCookieEnable', |
| 606 |
'pvaAcceleration', |
| 607 |
] |
| 608 |
|
| 609 |
returnables = [ |
| 610 |
'client_timeout', |
| 611 |
'description', |
| 612 |
'explicit_flow_migration', |
| 613 |
'idle_timeout', |
| 614 |
'ip_df_mode', |
| 615 |
'ip_tos_to_client', |
| 616 |
'ip_tos_to_server', |
| 617 |
'ip_ttl_mode', |
| 618 |
'ip_ttl_v4', |
| 619 |
'ip_ttl_v6', |
| 620 |
'keep_alive_interval', |
| 621 |
'late_binding', |
| 622 |
'link_qos_to_client', |
| 623 |
'link_qos_to_server', |
| 624 |
'loose_close', |
| 625 |
'loose_initialization', |
| 626 |
'mss_override', |
| 627 |
'parent', |
| 628 |
'reassemble_fragments', |
| 629 |
'receive_window_size', |
| 630 |
'reset_on_timeout', |
| 631 |
'rtt_from_client', |
| 632 |
'rtt_from_server', |
| 633 |
'server_sack', |
| 634 |
'server_timestamp', |
| 635 |
'syn_cookie_mss', |
| 636 |
'tcp_close_timeout', |
| 637 |
'tcp_generate_isn', |
| 638 |
'tcp_handshake_timeout', |
| 639 |
'tcp_strip_sack', |
| 640 |
'tcp_time_wait_timeout', |
| 641 |
'tcp_timestamp_mode', |
| 642 |
'tcp_wscale_mode', |
| 643 |
'timeout_recovery', |
| 644 |
'hardware_syn_cookie', |
| 645 |
'pva_acceleration', |
| 646 |
] |
| 647 |
|
| 648 |
updatables = [ |
| 649 |
'client_timeout', |
| 650 |
'description', |
| 651 |
'explicit_flow_migration', |
| 652 |
'idle_timeout', |
| 653 |
'ip_df_mode', |
| 654 |
'ip_tos_to_client', |
| 655 |
'ip_tos_to_server', |
| 656 |
'ip_ttl_mode', |
| 657 |
'ip_ttl_v4', |
| 658 |
'ip_ttl_v6', |
| 659 |
'keep_alive_interval', |
| 660 |
'late_binding', |
| 661 |
'link_qos_to_client', |
| 662 |
'link_qos_to_server', |
| 663 |
'loose_close', |
| 664 |
'loose_initialization', |
| 665 |
'mss_override', |
| 666 |
'parent', |
| 667 |
'reassemble_fragments', |
| 668 |
'receive_window_size', |
| 669 |
'reset_on_timeout', |
| 670 |
'rtt_from_client', |
| 671 |
'rtt_from_server', |
| 672 |
'server_sack', |
| 673 |
'server_timestamp', |
| 674 |
'syn_cookie_mss', |
| 675 |
'tcp_close_timeout', |
| 676 |
'tcp_generate_isn', |
| 677 |
'tcp_handshake_timeout', |
| 678 |
'tcp_strip_sack', |
| 679 |
'tcp_time_wait_timeout', |
| 680 |
'tcp_timestamp_mode', |
| 681 |
'tcp_wscale_mode', |
| 682 |
'timeout_recovery', |
| 683 |
'hardware_syn_cookie', |
| 684 |
'syn_cookie_enable', |
| 685 |
'pva_acceleration', |
| 686 |
] |
| 687 |
|
| 688 |
@property |
| 689 |
def explicit_flow_migration(self): |
| 690 |
result = flatten_boolean(self._values['explicit_flow_migration']) |
| 691 |
return result |
| 692 |
|
| 693 |
@property |
| 694 |
def late_binding(self): |
| 695 |
return flatten_boolean(self._values['late_binding']) |
| 696 |
|
| 697 |
@property |
| 698 |
def loose_close(self): |
| 699 |
return flatten_boolean(self._values['loose_close']) |
| 700 |
|
| 701 |
@property |
| 702 |
def loose_initialization(self): |
| 703 |
return flatten_boolean(self._values['loose_initialization']) |
| 704 |
|
| 705 |
@property |
| 706 |
def reassemble_fragments(self): |
| 707 |
return flatten_boolean(self._values['reassemble_fragments']) |
| 708 |
|
| 709 |
@property |
| 710 |
def reset_on_timeout(self): |
| 711 |
return flatten_boolean(self._values['reset_on_timeout']) |
| 712 |
|
| 713 |
@property |
| 714 |
def rtt_from_client(self): |
| 715 |
return flatten_boolean(self._values['rtt_from_client']) |
| 716 |
|
| 717 |
@property |
| 718 |
def rtt_from_server(self): |
| 719 |
return flatten_boolean(self._values['rtt_from_server']) |
| 720 |
|
| 721 |
@property |
| 722 |
def server_sack(self): |
| 723 |
return flatten_boolean(self._values['server_sack']) |
| 724 |
|
| 725 |
@property |
| 726 |
def server_timestamp(self): |
| 727 |
return flatten_boolean(self._values['server_timestamp']) |
| 728 |
|
| 729 |
@property |
| 730 |
def tcp_generate_isn(self): |
| 731 |
return flatten_boolean(self._values['tcp_generate_isn']) |
| 732 |
|
| 733 |
@property |
| 734 |
def tcp_strip_sack(self): |
| 735 |
return flatten_boolean(self._values['tcp_strip_sack']) |
| 736 |
|
| 737 |
@property |
| 738 |
def tcp_close_timeout(self): |
| 739 |
if self._values['tcp_close_timeout'] is None: |
| 740 |
return None |
| 741 |
try: |
| 742 |
return int(self._values['tcp_close_timeout']) |
| 743 |
except ValueError: |
| 744 |
return self._values['tcp_close_timeout'] |
| 745 |
|
| 746 |
@property |
| 747 |
def tcp_handshake_timeout(self): |
| 748 |
if self._values['tcp_handshake_timeout'] is None: |
| 749 |
return None |
| 750 |
try: |
| 751 |
return int(self._values['tcp_handshake_timeout']) |
| 752 |
except ValueError: |
| 753 |
if self._values['tcp_handshake_timeout'] in ['disabled', 'immediate']: |
| 754 |
return 0 |
| 755 |
return self._values['tcp_handshake_timeout'] |
| 756 |
|
| 757 |
@property |
| 758 |
def client_timeout(self): |
| 759 |
if self._values['client_timeout'] is None: |
| 760 |
return None |
| 761 |
try: |
| 762 |
return int(self._values['client_timeout']) |
| 763 |
except ValueError: |
| 764 |
if self._values['client_timeout'] == 'immediate': |
| 765 |
return 0 |
| 766 |
if self._values['client_timeout'] == 'indefinite': |
| 767 |
return 4294967295 |
| 768 |
return self._values['client_timeout'] |
| 769 |
|
| 770 |
@property |
| 771 |
def parent(self): |
| 772 |
if self._values['parent'] is None: |
| 773 |
return None |
| 774 |
result = fq_name(self.partition, self._values['parent']) |
| 775 |
return result |
| 776 |
|
| 777 |
|
| 778 |
class ApiParameters(Parameters): |
| 779 |
@property |
| 780 |
def description(self): |
| 781 |
if self._values['description'] in [None, 'none']: |
| 782 |
return None |
| 783 |
return self._values['description'] |
| 784 |
|
| 785 |
@property |
| 786 |
def idle_timeout(self): |
| 787 |
if self._values['idle_timeout'] is None: |
| 788 |
return None |
| 789 |
try: |
| 790 |
return int(self._values['idle_timeout']) |
| 791 |
except ValueError: |
| 792 |
return self._values['idle_timeout'] |
| 793 |
|
| 794 |
@property |
| 795 |
def ip_tos_to_client(self): |
| 796 |
return self.transform_ip_tos('ip_tos_to_client') |
| 797 |
|
| 798 |
@property |
| 799 |
def ip_tos_to_server(self): |
| 800 |
return self.transform_ip_tos('ip_tos_to_server') |
| 801 |
|
| 802 |
@property |
| 803 |
def keep_alive_interval(self): |
| 804 |
if self._values['keep_alive_interval'] is None: |
| 805 |
return None |
| 806 |
try: |
| 807 |
return int(self._values['keep_alive_interval']) |
| 808 |
except ValueError: |
| 809 |
return self._values['keep_alive_interval'] |
| 810 |
|
| 811 |
@property |
| 812 |
def link_qos_to_client(self): |
| 813 |
return self.transform_link_qos('link_qos_to_client') |
| 814 |
|
| 815 |
@property |
| 816 |
def link_qos_to_server(self): |
| 817 |
return self.transform_link_qos('link_qos_to_server') |
| 818 |
|
| 819 |
def transform_ip_tos(self, key): |
| 820 |
if self._values[key] is None: |
| 821 |
return None |
| 822 |
try: |
| 823 |
result = int(self._values[key]) |
| 824 |
return result |
| 825 |
except ValueError: |
| 826 |
return self._values[key] |
| 827 |
|
| 828 |
def transform_link_qos(self, key): |
| 829 |
if self._values[key] is None: |
| 830 |
return None |
| 831 |
if self._values[key] == 'pass-through': |
| 832 |
return 'pass-through' |
| 833 |
if 0 <= int(self._values[key]) <= 7: |
| 834 |
return int(self._values[key]) |
| 835 |
|
| 836 |
|
| 837 |
class ModuleParameters(Parameters): |
| 838 |
@property |
| 839 |
def description(self): |
| 840 |
if self._values['description'] is None: |
| 841 |
return None |
| 842 |
elif self._values['description'] in ['none', '']: |
| 843 |
return '' |
| 844 |
return self._values['description'] |
| 845 |
|
| 846 |
@property |
| 847 |
def idle_timeout(self): |
| 848 |
if self._values['idle_timeout'] is None: |
| 849 |
return None |
| 850 |
try: |
| 851 |
result = int(self._values['idle_timeout']) |
| 852 |
if result == 0: |
| 853 |
return 'immediate' |
| 854 |
return result |
| 855 |
except ValueError: |
| 856 |
return self._values['idle_timeout'] |
| 857 |
|
| 858 |
@property |
| 859 |
def ip_tos_to_client(self): |
| 860 |
return self.transform_ip_tos('ip_tos_to_client') |
| 861 |
|
| 862 |
@property |
| 863 |
def ip_tos_to_server(self): |
| 864 |
return self.transform_ip_tos('ip_tos_to_server') |
| 865 |
|
| 866 |
@property |
| 867 |
def ip_ttl_v4(self): |
| 868 |
if self._values['ip_ttl_v4'] is None: |
| 869 |
return None |
| 870 |
if 0 <= self._values['ip_ttl_v4'] <= 255: |
| 871 |
return int(self._values['ip_ttl_v4']) |
| 872 |
raise F5ModuleError( |
| 873 |
'ip_ttl_v4 must be between 0 and 255' |
| 874 |
) |
| 875 |
|
| 876 |
@property |
| 877 |
def ip_ttl_v6(self): |
| 878 |
if self._values['ip_ttl_v6'] is None: |
| 879 |
return None |
| 880 |
if 0 <= self._values['ip_ttl_v6'] <= 255: |
| 881 |
return int(self._values['ip_ttl_v6']) |
| 882 |
raise F5ModuleError( |
| 883 |
'ip_ttl_v6 must be between 0 and 255' |
| 884 |
) |
| 885 |
|
| 886 |
@property |
| 887 |
def keep_alive_interval(self): |
| 888 |
if self._values['keep_alive_interval'] is None: |
| 889 |
return None |
| 890 |
result = int(self._values['keep_alive_interval']) |
| 891 |
if result == 0: |
| 892 |
return 'disabled' |
| 893 |
return result |
| 894 |
|
| 895 |
@property |
| 896 |
def link_qos_to_client(self): |
| 897 |
result = self.transform_link_qos('link_qos_to_client') |
| 898 |
if result == -1: |
| 899 |
raise F5ModuleError( |
| 900 |
'link_qos_to_client must be between 0 and 7' |
| 901 |
) |
| 902 |
return result |
| 903 |
|
| 904 |
@property |
| 905 |
def link_qos_to_server(self): |
| 906 |
result = self.transform_link_qos('link_qos_to_server') |
| 907 |
if result == -1: |
| 908 |
raise F5ModuleError( |
| 909 |
'link_qos_to_server must be between 0 and 7' |
| 910 |
) |
| 911 |
return result |
| 912 |
|
| 913 |
def transform_link_qos(self, key): |
| 914 |
if self._values[key] is None: |
| 915 |
return None |
| 916 |
if self._values[key] == 'pass-through': |
| 917 |
return 'pass-through' |
| 918 |
if 0 <= int(self._values[key]) <= 7: |
| 919 |
return int(self._values[key]) |
| 920 |
else: |
| 921 |
return -1 |
| 922 |
|
| 923 |
def transform_ip_tos(self, key): |
| 924 |
if self._values[key] is None: |
| 925 |
return None |
| 926 |
try: |
| 927 |
result = int(self._values[key]) |
| 928 |
return result |
| 929 |
except ValueError: |
| 930 |
if self._values[key] == 'mimic': |
| 931 |
return 65534 |
| 932 |
return self._values[key] |
| 933 |
|
| 934 |
@property |
| 935 |
def hardware_syn_cookie(self): |
| 936 |
result = flatten_boolean(self._values['hardware_syn_cookie']) |
| 937 |
if result == 'yes': |
| 938 |
return 'enabled' |
| 939 |
if result == 'no': |
| 940 |
return 'disabled' |
| 941 |
|
| 942 |
@property |
| 943 |
def syn_cookie_enable(self): |
| 944 |
result = flatten_boolean(self._values['syn_cookie_enable']) |
| 945 |
if result == 'yes': |
| 946 |
return 'enabled' |
| 947 |
if result == 'no': |
| 948 |
return 'disabled' |
| 949 |
|
| 950 |
|
| 951 |
class Changes(Parameters): |
| 952 |
def to_return(self): |
| 953 |
result = {} |
| 954 |
try: |
| 955 |
for returnable in self.returnables: |
| 956 |
result[returnable] = getattr(self, returnable) |
| 957 |
result = self._filter_params(result) |
| 958 |
except Exception: |
| 959 |
raise |
| 960 |
return result |
| 961 |
|
| 962 |
|
| 963 |
class UsableChanges(Changes): |
| 964 |
@property |
| 965 |
def explicit_flow_migration(self): |
| 966 |
if self._values['explicit_flow_migration'] == 'yes': |
| 967 |
return 'enabled' |
| 968 |
elif self._values['explicit_flow_migration'] == 'no': |
| 969 |
return 'disabled' |
| 970 |
|
| 971 |
@property |
| 972 |
def late_binding(self): |
| 973 |
if self._values['late_binding'] == 'yes': |
| 974 |
return 'enabled' |
| 975 |
elif self._values['late_binding'] == 'no': |
| 976 |
return 'disabled' |
| 977 |
|
| 978 |
@property |
| 979 |
def loose_close(self): |
| 980 |
if self._values['loose_close'] == 'yes': |
| 981 |
return 'enabled' |
| 982 |
elif self._values['loose_close'] == 'no': |
| 983 |
return 'disabled' |
| 984 |
|
| 985 |
@property |
| 986 |
def loose_initialization(self): |
| 987 |
if self._values['loose_initialization'] == 'yes': |
| 988 |
return 'enabled' |
| 989 |
elif self._values['loose_initialization'] == 'no': |
| 990 |
return 'disabled' |
| 991 |
|
| 992 |
@property |
| 993 |
def reassemble_fragments(self): |
| 994 |
if self._values['reassemble_fragments'] == 'yes': |
| 995 |
return 'enabled' |
| 996 |
elif self._values['reassemble_fragments'] == 'no': |
| 997 |
return 'disabled' |
| 998 |
|
| 999 |
@property |
| 1000 |
def reset_on_timeout(self): |
| 1001 |
if self._values['reset_on_timeout'] == 'yes': |
| 1002 |
return 'enabled' |
| 1003 |
elif self._values['reset_on_timeout'] == 'no': |
| 1004 |
return 'disabled' |
| 1005 |
|
| 1006 |
@property |
| 1007 |
def rtt_from_client(self): |
| 1008 |
if self._values['rtt_from_client'] == 'yes': |
| 1009 |
return 'enabled' |
| 1010 |
elif self._values['rtt_from_client'] == 'no': |
| 1011 |
return 'disabled' |
| 1012 |
|
| 1013 |
@property |
| 1014 |
def rtt_from_server(self): |
| 1015 |
if self._values['rtt_from_server'] == 'yes': |
| 1016 |
return 'enabled' |
| 1017 |
elif self._values['rtt_from_server'] == 'no': |
| 1018 |
return 'disabled' |
| 1019 |
|
| 1020 |
@property |
| 1021 |
def server_sack(self): |
| 1022 |
if self._values['server_sack'] == 'yes': |
| 1023 |
return 'enabled' |
| 1024 |
elif self._values['server_sack'] == 'no': |
| 1025 |
return 'disabled' |
| 1026 |
|
| 1027 |
@property |
| 1028 |
def server_timestamp(self): |
| 1029 |
if self._values['server_timestamp'] == 'yes': |
| 1030 |
return 'enabled' |
| 1031 |
elif self._values['server_timestamp'] == 'no': |
| 1032 |
return 'disabled' |
| 1033 |
|
| 1034 |
@property |
| 1035 |
def tcp_generate_isn(self): |
| 1036 |
if self._values['tcp_generate_isn'] == 'yes': |
| 1037 |
return 'enabled' |
| 1038 |
elif self._values['tcp_generate_isn'] == 'no': |
| 1039 |
return 'disabled' |
| 1040 |
|
| 1041 |
@property |
| 1042 |
def tcp_strip_sack(self): |
| 1043 |
if self._values['tcp_strip_sack'] == 'yes': |
| 1044 |
return 'enabled' |
| 1045 |
elif self._values['tcp_strip_sack'] == 'no': |
| 1046 |
return 'disabled' |
| 1047 |
|
| 1048 |
|
| 1049 |
class ReportableChanges(Changes): |
| 1050 |
@property |
| 1051 |
def explicit_flow_migration(self): |
| 1052 |
result = flatten_boolean(self._values['explicit_flow_migration']) |
| 1053 |
return result |
| 1054 |
|
| 1055 |
@property |
| 1056 |
def late_binding(self): |
| 1057 |
result = flatten_boolean(self._values['late_binding']) |
| 1058 |
return result |
| 1059 |
|
| 1060 |
@property |
| 1061 |
def loose_close(self): |
| 1062 |
result = flatten_boolean(self._values['loose_close']) |
| 1063 |
return result |
| 1064 |
|
| 1065 |
@property |
| 1066 |
def loose_initialization(self): |
| 1067 |
result = flatten_boolean(self._values['loose_initialization']) |
| 1068 |
return result |
| 1069 |
|
| 1070 |
@property |
| 1071 |
def reassemble_fragments(self): |
| 1072 |
result = flatten_boolean(self._values['reassemble_fragments']) |
| 1073 |
return result |
| 1074 |
|
| 1075 |
@property |
| 1076 |
def reset_on_timeout(self): |
| 1077 |
result = flatten_boolean(self._values['reset_on_timeout']) |
| 1078 |
return result |
| 1079 |
|
| 1080 |
@property |
| 1081 |
def rtt_from_client(self): |
| 1082 |
result = flatten_boolean(self._values['rtt_from_client']) |
| 1083 |
return result |
| 1084 |
|
| 1085 |
@property |
| 1086 |
def rtt_from_server(self): |
| 1087 |
result = flatten_boolean(self._values['rtt_from_server']) |
| 1088 |
return result |
| 1089 |
|
| 1090 |
@property |
| 1091 |
def server_sack(self): |
| 1092 |
result = flatten_boolean(self._values['server_sack']) |
| 1093 |
return result |
| 1094 |
|
| 1095 |
@property |
| 1096 |
def server_timestamp(self): |
| 1097 |
result = flatten_boolean(self._values['server_timestamp']) |
| 1098 |
return result |
| 1099 |
|
| 1100 |
@property |
| 1101 |
def tcp_generate_isn(self): |
| 1102 |
result = flatten_boolean(self._values['tcp_generate_isn']) |
| 1103 |
return result |
| 1104 |
|
| 1105 |
@property |
| 1106 |
def tcp_strip_sack(self): |
| 1107 |
result = flatten_boolean(self._values['tcp_strip_sack']) |
| 1108 |
return result |
| 1109 |
|
| 1110 |
@property |
| 1111 |
def ip_tos_to_client(self): |
| 1112 |
return self.report_ip_tos('ip_tos_to_client') |
| 1113 |
|
| 1114 |
@property |
| 1115 |
def ip_tos_to_server(self): |
| 1116 |
return self.report_ip_tos('ip_tos_to_server') |
| 1117 |
|
| 1118 |
@property |
| 1119 |
def keep_alive_interval(self): |
| 1120 |
if self._values['keep_alive_interval'] is None: |
| 1121 |
return None |
| 1122 |
if self._values['keep_alive_interval'] == 'disabled': |
| 1123 |
return 0 |
| 1124 |
return self._values['keep_alive_interval'] |
| 1125 |
|
| 1126 |
@property |
| 1127 |
def client_timeout(self): |
| 1128 |
if self._values['client_timeout'] is None: |
| 1129 |
return None |
| 1130 |
try: |
| 1131 |
return int(self._values['client_timeout']) |
| 1132 |
except ValueError: |
| 1133 |
if self._values['client_timeout'] == 0: |
| 1134 |
return 'immediate' |
| 1135 |
if self._values['client_timeout'] == 4294967295: |
| 1136 |
return 'indefinite' |
| 1137 |
return self._values['client_timeout'] |
| 1138 |
|
| 1139 |
def report_ip_tos(self, key): |
| 1140 |
if self._values[key] is None: |
| 1141 |
return None |
| 1142 |
if self._values[key] == 65534: |
| 1143 |
return 'mimic' |
| 1144 |
try: |
| 1145 |
return int(self._values[key]) |
| 1146 |
except ValueError: |
| 1147 |
return self._values[key] |
| 1148 |
|
| 1149 |
|
| 1150 |
class Difference(object): |
| 1151 |
def __init__(self, want, have=None): |
| 1152 |
self.want = want |
| 1153 |
self.have = have |
| 1154 |
|
| 1155 |
def compare(self, param): |
| 1156 |
try: |
| 1157 |
result = getattr(self, param) |
| 1158 |
return result |
| 1159 |
except AttributeError: |
| 1160 |
return self.__default(param) |
| 1161 |
|
| 1162 |
def __default(self, param): |
| 1163 |
attr1 = getattr(self.want, param) |
| 1164 |
try: |
| 1165 |
attr2 = getattr(self.have, param) |
| 1166 |
if attr1 != attr2: |
| 1167 |
return attr1 |
| 1168 |
except AttributeError: |
| 1169 |
return attr1 |
| 1170 |
|
| 1171 |
@property |
| 1172 |
def description(self): |
| 1173 |
if self.want.description is None: |
| 1174 |
return None |
| 1175 |
if self.have.description is None and self.want.description == '': |
| 1176 |
return None |
| 1177 |
if self.want.description != self.have.description: |
| 1178 |
return self.want.description |
| 1179 |
|
| 1180 |
|
| 1181 |
class ModuleManager(object): |
| 1182 |
def __init__(self, *args, **kwargs): |
| 1183 |
self.module = kwargs.get('module', None) |
| 1184 |
self.client = F5RestClient(**self.module.params) |
| 1185 |
self.want = ModuleParameters(params=self.module.params) |
| 1186 |
self.have = ApiParameters() |
| 1187 |
self.changes = UsableChanges() |
| 1188 |
|
| 1189 |
def _set_changed_options(self): |
| 1190 |
changed = {} |
| 1191 |
for key in Parameters.returnables: |
| 1192 |
if getattr(self.want, key) is not None: |
| 1193 |
changed[key] = getattr(self.want, key) |
| 1194 |
if changed: |
| 1195 |
self.changes = UsableChanges(params=changed) |
| 1196 |
|
| 1197 |
def _update_changed_options(self): |
| 1198 |
diff = Difference(self.want, self.have) |
| 1199 |
updatables = Parameters.updatables |
| 1200 |
changed = dict() |
| 1201 |
for k in updatables: |
| 1202 |
change = diff.compare(k) |
| 1203 |
if change is None: |
| 1204 |
continue |
| 1205 |
else: |
| 1206 |
if isinstance(change, dict): |
| 1207 |
changed.update(change) |
| 1208 |
else: |
| 1209 |
changed[k] = change |
| 1210 |
if changed: |
| 1211 |
self.changes = UsableChanges(params=changed) |
| 1212 |
return True |
| 1213 |
return False |
| 1214 |
|
| 1215 |
def should_update(self): |
| 1216 |
result = self._update_changed_options() |
| 1217 |
if result: |
| 1218 |
return True |
| 1219 |
return False |
| 1220 |
|
| 1221 |
def exec_module(self): |
| 1222 |
start = datetime.now().isoformat() |
| 1223 |
version = tmos_version(self.client) |
| 1224 |
changed = False |
| 1225 |
result = dict() |
| 1226 |
state = self.want.state |
| 1227 |
|
| 1228 |
if state == "present": |
| 1229 |
changed = self.present() |
| 1230 |
elif state == "absent": |
| 1231 |
changed = self.absent() |
| 1232 |
|
| 1233 |
reportable = ReportableChanges(params=self.changes.to_return()) |
| 1234 |
changes = reportable.to_return() |
| 1235 |
result.update(**changes) |
| 1236 |
result.update(dict(changed=changed)) |
| 1237 |
self._announce_deprecations(result) |
| 1238 |
send_teem(start, self.client, self.module, version) |
| 1239 |
return result |
| 1240 |
|
| 1241 |
def _announce_deprecations(self, result): |
| 1242 |
warnings = result.pop('__warnings', []) |
| 1243 |
for warning in warnings: |
| 1244 |
self.client.module.deprecate( |
| 1245 |
msg=warning['msg'], |
| 1246 |
version=warning['version'] |
| 1247 |
) |
| 1248 |
|
| 1249 |
def present(self): |
| 1250 |
if self.exists(): |
| 1251 |
return self.update() |
| 1252 |
else: |
| 1253 |
return self.create() |
| 1254 |
|
| 1255 |
def exists(self): |
| 1256 |
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/fastl4/{2}".format( |
| 1257 |
self.client.provider['server'], |
| 1258 |
self.client.provider['server_port'], |
| 1259 |
transform_name(self.want.partition, self.want.name) |
| 1260 |
) |
| 1261 |
resp = self.client.api.get(uri) |
| 1262 |
try: |
| 1263 |
response = resp.json() |
| 1264 |
except ValueError as ex: |
| 1265 |
raise F5ModuleError(str(ex)) |
| 1266 |
|
| 1267 |
if resp.status == 404 or 'code' in response and response['code'] == 404: |
| 1268 |
return False |
| 1269 |
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: |
| 1270 |
return True |
| 1271 |
|
| 1272 |
errors = [401, 403, 409, 500, 501, 502, 503, 504] |
| 1273 |
|
| 1274 |
if resp.status in errors or 'code' in response and response['code'] in errors: |
| 1275 |
if 'message' in response: |
| 1276 |
raise F5ModuleError(response['message']) |
| 1277 |
else: |
| 1278 |
raise F5ModuleError(resp.content) |
| 1279 |
|
| 1280 |
def update(self): |
| 1281 |
self.have = self.read_current_from_device() |
| 1282 |
if not self.should_update(): |
| 1283 |
return False |
| 1284 |
if self.module.check_mode: |
| 1285 |
return True |
| 1286 |
self.update_on_device() |
| 1287 |
return True |
| 1288 |
|
| 1289 |
def remove(self): |
| 1290 |
if self.module.check_mode: |
| 1291 |
return True |
| 1292 |
self.remove_from_device() |
| 1293 |
if self.exists(): |
| 1294 |
raise F5ModuleError("Failed to delete the resource.") |
| 1295 |
return True |
| 1296 |
|
| 1297 |
def create(self): |
| 1298 |
self._set_changed_options() |
| 1299 |
if self.module.check_mode: |
| 1300 |
return True |
| 1301 |
self.create_on_device() |
| 1302 |
return True |
| 1303 |
|
| 1304 |
def create_on_device(self): |
| 1305 |
params = self.changes.api_params() |
| 1306 |
params['name'] = self.want.name |
| 1307 |
params['partition'] = self.want.partition |
| 1308 |
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/fastl4/".format( |
| 1309 |
self.client.provider['server'], |
| 1310 |
self.client.provider['server_port'] |
| 1311 |
) |
| 1312 |
resp = self.client.api.post(uri, json=params) |
| 1313 |
try: |
| 1314 |
response = resp.json() |
| 1315 |
except ValueError as ex: |
| 1316 |
raise F5ModuleError(str(ex)) |
| 1317 |
|
| 1318 |
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: |
| 1319 |
return True |
| 1320 |
raise F5ModuleError(resp.content) |
| 1321 |
|
| 1322 |
def update_on_device(self): |
| 1323 |
params = self.changes.api_params() |
| 1324 |
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/fastl4/{2}".format( |
| 1325 |
self.client.provider['server'], |
| 1326 |
self.client.provider['server_port'], |
| 1327 |
transform_name(self.want.partition, self.want.name) |
| 1328 |
) |
| 1329 |
resp = self.client.api.patch(uri, json=params) |
| 1330 |
try: |
| 1331 |
response = resp.json() |
| 1332 |
except ValueError as ex: |
| 1333 |
raise F5ModuleError(str(ex)) |
| 1334 |
|
| 1335 |
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: |
| 1336 |
return True |
| 1337 |
raise F5ModuleError(resp.content) |
| 1338 |
|
| 1339 |
def absent(self): |
| 1340 |
if self.exists(): |
| 1341 |
return self.remove() |
| 1342 |
return False |
| 1343 |
|
| 1344 |
def remove_from_device(self): |
| 1345 |
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/fastl4/{2}".format( |
| 1346 |
self.client.provider['server'], |
| 1347 |
self.client.provider['server_port'], |
| 1348 |
transform_name(self.want.partition, self.want.name) |
| 1349 |
) |
| 1350 |
response = self.client.api.delete(uri) |
| 1351 |
if response.status == 200: |
| 1352 |
return True |
| 1353 |
raise F5ModuleError(response.content) |
| 1354 |
|
| 1355 |
def read_current_from_device(self): |
| 1356 |
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/fastl4/{2}".format( |
| 1357 |
self.client.provider['server'], |
| 1358 |
self.client.provider['server_port'], |
| 1359 |
transform_name(self.want.partition, self.want.name) |
| 1360 |
) |
| 1361 |
resp = self.client.api.get(uri) |
| 1362 |
try: |
| 1363 |
response = resp.json() |
| 1364 |
except ValueError as ex: |
| 1365 |
raise F5ModuleError(str(ex)) |
| 1366 |
|
| 1367 |
if resp.status in [200, 201] or 'code' in response and response['code'] in [200, 201]: |
| 1368 |
return ApiParameters(params=response) |
| 1369 |
raise F5ModuleError(resp.content) |
| 1370 |
|
| 1371 |
|
| 1372 |
class ArgumentSpec(object): |
| 1373 |
def __init__(self): |
| 1374 |
self.supports_check_mode = True |
| 1375 |
argument_spec = dict( |
| 1376 |
name=dict(required=True), |
| 1377 |
parent=dict(), |
| 1378 |
idle_timeout=dict(), |
| 1379 |
client_timeout=dict(), |
| 1380 |
description=dict(), |
| 1381 |
explicit_flow_migration=dict(type='bool'), |
| 1382 |
ip_df_mode=dict( |
| 1383 |
choices=['pmtu', 'preserve', 'set', 'clear'] |
| 1384 |
), |
| 1385 |
ip_tos_to_client=dict(), |
| 1386 |
ip_tos_to_server=dict(), |
| 1387 |
ip_ttl_v4=dict(type='int'), |
| 1388 |
ip_ttl_v6=dict(type='int'), |
| 1389 |
ip_ttl_mode=dict( |
| 1390 |
choices=['proxy', 'set', 'preserve', 'decrement'] |
| 1391 |
), |
| 1392 |
keep_alive_interval=dict(type='int'), |
| 1393 |
late_binding=dict(type='bool'), |
| 1394 |
link_qos_to_client=dict(), |
| 1395 |
link_qos_to_server=dict(), |
| 1396 |
loose_close=dict(type='bool'), |
| 1397 |
loose_initialization=dict(type='bool'), |
| 1398 |
mss_override=dict(type='int'), |
| 1399 |
reassemble_fragments=dict(type='bool'), |
| 1400 |
receive_window_size=dict(type='int'), |
| 1401 |
reset_on_timeout=dict(type='bool'), |
| 1402 |
rtt_from_client=dict(type='bool'), |
| 1403 |
rtt_from_server=dict(type='bool'), |
| 1404 |
server_sack=dict(type='bool'), |
| 1405 |
server_timestamp=dict(type='bool'), |
| 1406 |
syn_cookie_mss=dict(type='int'), |
| 1407 |
tcp_close_timeout=dict(), |
| 1408 |
tcp_generate_isn=dict(type='bool'), |
| 1409 |
tcp_handshake_timeout=dict(), |
| 1410 |
tcp_strip_sack=dict(type='bool'), |
| 1411 |
tcp_time_wait_timeout=dict(type='int'), |
| 1412 |
tcp_timestamp_mode=dict( |
| 1413 |
choices=['preserve', 'rewrite', 'strip'] |
| 1414 |
), |
| 1415 |
tcp_wscale_mode=dict( |
| 1416 |
choices=['preserve', 'rewrite', 'strip'] |
| 1417 |
), |
| 1418 |
timeout_recovery=dict( |
| 1419 |
choices=['fallback', 'disconnect'] |
| 1420 |
), |
| 1421 |
hardware_syn_cookie=dict(type='bool'), |
| 1422 |
syn_cookie_enable=dict(type='bool'), |
| 1423 |
pva_acceleration=dict( |
| 1424 |
choices=['full', 'dedicated', 'partial', 'none'] |
| 1425 |
), |
| 1426 |
state=dict( |
| 1427 |
default='present', |
| 1428 |
choices=['present', 'absent'] |
| 1429 |
), |
| 1430 |
partition=dict( |
| 1431 |
default='Common', |
| 1432 |
fallback=(env_fallback, ['F5_PARTITION']) |
| 1433 |
) |
| 1434 |
) |
| 1435 |
self.argument_spec = {} |
| 1436 |
self.argument_spec.update(f5_argument_spec) |
| 1437 |
self.argument_spec.update(argument_spec) |
| 1438 |
|
| 1439 |
|
| 1440 |
def main(): |
| 1441 |
spec = ArgumentSpec() |
| 1442 |
|
| 1443 |
module = AnsibleModule( |
| 1444 |
argument_spec=spec.argument_spec, |
| 1445 |
supports_check_mode=spec.supports_check_mode, |
| 1446 |
) |
| 1447 |
|
| 1448 |
try: |
| 1449 |
mm = ModuleManager(module=module) |
| 1450 |
results = mm.exec_module() |
| 1451 |
module.exit_json(**results) |
| 1452 |
except F5ModuleError as ex: |
| 1453 |
module.fail_json(msg=str(ex)) |
| 1454 |
|
| 1455 |
|
| 1456 |
if __name__ == '__main__': |
| 1457 |
main() |