| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
""" Ansible module for managing Protection Domain on Dell Technologies (Dell) PowerFlex""" |
| 7 |
from __future__ import (absolute_import, division, print_function) |
| 8 |
|
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
DOCUMENTATION = r''' |
| 12 |
module: protection_domain |
| 13 |
version_added: '1.2.0' |
| 14 |
short_description: Manage Protection Domain on Dell PowerFlex |
| 15 |
description: |
| 16 |
- Managing Protection Domain on PowerFlex storage system includes creating, |
| 17 |
modifying attributes, deleting and getting details of Protection Domain. |
| 18 |
author: |
| 19 |
- Bhavneet Sharma (@sharmb5) <[email protected]> |
| 20 |
extends_documentation_fragment: |
| 21 |
- dellemc.powerflex.powerflex |
| 22 |
options: |
| 23 |
protection_domain_name: |
| 24 |
description: |
| 25 |
- The name of the protection domain. |
| 26 |
- Mandatory for create operation. |
| 27 |
- It is unique across the PowerFlex array. |
| 28 |
- Mutually exclusive with I(protection_domain_id). |
| 29 |
type: str |
| 30 |
protection_domain_id: |
| 31 |
description: |
| 32 |
- The ID of the protection domain. |
| 33 |
- Except for create operation, all other operations can be performed |
| 34 |
using protection_domain_id. |
| 35 |
- Mutually exclusive with I(protection_domain_name). |
| 36 |
type: str |
| 37 |
protection_domain_new_name: |
| 38 |
description: |
| 39 |
- Used to rename the protection domain. |
| 40 |
type: str |
| 41 |
is_active: |
| 42 |
description: |
| 43 |
- Used to activate or deactivate the protection domain. |
| 44 |
type: bool |
| 45 |
network_limits: |
| 46 |
description: |
| 47 |
- Network bandwidth limit used by all SDS in protection domain. |
| 48 |
type: dict |
| 49 |
suboptions: |
| 50 |
rebuild_limit: |
| 51 |
description: |
| 52 |
- Limit the network bandwidth for rebuild. |
| 53 |
type: int |
| 54 |
rebalance_limit: |
| 55 |
description: |
| 56 |
- Limit the network bandwidth for rebalance. |
| 57 |
type: int |
| 58 |
vtree_migration_limit: |
| 59 |
description: |
| 60 |
- Limit the network bandwidth for vtree migration. |
| 61 |
type: int |
| 62 |
overall_limit: |
| 63 |
description: |
| 64 |
- Limit the overall network bandwidth. |
| 65 |
type: int |
| 66 |
bandwidth_unit: |
| 67 |
description: |
| 68 |
- Unit for network bandwidth limits. |
| 69 |
type: str |
| 70 |
choices: ['KBps', 'MBps', 'GBps'] |
| 71 |
default: 'KBps' |
| 72 |
rf_cache_limits: |
| 73 |
description: |
| 74 |
- Used to set the RFcache parameters of the protection domain. |
| 75 |
type: dict |
| 76 |
suboptions: |
| 77 |
is_enabled: |
| 78 |
description: |
| 79 |
- Used to enable or disable RFcache in the protection domain. |
| 80 |
type: bool |
| 81 |
page_size: |
| 82 |
description: |
| 83 |
- Used to set the cache page size in KB. |
| 84 |
type: int |
| 85 |
max_io_limit: |
| 86 |
description: |
| 87 |
- Used to set cache maximum I/O limit in KB. |
| 88 |
type: int |
| 89 |
pass_through_mode: |
| 90 |
description: |
| 91 |
- Used to set the cache mode. |
| 92 |
choices: ['None', 'Read', 'Write', 'ReadAndWrite', 'WriteMiss'] |
| 93 |
type: str |
| 94 |
state: |
| 95 |
description: |
| 96 |
- State of the protection domain. |
| 97 |
required: true |
| 98 |
type: str |
| 99 |
choices: ['present', 'absent'] |
| 100 |
notes: |
| 101 |
- The protection domain can only be deleted if all its related objects have |
| 102 |
been dissociated from the protection domain. |
| 103 |
- If the protection domain set to inactive, then no operation can be |
| 104 |
performed on protection domain. |
| 105 |
- The I(check_mode) is not supported. |
| 106 |
''' |
| 107 |
|
| 108 |
EXAMPLES = r''' |
| 109 |
- name: Create protection domain |
| 110 |
dellemc.powerflex.protection_domain: |
| 111 |
hostname: "{{hostname}}" |
| 112 |
username: "{{username}}" |
| 113 |
password: "{{password}}" |
| 114 |
validate_certs: "{{validate_certs}}" |
| 115 |
port: "{{port}}" |
| 116 |
protection_domain_name: "domain1" |
| 117 |
state: "present" |
| 118 |
|
| 119 |
- name: Create protection domain with all parameters |
| 120 |
dellemc.powerflex.protection_domain: |
| 121 |
hostname: "{{hostname}}" |
| 122 |
username: "{{username}}" |
| 123 |
password: "{{password}}" |
| 124 |
validate_certs: "{{validate_certs}}" |
| 125 |
port: "{{port}}" |
| 126 |
protection_domain_name: "domain1" |
| 127 |
is_active: true |
| 128 |
network_limits: |
| 129 |
rebuild_limit: 10 |
| 130 |
rebalance_limit: 17 |
| 131 |
vtree_migration_limit: 14 |
| 132 |
overall_limit: 20 |
| 133 |
bandwidth_unit: "MBps" |
| 134 |
rf_cache_limits: |
| 135 |
is_enabled: true |
| 136 |
page_size: 16 |
| 137 |
max_io_limit: 128 |
| 138 |
pass_through_mode: "Read" |
| 139 |
state: "present" |
| 140 |
|
| 141 |
- name: Get protection domain details using name |
| 142 |
dellemc.powerflex.protection_domain: |
| 143 |
hostname: "{{hostname}}" |
| 144 |
username: "{{username}}" |
| 145 |
password: "{{password}}" |
| 146 |
validate_certs: "{{validate_certs}}" |
| 147 |
port: "{{port}}" |
| 148 |
protection_domain_name: "domain1" |
| 149 |
state: "present" |
| 150 |
|
| 151 |
- name: Get protection domain details using ID |
| 152 |
dellemc.powerflex.protection_domain: |
| 153 |
hostname: "{{hostname}}" |
| 154 |
username: "{{username}}" |
| 155 |
password: "{{password}}" |
| 156 |
validate_certs: "{{validate_certs}}" |
| 157 |
port: "{{port}}" |
| 158 |
protection_domain_id: "5718253c00000004" |
| 159 |
state: "present" |
| 160 |
|
| 161 |
- name: Modify protection domain attributes |
| 162 |
dellemc.powerflex.protection_domain: |
| 163 |
hostname: "{{hostname}}" |
| 164 |
username: "{{username}}" |
| 165 |
password: "{{password}}" |
| 166 |
validate_certs: "{{validate_certs}}" |
| 167 |
port: "{{port}}" |
| 168 |
protection_domain_name: "domain1" |
| 169 |
protection_domain_new_name: "domain1_new" |
| 170 |
network_limits: |
| 171 |
rebuild_limit: 14 |
| 172 |
rebalance_limit: 20 |
| 173 |
overall_limit: 25 |
| 174 |
bandwidth_unit: "MBps" |
| 175 |
rf_cache_limits: |
| 176 |
page_size: 64 |
| 177 |
pass_through_mode: "WriteMiss" |
| 178 |
state: "present" |
| 179 |
|
| 180 |
- name: Delete protection domain using name |
| 181 |
dellemc.powerflex.protection_domain: |
| 182 |
hostname: "{{hostname}}" |
| 183 |
username: "{{username}}" |
| 184 |
password: "{{password}}" |
| 185 |
validate_certs: "{{validate_certs}}" |
| 186 |
port: "{{port}}" |
| 187 |
protection_domain_name: "domain1_new" |
| 188 |
state: "absent" |
| 189 |
''' |
| 190 |
|
| 191 |
RETURN = r''' |
| 192 |
changed: |
| 193 |
description: Whether or not the resource has changed. |
| 194 |
returned: always |
| 195 |
type: bool |
| 196 |
sample: 'false' |
| 197 |
protection_domain_details: |
| 198 |
description: Details of the protection domain. |
| 199 |
returned: When protection domain exists |
| 200 |
type: dict |
| 201 |
contains: |
| 202 |
fglDefaultMetadataCacheSize: |
| 203 |
description: FGL metadata cache size. |
| 204 |
type: int |
| 205 |
fglDefaultNumConcurrentWrites: |
| 206 |
description: FGL concurrent writes. |
| 207 |
type: str |
| 208 |
fglMetadataCacheEnabled: |
| 209 |
description: Whether FGL cache enabled. |
| 210 |
type: bool |
| 211 |
id: |
| 212 |
description: Protection domain ID. |
| 213 |
type: str |
| 214 |
links: |
| 215 |
description: Protection domain links. |
| 216 |
type: list |
| 217 |
contains: |
| 218 |
href: |
| 219 |
description: Protection domain instance URL. |
| 220 |
type: str |
| 221 |
rel: |
| 222 |
description: Protection domain's relationship with |
| 223 |
different entities. |
| 224 |
type: str |
| 225 |
mdmSdsNetworkDisconnectionsCounterParameters: |
| 226 |
description: MDM's SDS counter parameter. |
| 227 |
type: dict |
| 228 |
contains: |
| 229 |
longWindow: |
| 230 |
description: Long window for Counter Parameters. |
| 231 |
type: int |
| 232 |
mediumWindow: |
| 233 |
description: Medium window for Counter Parameters. |
| 234 |
type: int |
| 235 |
shortWindow: |
| 236 |
description: Short window for Counter Parameters. |
| 237 |
type: int |
| 238 |
name: |
| 239 |
description: Name of the protection domain. |
| 240 |
type: str |
| 241 |
overallIoNetworkThrottlingEnabled: |
| 242 |
description: Whether overall network throttling enabled. |
| 243 |
type: bool |
| 244 |
overallIoNetworkThrottlingInKbps: |
| 245 |
description: Overall network throttling in KBps. |
| 246 |
type: int |
| 247 |
protectedMaintenanceModeNetworkThrottlingEnabled: |
| 248 |
description: Whether protected maintenance mode network throttling |
| 249 |
enabled. |
| 250 |
type: bool |
| 251 |
protectedMaintenanceModeNetworkThrottlingInKbps: |
| 252 |
description: Protected maintenance mode network throttling in |
| 253 |
KBps. |
| 254 |
type: int |
| 255 |
protectionDomainState: |
| 256 |
description: State of protection domain. |
| 257 |
type: int |
| 258 |
rebalanceNetworkThrottlingEnabled: |
| 259 |
description: Whether rebalance network throttling enabled. |
| 260 |
type: int |
| 261 |
rebalanceNetworkThrottlingInKbps: |
| 262 |
description: Rebalance network throttling in KBps. |
| 263 |
type: int |
| 264 |
rebuildNetworkThrottlingEnabled: |
| 265 |
description: Whether rebuild network throttling enabled. |
| 266 |
type: int |
| 267 |
rebuildNetworkThrottlingInKbps: |
| 268 |
description: Rebuild network throttling in KBps. |
| 269 |
type: int |
| 270 |
rfcacheAccpId: |
| 271 |
description: Id of RF cache acceleration pool. |
| 272 |
type: str |
| 273 |
rfcacheEnabled: |
| 274 |
description: Whether RF cache is enabled or not. |
| 275 |
type: bool |
| 276 |
rfcacheMaxIoSizeKb: |
| 277 |
description: RF cache maximum I/O size in KB. |
| 278 |
type: int |
| 279 |
rfcacheOpertionalMode: |
| 280 |
description: RF cache operational mode. |
| 281 |
type: str |
| 282 |
rfcachePageSizeKb: |
| 283 |
description: RF cache page size in KB. |
| 284 |
type: bool |
| 285 |
sdrSdsConnectivityInfo: |
| 286 |
description: Connectivity info of SDR and SDS. |
| 287 |
type: dict |
| 288 |
contains: |
| 289 |
clientServerConnStatus: |
| 290 |
description: Connectivity status of client and server. |
| 291 |
type: str |
| 292 |
disconnectedClientId: |
| 293 |
description: Disconnected client ID. |
| 294 |
type: str |
| 295 |
disconnectedClientName: |
| 296 |
description: Disconnected client name. |
| 297 |
type: str |
| 298 |
disconnectedServerId: |
| 299 |
description: Disconnected server ID. |
| 300 |
type: str |
| 301 |
disconnectedServerIp: |
| 302 |
description: Disconnected server IP. |
| 303 |
type: str |
| 304 |
disconnectedServerName: |
| 305 |
description: Disconnected server name. |
| 306 |
type: str |
| 307 |
sdsSdsNetworkDisconnectionsCounterParameters: |
| 308 |
description: Counter parameter for SDS-SDS network. |
| 309 |
type: dict |
| 310 |
contains: |
| 311 |
longWindow: |
| 312 |
description: Long window for Counter Parameters. |
| 313 |
type: int |
| 314 |
mediumWindow: |
| 315 |
description: Medium window for Counter Parameters. |
| 316 |
type: int |
| 317 |
shortWindow: |
| 318 |
description: Short window for Counter Parameters. |
| 319 |
type: int |
| 320 |
storagePool: |
| 321 |
description: List of storage pools. |
| 322 |
type: list |
| 323 |
systemId: |
| 324 |
description: ID of system. |
| 325 |
type: str |
| 326 |
vtreeMigrationNetworkThrottlingEnabled: |
| 327 |
description: Whether V-Tree migration network throttling enabled. |
| 328 |
type: bool |
| 329 |
vtreeMigrationNetworkThrottlingInKbps: |
| 330 |
description: V-Tree migration network throttling in KBps. |
| 331 |
type: int |
| 332 |
sample: { |
| 333 |
"fglDefaultMetadataCacheSize": 0, |
| 334 |
"fglDefaultNumConcurrentWrites": 1000, |
| 335 |
"fglMetadataCacheEnabled": false, |
| 336 |
"id": "7bd6457000000000", |
| 337 |
"links": [ |
| 338 |
{ |
| 339 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000", |
| 340 |
"rel": "self" |
| 341 |
}, |
| 342 |
{ |
| 343 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 344 |
relationships/Statistics", |
| 345 |
"rel": "/api/ProtectionDomain/relationship/Statistics" |
| 346 |
}, |
| 347 |
{ |
| 348 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 349 |
relationships/Sdr", |
| 350 |
"rel": "/api/ProtectionDomain/relationship/Sdr" |
| 351 |
}, |
| 352 |
{ |
| 353 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 354 |
relationships/AccelerationPool", |
| 355 |
"rel": "/api/ProtectionDomain/relationship/AccelerationPool" |
| 356 |
}, |
| 357 |
{ |
| 358 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 359 |
relationships/StoragePool", |
| 360 |
"rel": "/api/ProtectionDomain/relationship/StoragePool" |
| 361 |
}, |
| 362 |
{ |
| 363 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 364 |
relationships/Sds", |
| 365 |
"rel": "/api/ProtectionDomain/relationship/Sds" |
| 366 |
}, |
| 367 |
{ |
| 368 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 369 |
relationships/ReplicationConsistencyGroup", |
| 370 |
"rel": "/api/ProtectionDomain/relationship/ |
| 371 |
ReplicationConsistencyGroup" |
| 372 |
}, |
| 373 |
{ |
| 374 |
"href": "/api/instances/ProtectionDomain::7bd6457000000000/ |
| 375 |
relationships/FaultSet", |
| 376 |
"rel": "/api/ProtectionDomain/relationship/FaultSet" |
| 377 |
}, |
| 378 |
{ |
| 379 |
"href": "/api/instances/System::0989ce79058f150f", |
| 380 |
"rel": "/api/parent/relationship/systemId" |
| 381 |
} |
| 382 |
], |
| 383 |
"mdmSdsNetworkDisconnectionsCounterParameters": { |
| 384 |
"longWindow": { |
| 385 |
"threshold": 700, |
| 386 |
"windowSizeInSec": 86400 |
| 387 |
}, |
| 388 |
"mediumWindow": { |
| 389 |
"threshold": 500, |
| 390 |
"windowSizeInSec": 3600 |
| 391 |
}, |
| 392 |
"shortWindow": { |
| 393 |
"threshold": 300, |
| 394 |
"windowSizeInSec": 60 |
| 395 |
} |
| 396 |
}, |
| 397 |
"name": "domain1", |
| 398 |
"overallIoNetworkThrottlingEnabled": false, |
| 399 |
"overallIoNetworkThrottlingInKbps": null, |
| 400 |
"protectedMaintenanceModeNetworkThrottlingEnabled": false, |
| 401 |
"protectedMaintenanceModeNetworkThrottlingInKbps": null, |
| 402 |
"protectionDomainState": "Active", |
| 403 |
"rebalanceNetworkThrottlingEnabled": false, |
| 404 |
"rebalanceNetworkThrottlingInKbps": null, |
| 405 |
"rebuildNetworkThrottlingEnabled": false, |
| 406 |
"rebuildNetworkThrottlingInKbps": null, |
| 407 |
"rfcacheAccpId": null, |
| 408 |
"rfcacheEnabled": true, |
| 409 |
"rfcacheMaxIoSizeKb": 128, |
| 410 |
"rfcacheOpertionalMode": "WriteMiss", |
| 411 |
"rfcachePageSizeKb": 64, |
| 412 |
"sdrSdsConnectivityInfo": { |
| 413 |
"clientServerConnStatus": "CLIENT_SERVER_CONN_STATUS_ALL |
| 414 |
_CONNECTED", |
| 415 |
"disconnectedClientId": null, |
| 416 |
"disconnectedClientName": null, |
| 417 |
"disconnectedServerId": null, |
| 418 |
"disconnectedServerIp": null, |
| 419 |
"disconnectedServerName": null |
| 420 |
}, |
| 421 |
"sdsConfigurationFailureCounterParameters": { |
| 422 |
"longWindow": { |
| 423 |
"threshold": 700, |
| 424 |
"windowSizeInSec": 86400 |
| 425 |
}, |
| 426 |
"mediumWindow": { |
| 427 |
"threshold": 500, |
| 428 |
"windowSizeInSec": 3600 |
| 429 |
}, |
| 430 |
"shortWindow": { |
| 431 |
"threshold": 300, |
| 432 |
"windowSizeInSec": 60 |
| 433 |
} |
| 434 |
}, |
| 435 |
"sdsDecoupledCounterParameters": { |
| 436 |
"longWindow": { |
| 437 |
"threshold": 700, |
| 438 |
"windowSizeInSec": 86400 |
| 439 |
}, |
| 440 |
"mediumWindow": { |
| 441 |
"threshold": 500, |
| 442 |
"windowSizeInSec": 3600 |
| 443 |
}, |
| 444 |
"shortWindow": { |
| 445 |
"threshold": 300, |
| 446 |
"windowSizeInSec": 60 |
| 447 |
} |
| 448 |
}, |
| 449 |
"sdsReceiveBufferAllocationFailuresCounterParameters": { |
| 450 |
"longWindow": { |
| 451 |
"threshold": 2000000, |
| 452 |
"windowSizeInSec": 86400 |
| 453 |
}, |
| 454 |
"mediumWindow": { |
| 455 |
"threshold": 200000, |
| 456 |
"windowSizeInSec": 3600 |
| 457 |
}, |
| 458 |
"shortWindow": { |
| 459 |
"threshold": 20000, |
| 460 |
"windowSizeInSec": 60 |
| 461 |
} |
| 462 |
}, |
| 463 |
"sdsSdsNetworkDisconnectionsCounterParameters": { |
| 464 |
"longWindow": { |
| 465 |
"threshold": 700, |
| 466 |
"windowSizeInSec": 86400 |
| 467 |
}, |
| 468 |
"mediumWindow": { |
| 469 |
"threshold": 500, |
| 470 |
"windowSizeInSec": 3600 |
| 471 |
}, |
| 472 |
"shortWindow": { |
| 473 |
"threshold": 300, |
| 474 |
"windowSizeInSec": 60 |
| 475 |
} |
| 476 |
}, |
| 477 |
"storagePool": [ |
| 478 |
{ |
| 479 |
"id": "8d1cba1700000000", |
| 480 |
"name": "pool1" |
| 481 |
} |
| 482 |
], |
| 483 |
"systemId": "0989ce79058f150f", |
| 484 |
"vtreeMigrationNetworkThrottlingEnabled": false, |
| 485 |
"vtreeMigrationNetworkThrottlingInKbps": null |
| 486 |
} |
| 487 |
''' |
| 488 |
|
| 489 |
from ansible.module_utils.basic import AnsibleModule |
| 490 |
from ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell.libraries.powerflex_base \ |
| 491 |
import PowerFlexBase, powerflex_compatibility |
| 492 |
from ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell \ |
| 493 |
import utils |
| 494 |
|
| 495 |
LOG = utils.get_logger('protection_domain') |
| 496 |
|
| 497 |
|
| 498 |
@powerflex_compatibility(min_ver='3.6', max_ver='5.0', successor='protection_domain_v2') |
| 499 |
class PowerFlexProtectionDomain(PowerFlexBase): |
| 500 |
"""Class with protection domain operations""" |
| 501 |
|
| 502 |
def __init__(self): |
| 503 |
""" Define all parameters required by this module""" |
| 504 |
argument_spec = get_powerflex_protection_domain_parameters() |
| 505 |
mut_ex_args = [['protection_domain_name', 'protection_domain_id']] |
| 506 |
required_one_of_args = [['protection_domain_name', |
| 507 |
'protection_domain_id']] |
| 508 |
|
| 509 |
module_params = { |
| 510 |
'argument_spec': argument_spec, |
| 511 |
'supports_check_mode': False, |
| 512 |
'mutually_exclusive': mut_ex_args, |
| 513 |
'required_one_of': required_one_of_args, |
| 514 |
} |
| 515 |
|
| 516 |
super().__init__(AnsibleModule, module_params) |
| 517 |
super().check_module_compatibility() |
| 518 |
|
| 519 |
def validate_input_params(self): |
| 520 |
"""Validate the input parameters""" |
| 521 |
|
| 522 |
name_params = ['protection_domain_name', 'protection_domain_new_name', |
| 523 |
'protection_domain_id'] |
| 524 |
msg = "Please provide the valid {0}" |
| 525 |
|
| 526 |
for n_item in name_params: |
| 527 |
if self.module.params[n_item] is not None and (len( |
| 528 |
self.module.params[n_item].strip()) or self. |
| 529 |
module.params[n_item].count(" ") > 0) == 0: |
| 530 |
err_msg = msg.format(n_item) |
| 531 |
self.module.fail_json(msg=err_msg) |
| 532 |
|
| 533 |
if self.module.params['network_limits'] is not None: |
| 534 |
if self.module.params['network_limits']['overall_limit'] is not None and \ |
| 535 |
self.module.params['network_limits']['overall_limit'] < 0: |
| 536 |
error_msg = "Overall limit cannot be negative. " \ |
| 537 |
"Provide a valid value " |
| 538 |
LOG.info(error_msg) |
| 539 |
self.module.fail_json(msg=error_msg) |
| 540 |
|
| 541 |
def is_id_or_new_name_in_create(self): |
| 542 |
"""Checking if protection domain id or new names present in create """ |
| 543 |
|
| 544 |
if self.module.params['protection_domain_new_name'] or \ |
| 545 |
self.module.params['protection_domain_id']: |
| 546 |
error_msg = "protection_domain_new_name/protection_domain_id " \ |
| 547 |
"are not supported during creation of protection " \ |
| 548 |
"domain. Please try with protection_domain_name." |
| 549 |
LOG.info(error_msg) |
| 550 |
self.module.fail_json(msg=error_msg) |
| 551 |
|
| 552 |
def get_storage_pool(self, protection_domain_id): |
| 553 |
""" |
| 554 |
Get Storage pools details |
| 555 |
:param protection_domain_id: Name of the protection domain |
| 556 |
:type protection_domain_id: str |
| 557 |
:return: list containing storage pools which are present in |
| 558 |
protection domain |
| 559 |
""" |
| 560 |
|
| 561 |
try: |
| 562 |
sps_list = [] |
| 563 |
resp = self.powerflex_conn.protection_domain. \ |
| 564 |
get_storage_pools(protection_domain_id=protection_domain_id) |
| 565 |
for items in resp: |
| 566 |
sp_name_id = dict() |
| 567 |
sp_name_id['id'] = items['id'] |
| 568 |
sp_name_id['name'] = items['name'] |
| 569 |
sps_list.append(sp_name_id) |
| 570 |
return sps_list |
| 571 |
|
| 572 |
except Exception as e: |
| 573 |
errmsg = "Failed to get the storage pools present in protection" \ |
| 574 |
" domain %s with error %s" % ( |
| 575 |
protection_domain_id, str(e)) |
| 576 |
LOG.error(errmsg) |
| 577 |
self.module.fail_json(msg=errmsg) |
| 578 |
|
| 579 |
def get_protection_domain(self, protection_domain_name=None, |
| 580 |
protection_domain_id=None): |
| 581 |
""" |
| 582 |
Get protection domain details |
| 583 |
:param protection_domain_name: Name of the protection domain |
| 584 |
:param protection_domain_id: ID of the protection domain |
| 585 |
:return: Protection domain details if exists |
| 586 |
:rtype: dict |
| 587 |
""" |
| 588 |
|
| 589 |
name_or_id = protection_domain_id if protection_domain_id \ |
| 590 |
else protection_domain_name |
| 591 |
|
| 592 |
try: |
| 593 |
if protection_domain_id: |
| 594 |
pd_details = self.powerflex_conn.protection_domain.get( |
| 595 |
filter_fields={'id': protection_domain_id}) |
| 596 |
|
| 597 |
else: |
| 598 |
pd_details = self.powerflex_conn.protection_domain.get( |
| 599 |
filter_fields={'name': protection_domain_name}) |
| 600 |
|
| 601 |
if len(pd_details) == 0: |
| 602 |
error_msg = "Unable to find the protection domain with " \ |
| 603 |
"'%s'." % name_or_id |
| 604 |
LOG.info(error_msg) |
| 605 |
return None |
| 606 |
|
| 607 |
|
| 608 |
pd_details[0]['storagePool'] = self.get_storage_pool(pd_details |
| 609 |
[0]['id']) |
| 610 |
return pd_details[0] |
| 611 |
|
| 612 |
except Exception as e: |
| 613 |
error_msg = "Failed to get the protection domain '%s' with " \ |
| 614 |
"error '%s'" % (name_or_id, str(e)) |
| 615 |
LOG.error(error_msg) |
| 616 |
self.module.fail_json(msg=error_msg) |
| 617 |
|
| 618 |
def create_protection_domain(self, protection_domain_name): |
| 619 |
""" |
| 620 |
Create Protection Domain |
| 621 |
:param protection_domain_name: Name of the protection domain |
| 622 |
:type protection_domain_name: str |
| 623 |
:return: Boolean indicating if create operation is successful |
| 624 |
""" |
| 625 |
|
| 626 |
try: |
| 627 |
LOG.info("Creating protection domain with name: %s ", |
| 628 |
protection_domain_name) |
| 629 |
self.powerflex_conn.protection_domain. \ |
| 630 |
create(name=protection_domain_name) |
| 631 |
return True |
| 632 |
|
| 633 |
except Exception as e: |
| 634 |
error_msg = "Create protection domain '%s' operation failed" \ |
| 635 |
" with error '%s'" % (protection_domain_name, str(e)) |
| 636 |
LOG.error(error_msg) |
| 637 |
self.module.fail_json(msg=error_msg) |
| 638 |
|
| 639 |
def perform_create_operation(self, state, pd_details, |
| 640 |
protection_domain_name): |
| 641 |
"""performing creation of protection domain details""" |
| 642 |
|
| 643 |
if state == 'present' and not pd_details: |
| 644 |
self.is_id_or_new_name_in_create() |
| 645 |
create_change = self. \ |
| 646 |
create_protection_domain(protection_domain_name) |
| 647 |
if create_change: |
| 648 |
pd_details = self. \ |
| 649 |
get_protection_domain(protection_domain_name) |
| 650 |
msg = "Protection domain created successfully, fetched" \ |
| 651 |
" protection domain details {0}". \ |
| 652 |
format(str(pd_details)) |
| 653 |
LOG.info(msg) |
| 654 |
return create_change, pd_details |
| 655 |
|
| 656 |
return False, pd_details |
| 657 |
|
| 658 |
def is_modify_required(self, pd_details, network_limits, rf_cache_limits, |
| 659 |
protection_domain_new_name, is_active): |
| 660 |
"""Check if modification required""" |
| 661 |
|
| 662 |
if (self.module.params['state'] == 'present') and pd_details and \ |
| 663 |
(network_limits is not None or rf_cache_limits is not None |
| 664 |
or protection_domain_new_name is not None or is_active is |
| 665 |
not None): |
| 666 |
return True |
| 667 |
|
| 668 |
def modify_nw_limits(self, protection_domain_id, nw_modify_dict, |
| 669 |
create_flag=False): |
| 670 |
""" |
| 671 |
Modify Protection domain attributes |
| 672 |
:param protection_domain_id: ID of the protection domain |
| 673 |
:type protection_domain_id: str |
| 674 |
:param nw_modify_dict: Dictionary containing the attributes of |
| 675 |
protection domain which are to be updated |
| 676 |
:type nw_modify_dict: dict |
| 677 |
:param create_flag: Flag to indicate whether modify operation is |
| 678 |
followed by create operation or not |
| 679 |
:type create_flag: bool |
| 680 |
:return: Boolean indicating if the operation is successful |
| 681 |
""" |
| 682 |
try: |
| 683 |
msg = "Dict containing network modify params {0}". \ |
| 684 |
format(str(nw_modify_dict)) |
| 685 |
LOG.info(msg) |
| 686 |
if 'rebuild_limit' in nw_modify_dict or 'rebalance_limit' in \ |
| 687 |
nw_modify_dict or 'vtree_migration_limit' in \ |
| 688 |
nw_modify_dict or 'overall_limit' in nw_modify_dict: |
| 689 |
self.powerflex_conn.protection_domain.network_limits( |
| 690 |
protection_domain_id=protection_domain_id, |
| 691 |
rebuild_limit=nw_modify_dict['rebuild_limit'], |
| 692 |
rebalance_limit=nw_modify_dict['rebalance_limit'], |
| 693 |
vtree_migration_limit=nw_modify_dict['vtree_migration_limit'], |
| 694 |
overall_limit=nw_modify_dict['overall_limit']) |
| 695 |
msg = "The Network limits are updated to {0}, {1}, {2}, " \ |
| 696 |
"{3} successfully.". \ |
| 697 |
format(nw_modify_dict['rebuild_limit'], |
| 698 |
nw_modify_dict['rebalance_limit'], |
| 699 |
nw_modify_dict['vtree_migration_limit'], |
| 700 |
nw_modify_dict['overall_limit']) |
| 701 |
LOG.info(msg) |
| 702 |
return True |
| 703 |
|
| 704 |
except Exception as e: |
| 705 |
if create_flag: |
| 706 |
err_msg = "Create protection domain is successful," \ |
| 707 |
" but failed to update the network limits" \ |
| 708 |
" {0} with error {1}".format(protection_domain_id, |
| 709 |
str(e)) |
| 710 |
else: |
| 711 |
err_msg = "Failed to update the network limits of " \ |
| 712 |
"protection domain {0} with error {1}". \ |
| 713 |
format(protection_domain_id, str(e)) |
| 714 |
LOG.error(err_msg) |
| 715 |
self.module.fail_json(msg=err_msg) |
| 716 |
|
| 717 |
def modify_rf_limits(self, protection_domain_id, rf_modify_dict, |
| 718 |
create_flag): |
| 719 |
""" |
| 720 |
Modify Protection domain attributes |
| 721 |
:param protection_domain_id: ID of the protection domain |
| 722 |
:type protection_domain_id: str |
| 723 |
:param rf_modify_dict: Dict containing the attributes of rf cache |
| 724 |
which are to be updated |
| 725 |
:type rf_modify_dict: dict |
| 726 |
:param create_flag: Flag to indicate whether modify operation is |
| 727 |
followed by create operation or not |
| 728 |
:type create_flag: bool |
| 729 |
:return: Boolean indicating if the operation is successful |
| 730 |
""" |
| 731 |
try: |
| 732 |
msg = "Dict containing network modify params {0}". \ |
| 733 |
format(str(rf_modify_dict)) |
| 734 |
LOG.info(msg) |
| 735 |
|
| 736 |
if 'is_enabled' in rf_modify_dict and \ |
| 737 |
rf_modify_dict['is_enabled'] is not None: |
| 738 |
self.powerflex_conn.protection_domain.set_rfcache_enabled( |
| 739 |
protection_domain_id, rf_modify_dict['is_enabled']) |
| 740 |
msg = "The RFcache is enabled to '%s' successfully." \ |
| 741 |
% rf_modify_dict['is_enabled'] |
| 742 |
LOG.info(msg) |
| 743 |
|
| 744 |
if 'page_size' in rf_modify_dict or 'max_io_limit' in \ |
| 745 |
rf_modify_dict or 'pass_through_mode' in rf_modify_dict: |
| 746 |
self.powerflex_conn.protection_domain.rfcache_parameters( |
| 747 |
protection_domain_id=protection_domain_id, |
| 748 |
page_size=rf_modify_dict['page_size'], |
| 749 |
max_io_limit=rf_modify_dict['max_io_limit'], |
| 750 |
pass_through_mode=rf_modify_dict['pass_through_mode']) |
| 751 |
msg = "The RFcache parameters are updated to {0}, {1},{2}.'" \ |
| 752 |
.format(rf_modify_dict['page_size'], |
| 753 |
rf_modify_dict['max_io_limit'], |
| 754 |
rf_modify_dict['pass_through_mode']) |
| 755 |
LOG.info(msg) |
| 756 |
return True |
| 757 |
|
| 758 |
except Exception as e: |
| 759 |
if create_flag: |
| 760 |
err_msg = "Create protection domain is successful," \ |
| 761 |
" but failed to update the rf cache limits" \ |
| 762 |
" {0} with error {1}".format(protection_domain_id, |
| 763 |
str(e)) |
| 764 |
else: |
| 765 |
err_msg = "Failed to update the rf cache limits of " \ |
| 766 |
"protection domain {0} with error {1}". \ |
| 767 |
format(protection_domain_id, str(e)) |
| 768 |
LOG.error(err_msg) |
| 769 |
self.module.fail_json(msg=err_msg) |
| 770 |
|
| 771 |
def modify_pd_attributes(self, protection_domain_id, modify_dict, |
| 772 |
create_flag=False): |
| 773 |
""" |
| 774 |
Modify Protection domain attributes |
| 775 |
:param protection_domain_id: ID of the protection domain |
| 776 |
:type protection_domain_id: str |
| 777 |
:param modify_dict: Dictionary containing the attributes of |
| 778 |
protection domain which are to be updated |
| 779 |
:type modify_dict: dict |
| 780 |
:param create_flag: Flag to indicate whether modify operation is |
| 781 |
followed by create operation or not |
| 782 |
:type create_flag: bool |
| 783 |
:return: Boolean indicating if the operation is successful |
| 784 |
""" |
| 785 |
try: |
| 786 |
msg = "Dictionary containing attributes which need to be" \ |
| 787 |
" updated are '%s'." % (str(modify_dict)) |
| 788 |
LOG.info(msg) |
| 789 |
|
| 790 |
if 'protection_domain_new_name' in modify_dict: |
| 791 |
self.powerflex_conn.protection_domain. \ |
| 792 |
rename(protection_domain_id, |
| 793 |
modify_dict['protection_domain_new_name']) |
| 794 |
msg = "The name of the protection domain is updated to " \ |
| 795 |
"'%s' successfully." % \ |
| 796 |
modify_dict['protection_domain_new_name'] |
| 797 |
LOG.info(msg) |
| 798 |
|
| 799 |
if 'is_active' in modify_dict and modify_dict['is_active']: |
| 800 |
self.powerflex_conn.protection_domain. \ |
| 801 |
activate(protection_domain_id, modify_dict['is_active']) |
| 802 |
msg = "The protection domain is activated successfully, by " \ |
| 803 |
"setting as is_active: '%s' " % \ |
| 804 |
modify_dict['is_active'] |
| 805 |
LOG.info(msg) |
| 806 |
|
| 807 |
if 'is_active' in modify_dict and not modify_dict['is_active']: |
| 808 |
self.powerflex_conn.protection_domain. \ |
| 809 |
inactivate(protection_domain_id, modify_dict['is_active']) |
| 810 |
msg = "The protection domain is inactivated successfully, " \ |
| 811 |
"by setting as is_active: '%s' " % \ |
| 812 |
modify_dict['is_active'] |
| 813 |
LOG.info(msg) |
| 814 |
return True |
| 815 |
|
| 816 |
except Exception as e: |
| 817 |
if create_flag: |
| 818 |
err_msg = "Create protection domain is successful," \ |
| 819 |
" but failed to update the protection domain" \ |
| 820 |
" {0} with error {1}".format(protection_domain_id, |
| 821 |
str(e)) |
| 822 |
else: |
| 823 |
err_msg = "Failed to update the protection domain {0}" \ |
| 824 |
" with error {1}".format(protection_domain_id, |
| 825 |
str(e)) |
| 826 |
LOG.error(err_msg) |
| 827 |
self.module.fail_json(msg=err_msg) |
| 828 |
|
| 829 |
def delete_protection_domain(self, protection_domain_id): |
| 830 |
""" |
| 831 |
Delete Protection Domain |
| 832 |
:param protection_domain_id: ID of the protection domain |
| 833 |
:type protection_domain_id: str |
| 834 |
:return: Boolean indicating if delete operation is successful |
| 835 |
""" |
| 836 |
try: |
| 837 |
self.powerflex_conn.protection_domain.delete(protection_domain_id) |
| 838 |
LOG.info("Protection domain deleted successfully.") |
| 839 |
return True |
| 840 |
except Exception as e: |
| 841 |
error_msg = "Delete protection domain '%s' operation failed" \ |
| 842 |
" with error '%s'" % (protection_domain_id, str(e)) |
| 843 |
LOG.error(error_msg) |
| 844 |
self.module.fail_json(msg=error_msg) |
| 845 |
|
| 846 |
def perform_module_operation(self): |
| 847 |
""" |
| 848 |
Perform different actions on protection domain based on parameters |
| 849 |
passed in the playbook |
| 850 |
""" |
| 851 |
protection_domain_name = self.module.params['protection_domain_name'] |
| 852 |
protection_domain_id = self.module.params['protection_domain_id'] |
| 853 |
protection_domain_new_name = self.module.params[ |
| 854 |
'protection_domain_new_name'] |
| 855 |
is_active = self.module.params['is_active'] |
| 856 |
network_limits = self.convert_limits_in_kbps( |
| 857 |
self.module.params['network_limits']) |
| 858 |
rf_cache_limits = self.module.params['rf_cache_limits'] |
| 859 |
state = self.module.params['state'] |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
changed = False |
| 864 |
result = dict( |
| 865 |
changed=False, |
| 866 |
protection_domain_details=None |
| 867 |
) |
| 868 |
|
| 869 |
|
| 870 |
self.validate_input_params() |
| 871 |
|
| 872 |
|
| 873 |
pd_details = self.get_protection_domain(protection_domain_name, |
| 874 |
protection_domain_id) |
| 875 |
|
| 876 |
if pd_details: |
| 877 |
protection_domain_id = pd_details['id'] |
| 878 |
msg = "Fetched the protection domain details with id '%s', name" \ |
| 879 |
" '%s'" % (protection_domain_id, protection_domain_name) |
| 880 |
LOG.info(msg) |
| 881 |
|
| 882 |
|
| 883 |
create_changed = False |
| 884 |
create_changed, pd_details = self. \ |
| 885 |
perform_create_operation(state, pd_details, |
| 886 |
protection_domain_name) |
| 887 |
|
| 888 |
|
| 889 |
modify_dict = {} |
| 890 |
nw_modify_dict = {} |
| 891 |
rf_modify_dict = {} |
| 892 |
|
| 893 |
if self.is_modify_required(pd_details, network_limits, |
| 894 |
rf_cache_limits, |
| 895 |
protection_domain_new_name, is_active): |
| 896 |
modify_dict = to_modify(pd_details, protection_domain_new_name, |
| 897 |
is_active) |
| 898 |
nw_modify_dict = to_nw_limit_modify(pd_details, network_limits) |
| 899 |
rf_modify_dict = to_rf_limit_modify(pd_details, rf_cache_limits) |
| 900 |
msg = "Parameters to be modified are as follows: %s %s, %s" \ |
| 901 |
% (str(modify_dict), str(nw_modify_dict), |
| 902 |
str(rf_modify_dict)) |
| 903 |
LOG.info(msg) |
| 904 |
|
| 905 |
|
| 906 |
modify_changed = False |
| 907 |
is_nw_limit = all(value is None for value in nw_modify_dict.values()) |
| 908 |
is_rf_limit = all(value is None for value in rf_modify_dict.values()) |
| 909 |
|
| 910 |
if not is_nw_limit and state == 'present': |
| 911 |
modify_changed = self.modify_nw_limits(pd_details['id'], |
| 912 |
nw_modify_dict, |
| 913 |
create_changed) |
| 914 |
if not is_rf_limit and state == 'present': |
| 915 |
modify_changed = self.modify_rf_limits(pd_details['id'], |
| 916 |
rf_modify_dict, |
| 917 |
create_changed) |
| 918 |
if modify_dict and state == 'present': |
| 919 |
modify_changed = self. \ |
| 920 |
modify_pd_attributes(pd_details['id'], modify_dict, |
| 921 |
create_changed) |
| 922 |
if modify_changed: |
| 923 |
pd_details = self.get_protection_domain( |
| 924 |
protection_domain_id=pd_details['id']) |
| 925 |
msg = "Protection domain details after modification:" \ |
| 926 |
" '%s'" % str(pd_details) |
| 927 |
LOG.info(msg) |
| 928 |
|
| 929 |
|
| 930 |
delete_changed = False |
| 931 |
if state == 'absent' and pd_details: |
| 932 |
delete_changed = self. \ |
| 933 |
delete_protection_domain(pd_details['id']) |
| 934 |
|
| 935 |
if create_changed or modify_changed or delete_changed: |
| 936 |
changed = True |
| 937 |
|
| 938 |
|
| 939 |
if state == 'present': |
| 940 |
pd_details = self.get_protection_domain( |
| 941 |
protection_domain_id=pd_details['id']) |
| 942 |
result['protection_domain_details'] = pd_details |
| 943 |
result['changed'] = changed |
| 944 |
self.module.exit_json(**result) |
| 945 |
|
| 946 |
def convert_limits_in_kbps(self, network_limits): |
| 947 |
""" |
| 948 |
Convert the limits into KBps |
| 949 |
|
| 950 |
:param network_limits: dict containing all Network bandwidth limits |
| 951 |
:rtype: converted network limits |
| 952 |
""" |
| 953 |
limit_params = ['rebuild_limit', 'rebalance_limit', |
| 954 |
'vtree_migration_limit', 'overall_limit'] |
| 955 |
modified_limits = dict() |
| 956 |
modified_limits['rebuild_limit'] = None |
| 957 |
modified_limits['rebalance_limit'] = None |
| 958 |
modified_limits['vtree_migration_limit'] = None |
| 959 |
modified_limits['overall_limit'] = None |
| 960 |
if network_limits is None: |
| 961 |
return None |
| 962 |
for limits in network_limits: |
| 963 |
if network_limits[limits] is not None and limits in limit_params: |
| 964 |
if network_limits['bandwidth_unit'] == "GBps": |
| 965 |
modified_limits[limits] = \ |
| 966 |
network_limits[limits] * 1024 * 1024 |
| 967 |
elif network_limits['bandwidth_unit'] == "MBps": |
| 968 |
modified_limits[limits] = network_limits[limits] * 1024 |
| 969 |
else: |
| 970 |
modified_limits[limits] = network_limits[limits] |
| 971 |
|
| 972 |
return modified_limits |
| 973 |
|
| 974 |
|
| 975 |
def to_modify(pd_details, protection_domain_new_name, is_active): |
| 976 |
""" |
| 977 |
Check if modification required for rename and is_active for protection |
| 978 |
domain |
| 979 |
:param pd_details: Details of the protection domain |
| 980 |
:type pd_details: dict |
| 981 |
:param protection_domain_new_name: To rename protection domain |
| 982 |
:type protection_domain_new_name: str |
| 983 |
:param is_active: Whether to activate protection domain |
| 984 |
:type is_active: bool |
| 985 |
:return: Dictionary containing the attributes of protection domain |
| 986 |
which are to be updated |
| 987 |
:rtype: dict |
| 988 |
""" |
| 989 |
|
| 990 |
modify_dict = dict() |
| 991 |
if protection_domain_new_name is not None and \ |
| 992 |
protection_domain_new_name != pd_details['name']: |
| 993 |
modify_dict['protection_domain_new_name'] = \ |
| 994 |
protection_domain_new_name |
| 995 |
|
| 996 |
if is_active is not None and \ |
| 997 |
((pd_details['protectionDomainState'] == 'Active' and |
| 998 |
not is_active) or |
| 999 |
(pd_details['protectionDomainState'] == 'Inactive' and |
| 1000 |
is_active)): |
| 1001 |
modify_dict['is_active'] = is_active |
| 1002 |
|
| 1003 |
return modify_dict |
| 1004 |
|
| 1005 |
|
| 1006 |
def to_nw_limit_modify(pd_details, network_limits): |
| 1007 |
""" |
| 1008 |
Check if modification required network bandwidth limit for protection |
| 1009 |
domain |
| 1010 |
:param pd_details: Details of the protection domain |
| 1011 |
:type pd_details: dict |
| 1012 |
:param network_limits: dict of Network bandwidth limit |
| 1013 |
:type network_limits: dict |
| 1014 |
:return: Dictionary containing the attributes of protection domain |
| 1015 |
which are to be updated |
| 1016 |
:rtype: dict |
| 1017 |
""" |
| 1018 |
|
| 1019 |
modify_dict = {} |
| 1020 |
if network_limits is not None: |
| 1021 |
modify_dict['rebuild_limit'] = None |
| 1022 |
modify_dict['rebalance_limit'] = None |
| 1023 |
modify_dict['vtree_migration_limit'] = None |
| 1024 |
modify_dict['overall_limit'] = None |
| 1025 |
|
| 1026 |
if network_limits['rebuild_limit'] is not None and \ |
| 1027 |
pd_details['rebuildNetworkThrottlingInKbps'] != network_limits['rebuild_limit']: |
| 1028 |
modify_dict['rebuild_limit'] = network_limits['rebuild_limit'] |
| 1029 |
|
| 1030 |
if network_limits['rebalance_limit'] is not None and \ |
| 1031 |
pd_details['rebalanceNetworkThrottlingInKbps'] \ |
| 1032 |
!= network_limits['rebalance_limit']: |
| 1033 |
modify_dict['rebalance_limit'] = network_limits['rebalance_limit'] |
| 1034 |
|
| 1035 |
if network_limits['vtree_migration_limit'] is not None and \ |
| 1036 |
pd_details['vtreeMigrationNetworkThrottlingInKbps'] != \ |
| 1037 |
network_limits['vtree_migration_limit']: |
| 1038 |
modify_dict['vtree_migration_limit'] = network_limits['vtree_migration_limit'] |
| 1039 |
|
| 1040 |
if network_limits['overall_limit'] is not None and \ |
| 1041 |
pd_details['overallIoNetworkThrottlingInKbps'] != \ |
| 1042 |
network_limits['overall_limit']: |
| 1043 |
modify_dict['overall_limit'] = network_limits['overall_limit'] |
| 1044 |
|
| 1045 |
return modify_dict |
| 1046 |
|
| 1047 |
|
| 1048 |
def to_rf_limit_modify(pd_details, rf_cache_limits): |
| 1049 |
""" |
| 1050 |
Check if modification required for RF cache for protection domain |
| 1051 |
:param pd_details: Details of the protection domain |
| 1052 |
:type pd_details: dict |
| 1053 |
:param rf_cache_limits: dict for RF cache |
| 1054 |
:type rf_cache_limits: dict |
| 1055 |
:return: Dictionary containing the attributes of protection domain |
| 1056 |
which are to be updated |
| 1057 |
:rtype: dict |
| 1058 |
""" |
| 1059 |
modify_dict = {} |
| 1060 |
if rf_cache_limits is not None: |
| 1061 |
modify_dict['is_enabled'] = None |
| 1062 |
modify_dict['page_size'] = None |
| 1063 |
modify_dict['max_io_limit'] = None |
| 1064 |
modify_dict['pass_through_mode'] = None |
| 1065 |
|
| 1066 |
if rf_cache_limits['is_enabled'] is not None and pd_details['rfcacheEnabled'] != \ |
| 1067 |
rf_cache_limits['is_enabled']: |
| 1068 |
modify_dict['is_enabled'] = rf_cache_limits['is_enabled'] |
| 1069 |
|
| 1070 |
if rf_cache_limits['page_size'] is not None and pd_details['rfcachePageSizeKb'] != \ |
| 1071 |
rf_cache_limits['page_size']: |
| 1072 |
modify_dict['page_size'] = rf_cache_limits['page_size'] |
| 1073 |
|
| 1074 |
if rf_cache_limits['max_io_limit'] is not None and pd_details['rfcacheMaxIoSizeKb'] != \ |
| 1075 |
rf_cache_limits['max_io_limit']: |
| 1076 |
modify_dict['max_io_limit'] = rf_cache_limits['max_io_limit'] |
| 1077 |
|
| 1078 |
if rf_cache_limits['pass_through_mode'] is not None and \ |
| 1079 |
pd_details['rfcacheOpertionalMode'] != rf_cache_limits['pass_through_mode']: |
| 1080 |
modify_dict['pass_through_mode'] = rf_cache_limits['pass_through_mode'] |
| 1081 |
|
| 1082 |
return modify_dict |
| 1083 |
|
| 1084 |
|
| 1085 |
def get_powerflex_protection_domain_parameters(): |
| 1086 |
"""This method provides parameters required for the protection domain |
| 1087 |
module on PowerFlex""" |
| 1088 |
return dict( |
| 1089 |
protection_domain_name=dict(), |
| 1090 |
protection_domain_new_name=dict(), |
| 1091 |
protection_domain_id=dict(), |
| 1092 |
is_active=dict(type='bool'), |
| 1093 |
network_limits=dict( |
| 1094 |
type='dict', options=dict( |
| 1095 |
rebuild_limit=dict(type='int'), |
| 1096 |
rebalance_limit=dict(type='int'), |
| 1097 |
vtree_migration_limit=dict(type='int'), |
| 1098 |
overall_limit=dict(type='int'), |
| 1099 |
bandwidth_unit=dict(choices=['KBps', 'MBps', 'GBps'], |
| 1100 |
default='KBps') |
| 1101 |
) |
| 1102 |
), |
| 1103 |
rf_cache_limits=dict( |
| 1104 |
type='dict', options=dict( |
| 1105 |
is_enabled=dict(type='bool'), |
| 1106 |
page_size=dict(type='int'), |
| 1107 |
max_io_limit=dict(type='int'), |
| 1108 |
pass_through_mode=dict(choices=['None', 'Read', 'Write', |
| 1109 |
'ReadAndWrite', 'WriteMiss']) |
| 1110 |
) |
| 1111 |
), |
| 1112 |
state=dict(required=True, type='str', choices=['present', 'absent']) |
| 1113 |
) |
| 1114 |
|
| 1115 |
|
| 1116 |
def main(): |
| 1117 |
""" Create PowerFlex protection domain object and perform actions on it |
| 1118 |
based on user input from playbook""" |
| 1119 |
obj = PowerFlexProtectionDomain() |
| 1120 |
obj.perform_module_operation() |
| 1121 |
|
| 1122 |
|
| 1123 |
if __name__ == '__main__': |
| 1124 |
main() |