
    VhZ                    `   d Z ddlmZmZmZ eZdZdZdZ	ddl
mZ ddlmZ ddlmZ dd	lmZ  ej$                  d
      Z G d de      Zd Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d  d!      Z G d" d#      Z  G d$ d%      Z! G d& d'      Z" G d( d)      Z# G d* d+      Z$ G d, d-      Z% G d. d/      Z& G d0 d1      Z' G d2 d3      Z( G d4 d5      Z) G d6 d7      Z*d8 Z+e,d9k(  r e+        y:y:);zKAnsible module for managing Dell Technologies (Dell) PowerFlex storage pool    )absolute_importdivisionprint_functiona   
---
module: storagepool

version_added: '1.0.0'

short_description: Managing Dell PowerFlex storage pool

description:
- Dell PowerFlex storage pool module includes getting the details of
  storage pool, creating a new storage pool, and modifying the attribute of
  a storage pool.

extends_documentation_fragment:
  - dellemc.powerflex.powerflex

author:
- Arindam Datta (@dattaarindam) <ansible.team@dell.com>
- P Srinivas Rao (@srinivas-rao5) <ansible.team@dell.com>
- Trisha Datta (@trisha-dell) <ansible.team@dell.com>

options:
  storage_pool_name:
    description:
    - The name of the storage pool.
    - If more than one storage pool is found with the same name then
      protection domain id/name is required to perform the task.
    - Mutually exclusive with I(storage_pool_id).
    type: str
  storage_pool_id:
    description:
    - The id of the storage pool.
    - It is auto generated, hence should not be provided during
      creation of a storage pool.
    - Mutually exclusive with I(storage_pool_name).
    type: str
  protection_domain_name:
    description:
    - The name of the protection domain.
    - During creation of a pool, either protection domain name or id must be
      mentioned.
    - Mutually exclusive with I(protection_domain_id).
    type: str
  protection_domain_id:
    description:
    - The id of the protection domain.
    - During creation of a pool, either protection domain name or id must
      be mentioned.
    - Mutually exclusive with I(protection_domain_name).
    type: str
  media_type:
    description:
    - Type of devices in the storage pool.
    type: str
    choices: ['HDD', 'SSD', 'TRANSITIONAL']
  storage_pool_new_name:
    description:
    - New name for the storage pool can be provided.
    - This parameter is used for renaming the storage pool.
    type: str
  use_rfcache:
    description:
    - Enable/Disable RFcache on a specific storage pool.
    type: bool
  use_rmcache:
    description:
    - Enable/Disable RMcache on a specific storage pool.
    type: bool
  enable_zero_padding:
    description:
    - Enable/Disable zero padding on a specific storage pool.
    type: bool
  rep_cap_max_ratio:
    description:
    - Set replication journal capacity of a storage pool.
    type: int
  enable_rebalance:
    description:
    - Enable/Disable rebalance on a specific storage pool.
    type: bool
  spare_percentage:
    description:
    - Set the spare percentage of a specific storage pool.
    type: int
  rmcache_write_handling_mode :
    description:
    - Set RM cache write handling mode of a storage pool.
    - I(Passthrough) Writes skip the cache and are stored in storage only.
    - I(Cached) Writes are stored in both cache and storage (the default).
    - Caching is only performed for IOs whose size is a multiple of 4k bytes.
    type: str
    choices: ['Cached', 'Passthrough']
    default: 'Cached'
  enable_rebuild:
    description:
    - Enable/Disable rebuild of a specific storage pool.
    type: bool
  enable_fragmentation:
    description:
    - Enable/Disable fragmentation of a specific storage pool.
    type: bool
  parallel_rebuild_rebalance_limit:
    description:
    - Set rebuild/rebalance parallelism limit of a storage pool.
    type: int
  persistent_checksum:
    description:
    - Enable/Disable persistent checksum of a specific storage pool.
    type: dict
    suboptions:
      enable:
        description:
        - Enable / disable persistent checksum.
        type: bool
      validate_on_read:
        description:
        - Validate checksum upon reading data.
        type: bool
      builder_limit:
        description:
        - Bandwidth limit in KB/s for the checksum building process.
        - Valid range is 1024 to 10240.
        default: 3072
        type: int
  protected_maintenance_mode_io_priority_policy:
    description:
    - Set protected maintenance mode I/O priority policy of a storage pool.
    type: dict
    suboptions:
      policy:
        description:
        - The I/O priority policy for protected maintenance mode.
        - C(unlimited) Protected maintenance mode IOPS are not limited
        - C(limitNumOfConcurrentIos)Limit the number of allowed concurrent protected maintenance mode
          migration I/Os to the value defined for I(concurrent_ios_per_device).
        - C(favorAppIos) Always limit the number of allowed concurrent protected maintenance mode
          migration I/Os to value defined for I(concurrent_ios_per_device).
        - If application I/Os are in progress, should also limit the bandwidth of
          protected maintenance mode migration I/Os to the limit defined for the I(bw_limit_per_device).
        type: str
        choices: ['unlimited', 'limitNumOfConcurrentIos', 'favorAppIos']
        default: 'limitNumOfConcurrentIos'
      concurrent_ios_per_device:
        description:
        - The maximum number of concurrent protected maintenance mode migration I/Os per device.
        - Valid range is 1 to 20.
        type: int
      bw_limit_per_device:
        description:
        - The maximum bandwidth of protected maintenance mode migration I/Os,
          in KB per second, per device.
        - Valid range is 1024 to 1048576.
        type: int
  vtree_migration_io_priority_policy:
    description:
    - Set the I/O priority policy for V-Tree migration for a specific Storage Pool.
    type: dict
    suboptions:
      policy:
        description:
        - The I/O priority policy for protected maintenance mode.
        - C(limitNumOfConcurrentIos) Limit the number of allowed concurrent V-Tree
          migration I/Os (default) to the I(concurrent_ios_per_device).
        - C(favorAppIos) Always limit the number of allowed concurrent
          V-Tree migration I/Os to defined for I(concurrent_ios_per_device).
        - If application I/Os are in progress, should also limit the bandwidth of
          V-Tree migration I/Os to the limit defined for the I(bw_limit_per_device).
        type: str
        choices: ['limitNumOfConcurrentIos', 'favorAppIos']
      concurrent_ios_per_device:
        description:
        - The maximum number of concurrent V-Tree migration I/Os per device.
        - Valid range is 1 to 20
        type: int
      bw_limit_per_device:
        description:
        - The maximum bandwidth of V-Tree migration I/Os,
          in KB per second, per device.
        - Valid range is 1024 to 25600.
        type: int
  rebalance_io_priority_policy:
    description:
    - Set the rebalance I/O priority policy for a Storage Pool.
    type: dict
    suboptions:
      policy:
        description:
        - Policy to use for rebalance I/O priority.
        - C(unlimited) Rebalance I/Os are not limited.
        - C(limitNumOfConcurrentIos) Limit the number of allowed concurrent rebalance I/Os.
        - C(favorAppIos) Limit the number and bandwidth of rebalance I/Os when application I/Os are in progress.
        type: str
        choices: ['unlimited', 'limitNumOfConcurrentIos', 'favorAppIos']
        default: 'favorAppIos'
      concurrent_ios_per_device:
        description:
        - The maximum number of concurrent rebalance I/Os per device.
        - Valid range is 1 to 20.
        type: int
      bw_limit_per_device:
        description:
        - The maximum bandwidth of rebalance I/Os, in KB/s, per device.
        - Valid range is 1024 to 1048576.
        type: int
  cap_alert_thresholds:
    description:
    - Set the threshold for triggering capacity usage alerts.
    - Alerts thresholds are calculated from each Storage Pool
      capacity after deducting the defined amount of spare capacity.
    type: dict
    suboptions:
      high_threshold:
        description:
        - Threshold of the non-spare capacity of the Storage Pool that will trigger a
          high-priority alert, expressed as a percentage.
        - This value must be lower than the I(critical_threshold).
        type: int
      critical_threshold:
        description:
        - Threshold of the non-spare capacity of the Storage Pool that will trigger a
          critical-priority alert, expressed as a percentage.
        type: int
  state:
    description:
    - State of the storage pool.
    type: str
    choices: ["present", "absent"]
    required: true
notes:
  - TRANSITIONAL media type is supported only during modification.
  - The I(check_mode) is supported.
a  
- name: Get the details of storage pool by name
  dellemc.powerflex.storagepool:
    hostname: "{{hostname}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    storage_pool_name: "sample_pool_name"
    protection_domain_name: "sample_protection_domain"
    state: "present"

- name: Get the details of storage pool by id
  dellemc.powerflex.storagepool:
    hostname: "{{hostname}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    storage_pool_id: "abcd1234ab12r"
    state: "present"

- name: Create a new Storage pool
  dellemc.powerflex.storagepool:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: "{{ validate_certs }}"
    storage_pool_name: "{{ pool_name }}"
    protection_domain_name: "{{ protection_domain_name }}"
    cap_alert_thresholds:
      high_threshold: 30
      critical_threshold: 50
    media_type: "TRANSITIONAL"
    enable_zero_padding: true
    rep_cap_max_ratio: 40
    rmcache_write_handling_mode: "Passthrough"
    spare_percentage: 80
    enable_rebalance: false
    enable_fragmentation: false
    enable_rebuild: false
    use_rmcache: true
    use_rfcache: true
    parallel_rebuild_rebalance_limit: 3
    protected_maintenance_mode_io_priority_policy:
      policy: "unlimited"
    rebalance_io_priority_policy:
      policy: "unlimited"
    vtree_migration_io_priority_policy:
      policy: "limitNumOfConcurrentIos"
      concurrent_ios_per_device: 10
    persistent_checksum:
      enable: false
    state: "present"

- name: Modify a Storage pool by name
  dellemc.powerflex.storagepool:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    validate_certs: "{{ validate_certs }}"
    storage_pool_name: "{{ pool_name }}"
    protection_domain_name: "{{ protection_domain_name }}"
    storage_pool_new_name: "pool_name_new"
    cap_alert_thresholds:
      high_threshold: 50
      critical_threshold: 70
    enable_zero_padding: false
    rep_cap_max_ratio: 60
    rmcache_write_handling_mode: "Passthrough"
    spare_percentage: 90
    enable_rebalance: true
    enable_fragmentation: true
    enable_rebuild: true
    use_rmcache: true
    use_rfcache: true
    parallel_rebuild_rebalance_limit: 6
    protected_maintenance_mode_io_priority_policy:
      policy: "limitNumOfConcurrentIos"
      concurrent_ios_per_device: 4
    rebalance_io_priority_policy:
      policy: "favorAppIos"
      concurrent_ios_per_device: 10
      bw_limit_per_device: 4096
    vtree_migration_io_priority_policy:
      policy: "limitNumOfConcurrentIos"
      concurrent_ios_per_device: 10
    persistent_checksum:
      enable: true
      validate_on_read: true
      builder_limit: 1024
    state: "present"
a@  
changed:
    description: Whether or not the resource has changed.
    returned: always
    type: bool
    sample: 'false'
storage_pool_details:
    description: Details of the storage pool.
    returned: When storage pool exists
    type: dict
    contains:
        mediaType:
            description: Type of devices in the storage pool.
            type: str
        useRfcache:
            description: Enable/Disable RFcache on a specific storage pool.
            type: bool
        useRmcache:
            description: Enable/Disable RMcache on a specific storage pool.
            type: bool
        id:
            description: ID of the storage pool under protection domain.
            type: str
        name:
            description: Name of the storage pool under protection domain.
            type: str
        protectionDomainId:
            description: ID of the protection domain in which pool resides.
            type: str
        protectionDomainName:
            description: Name of the protection domain in which pool resides.
            type: str
        "statistics":
            description: Statistics details of the storage pool.
            type: dict
            contains:
                "capacityInUseInKb":
                    description: Total capacity of the storage pool.
                    type: str
                "unusedCapacityInKb":
                    description: Unused capacity of the storage pool.
                    type: str
                "deviceIds":
                    description: Device Ids of the storage pool.
                    type: list
    sample: {
        "addressSpaceUsage": "Normal",
        "addressSpaceUsageType": "DeviceCapacityLimit",
        "backgroundScannerBWLimitKBps": 3072,
        "backgroundScannerMode": "DataComparison",
        "bgScannerCompareErrorAction": "ReportAndFix",
        "bgScannerReadErrorAction": "ReportAndFix",
        "capacityAlertCriticalThreshold": 90,
        "capacityAlertHighThreshold": 80,
        "capacityUsageState": "Normal",
        "capacityUsageType": "NetCapacity",
        "checksumEnabled": false,
        "compressionMethod": "Invalid",
        "dataLayout": "MediumGranularity",
        "externalAccelerationType": "None",
        "fglAccpId": null,
        "fglExtraCapacity": null,
        "fglMaxCompressionRatio": null,
        "fglMetadataSizeXx100": null,
        "fglNvdimmMetadataAmortizationX100": null,
        "fglNvdimmWriteCacheSizeInMb": null,
        "fglOverProvisioningFactor": null,
        "fglPerfProfile": null,
        "fglWriteAtomicitySize": null,
        "fragmentationEnabled": true,
        "id": "e0d8f6c900000000",
        "links": [
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000",
                "rel": "self"
            },
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000
                        /relationships/Statistics",
                "rel": "/api/StoragePool/relationship/Statistics"
            },
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000
                        /relationships/SpSds",
                "rel": "/api/StoragePool/relationship/SpSds"
            },
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000
                        /relationships/Volume",
                "rel": "/api/StoragePool/relationship/Volume"
            },
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000
                        /relationships/Device",
                "rel": "/api/StoragePool/relationship/Device"
            },
            {
                "href": "/api/instances/StoragePool::e0d8f6c900000000
                        /relationships/VTree",
                "rel": "/api/StoragePool/relationship/VTree"
            },
            {
                "href": "/api/instances/ProtectionDomain::9300c1f900000000",
                "rel": "/api/parent/relationship/protectionDomainId"
            }
        ],
        "statistics": {
                "BackgroundScannedInMB": 3466920,
                "activeBckRebuildCapacityInKb": 0,
                "activeEnterProtectedMaintenanceModeCapacityInKb": 0,
                "aggregateCompressionLevel": "Uncompressed",
                "atRestCapacityInKb": 1248256,
                "backgroundScanCompareErrorCount": 0,
                "backgroundScanFixedCompareErrorCount": 0,
                "bckRebuildReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "bckRebuildWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "capacityAvailableForVolumeAllocationInKb": 369098752,
                "capacityInUseInKb": 2496512,
                "capacityInUseNoOverheadInKb": 2496512,
                "capacityLimitInKb": 845783040,
                "compressedDataCompressionRatio": 0.0,
                "compressionRatio": 1.0,
                "currentFglMigrationSizeInKb": 0,
                "deviceIds": [
                ],
                "enterProtectedMaintenanceModeCapacityInKb": 0,
                "enterProtectedMaintenanceModeReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "enterProtectedMaintenanceModeWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "exitProtectedMaintenanceModeReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "exitProtectedMaintenanceModeWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "exposedCapacityInKb": 0,
                "failedCapacityInKb": 0,
                "fwdRebuildReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "fwdRebuildWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "inMaintenanceCapacityInKb": 0,
                "inMaintenanceVacInKb": 0,
                "inUseVacInKb": 184549376,
                "inaccessibleCapacityInKb": 0,
                "logWrittenBlocksInKb": 0,
                "maxCapacityInKb": 845783040,
                "migratingVolumeIds": [
                ],
                "migratingVtreeIds": [
                ],
                "movingCapacityInKb": 0,
                "netCapacityInUseInKb": 1248256,
                "normRebuildCapacityInKb": 0,
                "normRebuildReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "normRebuildWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "numOfDeviceAtFaultRebuilds": 0,
                "numOfDevices": 3,
                "numOfIncomingVtreeMigrations": 0,
                "numOfVolumes": 8,
                "numOfVolumesInDeletion": 0,
                "numOfVtrees": 8,
                "overallUsageRatio": 73.92289,
                "pendingBckRebuildCapacityInKb": 0,
                "pendingEnterProtectedMaintenanceModeCapacityInKb": 0,
                "pendingExitProtectedMaintenanceModeCapacityInKb": 0,
                "pendingFwdRebuildCapacityInKb": 0,
                "pendingMovingCapacityInKb": 0,
                "pendingMovingInBckRebuildJobs": 0,
                "persistentChecksumBuilderProgress": 100.0,
                "persistentChecksumCapacityInKb": 414720,
                "primaryReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "primaryReadFromDevBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "primaryReadFromRmcacheBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "primaryVacInKb": 92274688,
                "primaryWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "protectedCapacityInKb": 2496512,
                "protectedVacInKb": 184549376,
                "provisionedAddressesInKb": 2496512,
                "rebalanceCapacityInKb": 0,
                "rebalanceReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "rebalanceWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "rfacheReadHit": 0,
                "rfacheWriteHit": 0,
                "rfcacheAvgReadTime": 0,
                "rfcacheAvgWriteTime": 0,
                "rfcacheIoErrors": 0,
                "rfcacheIosOutstanding": 0,
                "rfcacheIosSkipped": 0,
                "rfcacheReadMiss": 0,
                "rmPendingAllocatedInKb": 0,
                "rmPendingThickInKb": 0,
                "rplJournalCapAllowed": 0,
                "rplTotalJournalCap": 0,
                "rplUsedJournalCap": 0,
                "secondaryReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "secondaryReadFromDevBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "secondaryReadFromRmcacheBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "secondaryVacInKb": 92274688,
                "secondaryWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "semiProtectedCapacityInKb": 0,
                "semiProtectedVacInKb": 0,
                "snapCapacityInUseInKb": 0,
                "snapCapacityInUseOccupiedInKb": 0,
                "snapshotCapacityInKb": 0,
                "spSdsIds": [
                    "abdfe71b00030001",
                    "abdce71d00040001",
                    "abdde71e00050001"
                ],
                "spareCapacityInKb": 84578304,
                "targetOtherLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "targetReadLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "targetWriteLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "tempCapacityInKb": 0,
                "tempCapacityVacInKb": 0,
                "thickCapacityInUseInKb": 0,
                "thinAndSnapshotRatio": 73.92289,
                "thinCapacityAllocatedInKm": 184549376,
                "thinCapacityInUseInKb": 0,
                "thinUserDataCapacityInKb": 2496512,
                "totalFglMigrationSizeInKb": 0,
                "totalReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "totalWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "trimmedUserDataCapacityInKb": 0,
                "unreachableUnusedCapacityInKb": 0,
                "unusedCapacityInKb": 758708224,
                "userDataCapacityInKb": 2496512,
                "userDataCapacityNoTrimInKb": 2496512,
                "userDataReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "userDataSdcReadLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "userDataSdcTrimLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "userDataSdcWriteLatency": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "userDataTrimBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "userDataWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "volMigrationReadBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "volMigrationWriteBwc": {
                    "numOccured": 0,
                    "numSeconds": 0,
                    "totalWeightInKb": 0
                },
                "volumeAddressSpaceInKb": 922XXXXX,
                "volumeAllocationLimitInKb": 3707XXXXX,
                "volumeIds": [
                    "456afc7900XXXXXXXX"
                ],
                "vtreeAddresSpaceInKb": 92274688,
                "vtreeIds": [
                    "32b1681bXXXXXXXX",
                ]
        },
        "mediaType": "HDD",
        "name": "pool1",
        "numOfParallelRebuildRebalanceJobsPerDevice": 2,
        "persistentChecksumBuilderLimitKb": 3072,
        "persistentChecksumEnabled": true,
        "persistentChecksumState": "Protected",
        "persistentChecksumValidateOnRead": false,
        "protectedMaintenanceModeIoPriorityAppBwPerDeviceThresholdInKbps": null,
        "protectedMaintenanceModeIoPriorityAppIopsPerDeviceThreshold": null,
        "protectedMaintenanceModeIoPriorityBwLimitPerDeviceInKbps": 10240,
        "protectedMaintenanceModeIoPriorityNumOfConcurrentIosPerDevice": 1,
        "protectedMaintenanceModeIoPriorityPolicy": "limitNumOfConcurrentIos",
        "protectedMaintenanceModeIoPriorityQuietPeriodInMsec": null,
        "protectionDomainId": "9300c1f900000000",
        "protectionDomainName": "domain1",
        "rebalanceEnabled": true,
        "rebalanceIoPriorityAppBwPerDeviceThresholdInKbps": null,
        "rebalanceIoPriorityAppIopsPerDeviceThreshold": null,
        "rebalanceIoPriorityBwLimitPerDeviceInKbps": 10240,
        "rebalanceIoPriorityNumOfConcurrentIosPerDevice": 1,
        "rebalanceIoPriorityPolicy": "favorAppIos",
        "rebalanceIoPriorityQuietPeriodInMsec": null,
        "rebuildEnabled": true,
        "rebuildIoPriorityAppBwPerDeviceThresholdInKbps": null,
        "rebuildIoPriorityAppIopsPerDeviceThreshold": null,
        "rebuildIoPriorityBwLimitPerDeviceInKbps": 10240,
        "rebuildIoPriorityNumOfConcurrentIosPerDevice": 1,
        "rebuildIoPriorityPolicy": "limitNumOfConcurrentIos",
        "rebuildIoPriorityQuietPeriodInMsec": null,
        "replicationCapacityMaxRatio": 32,
        "rmcacheWriteHandlingMode": "Cached",
        "sparePercentage": 10,
        "useRfcache": false,
        "useRmcache": false,
        "vtreeMigrationIoPriorityAppBwPerDeviceThresholdInKbps": null,
        "vtreeMigrationIoPriorityAppIopsPerDeviceThreshold": null,
        "vtreeMigrationIoPriorityBwLimitPerDeviceInKbps": 10240,
        "vtreeMigrationIoPriorityNumOfConcurrentIosPerDevice": 1,
        "vtreeMigrationIoPriorityPolicy": "favorAppIos",
        "vtreeMigrationIoPriorityQuietPeriodInMsec": null,
        "zeroPaddingEnabled": true
    }
)AnsibleModule)PowerFlexBase)Configuration)utilsstoragepoolc                   r     e Zd ZdZ fdZ	 ddZ	 	 ddZ	 ddZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Z xZS )PowerFlexStoragePoolz!Class with StoragePool operationsc                     	 ddgddgddgddgg}ddgg}t               d||d}t        | 	  t        |       t	        j
                  | j                         t        di       | _        y	)
z. Define all parameters required by this modulestorage_pool_namestorage_pool_idprotection_domain_nameprotection_domain_idT)argument_specsupports_check_modemutually_exclusiverequired_one_ofF)changedstorage_pool_detailsN)	$get_powerflex_storagepool_parameterssuper__init__r   r	   ensure_required_libsmoduledictresult)selfr   r   ansible_module_params	__class__s       q/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/dellemc/powerflex/plugins/modules/storagepool.pyr   zPowerFlexStoragePool.__init__  s    -24EF79OP02JK02HIK
 01BCD BC#'"4.	!
 	(=>""4;;/!#
    c                 d    t        | j                  | j                        j                  ||      S )zRGet the details of a protection domain in a given PowerFlex storage
        system)r   r   )r   powerflex_connr   get_protection_domain)r   r   r   s      r"   r&   z*PowerFlexStoragePool.get_protection_domain  s6    
 T00$++>TT#9Pd U f 	fr#   c                    |r|n|}	 i }|rd|i}|r|j                  d|i       |r|j                  d|i       | j                  j                  j                  |      }|g k7  rt	        |      dkD  rCdj                  |      }t        j                  |       | j                  j                  |       yt	        |      dk(  rW|d   }| j                  j                  j                  |d         }|r|ni |d	<   |d   }| j                  |
      d   }	|	|d<   |S y# t        $ rV}
dj                  |t        |
            }t        j                  |       | j                  j                  |       Y d}
~
yd}
~
ww xY w)zGet storage pool details
            :param pd_id: ID of the protection domain
            :param storage_pool_name: The name of the storage pool
            :param storage_pool_id: The storage pool id
            :return: Storage pool details
        idnameprotectionDomainId)filter_fields   ztMore than one storage pool found with {0}, Please provide protection domain Name/Id to fetch the unique storage poolmsgr   
statistics)r   protectionDomainNameNz1Failed to get the storage pool {0} with error {1})updater%   storage_poolgetlenformatLOGerrorr   	fail_jsonget_statisticsr&   	Exceptionstr)r   r   r   pd_id
name_or_idr+   pool_detailserr_msgr/   pd_nameeerrormsgs               r"   get_storage_poolz%PowerFlexStoragePool.get_storage_pool  s    )8_" 	$	0M!% 7 $$f.?%@A$$&:E%BC..;;??+ @ -Lr!|$q(. /5f5F.G  IIg&KK))g)6  &!+#/?L!%!4!4!A!A!P!PQ]^bQc!dJ?IrL.()=>E"88-2 9 44:<G <CL!78'' 	0#VJA7 IIhKK!!h!//		0s    B-D 6A$D 	E;%AE66E;c                    	 |dk(  r| j                   j                  d       || j                   j                  d       | j                   j                  s-| j                  j                  j                  |||||      d   }| j                  |      S # t        $ rV}d	j                  |t        |            }t        j                  |       | j                   j                  |       Y d}~yd}~ww xY w)
aq  
        Create a storage pool
        :param pool_name: Name of the storage pool
        :param pd_id: ID of the storage pool
        :param media_type: Type of storage device in the pool
        :param use_rfcache: Enable/Disable RFcache on pool
        :param use_rmcache: Enable/Disable RMcache on pool
        :return: True, if the operation is successful
        TransitionalzYTRANSITIONAL media type is not supported during creation. Please enter a valid media typer-   NzGPlease provide protection domain details for creation of a storage pool)
media_typer   r)   use_rfcacheuse_rmcacher(   )r   r<   z4Failed to create the storage pool {0} with error {1})r   r8   
check_moder%   r2   createrC   r:   r5   r;   r6   r7   )	r   	pool_namer<   rF   rG   rH   pool_idrA   rB   s	            r"   create_storage_poolz(PowerFlexStoragePool.create_storage_poolO  s	   	0^+%% +M% N }%%5 & 6 ;;))--::AA)).Y + B F GKL
 ((/4 ) 6 6  	0#VIs1v6 IIhKK!!h!//		0s   BB 	C6 AC11C6c                 
   | j                   j                  d   }| j                   j                  d   }|O|r$||d   k7  r| j                   j                  d       |r&||d   k7  r| j                   j                  d       yyyy)	z
        :param pool_details: Details of the storage pool
        :param pd_name: Name of the protection domain
        :param pd_id: Id of the protection domain
        r   r   Nr*   zEntered protection domain id does not match with the storage pool's protection domain id. Please enter a correct protection domain id.r-   r0   zEntered protection domain name does not match with the storage pool's protection domain name. Please enter a correct protection domain name.)r   paramsr8   )r   r>   r@   r<   s       r"   verify_protection_domainz-PowerFlexStoragePool.verify_protection_domains  s     ++$$%=>""#9:#,/C"DD%% +L% M
 7l3I&JJ%% +O% P Kw $r#   c                 p   | j                   j                  d   3t        | j                   j                  d   j                               dk(  sL| j                   j                  d   Qt        | j                   j                  d   j                               dk(  r| j                   j	                  d       y y y )Nr   r   storage_pool_new_namez]Empty or white spaced string provided for storage pool name. Provide valid storage pool name.r-   )r   rO   r4   stripr8   )r   s    r"   verify_storage_pool_namez-PowerFlexStoragePool.verify_storage_pool_name  s    KK23?T[[''(;<BBDEJ##$;<H++,CDJJLMQRRKK!!" " # S Ir#   c                    	 |d   d   r}|d   dur?| j                   j                  j                  |d   |d   d   |d   d   |d   d          n7| j                   j                  j                  |d   |d   d   |d   d   	       | j	                  |d   
      }|S # t
        $ rU}dj                  t        |            }t        j                  |       | j                  j                  |       Y d }~y d }~ww xY w)Npersistent_checksumenablepersistentChecksumEnabledTr(   validate_on_readbuilder_limit)r   rW   validaterZ   )r   r[   rZ   r   z0Failed to set persistent checksum with error {0}r-   )r%   r2   set_persistent_checksummodify_persistent_checksumrC   r:   r5   r;   r6   r7   r   r8   )r   r>   pool_paramsrA   r?   s        r"   r]   z,PowerFlexStoragePool.set_persistent_checksum  s*   	/01(; ;<DH''44LL(4T(:*+@A(K!,-B!CDV!W&12G&H&Y	 M [ ''44OO(4T(:!,-B!CDV!W&12G&H&Y P [
  00dAS0TL 	/"F3q6N IIgKK!!g!..		/s   BB 	C<'AC77C<c                    t               }|d   d   |d   d   |d   k7  r|d   d   |d<   |d   d   #|d   d   |d   k7  r|d   d   du r|d   d   |d<   |d   d   #|d   d   |d   k7  r|d   d   du r|d   d   |d<   |S )	NrV   rW   rX   rY    persistentChecksumValidateOnReadTrZ    persistentChecksumBuilderLimitKbr   )r   r>   r_   checksum_dicts       r"   to_modify_persistent_checksumz2PowerFlexStoragePool.to_modify_persistent_checksum  s    ,-h7C128<Mh@ii&12G&H&RM(#,-.@AM123EF,WyJzz128<D0;<Q0RSe0fM,-,-o>J12?C|TvGww128<D-89N-OP_-`M/*r#   c                 @   d d d d}d}|d   d   |d   d   |d   k7  r|d   d   |d<   d}|d   d   "|d   d   |d   k7  rt        |d   d         |d	<   |d   d
   "|d   d
   |d   k7  rt        |d   d
         |d<   |d   |d	   |d   
|d   |d<   d}|du r|S y )Npolicyconcurrent_iosbw_limitFrebalance_io_priority_policyrh   rebalanceIoPriorityPolicyTconcurrent_ios_per_device.rebalanceIoPriorityNumOfConcurrentIosPerDeviceri   bw_limit_per_device)rebalanceIoPriorityBwLimitPerDeviceInKbpsrj   r;   r   r>   r_   policy_dictmodifys        r"   &to_modify_rebalance_io_priority_policyz;PowerFlexStoragePool.to_modify_rebalance_io_priority_policy  sN    "

 56x@L:;HEVqIrr$/0N$OPX$YK!F567RS_:;<WX\h  jZ  ][  [,/<Z0[\w0x,yK()567LMY:;<QRVb  dO  WP  P&)+6T*UVk*l&mK
#x (k:J.K.W[fgq[r[~$01L$MK!FT>r#   c                 @   d d d d}d}|d   d   |d   d   |d   k7  r|d   d   |d<   d}|d   d   "|d   d   |d   k7  rt        |d   d         |d	<   |d   d
   "|d   d
   |d   k7  rt        |d   d
         |d<   |d   |d	   |d   
|d   |d<   d}|du r|S y )Nrg   F"vtree_migration_io_priority_policyrh   vtreeMigrationIoPriorityPolicyTrm   3vtreeMigrationIoPriorityNumOfConcurrentIosPerDeviceri   ro   .vtreeMigrationIoPriorityBwLimitPerDeviceInKbpsrj   rq   rr   s        r"   ,to_modify_vtree_migration_io_priority_policyzAPowerFlexStoragePool.to_modify_vtree_migration_io_priority_policy  s<   "

 ;<XFR@A(K|\|O}}$/0T$UV^$_K!F;<=XYe@AB]^RST,/<`0ab}0~,K();<=RS_@ABWXMNO&)+6Z*[\q*r&sK
#x (k:J.K.W[fgq[r[~$01Q$RK!FT>r#   c                 @   d d d d}d}|d   d   |d   d   |d   k7  r|d   d   |d<   d}|d   d   "|d   d   |d   k7  rt        |d   d         |d	<   |d   d
   "|d   d
   |d   k7  rt        |d   d
         |d<   |d   |d	   |d   
|d   |d<   d}|du r|S y )Nrg   F-protected_maintenance_mode_io_priority_policyrh   (protectedMaintenanceModeIoPriorityPolicyTrm   =protectedMaintenanceModeIoPriorityNumOfConcurrentIosPerDeviceri   ro   8protectedMaintenanceModeIoPriorityBwLimitPerDeviceInKbpsrj   rq   rr   s        r"   7to_modify_protected_maintenance_mode_io_priority_policyzLPowerFlexStoragePool.to_modify_protected_maintenance_mode_io_priority_policy  sT    "

 FGQ]KLXVZf  hR  [S  S$/0_$`ai$jK!FFGHcdpKLMhi\]^,/<k0l  nI  1J  -KK()FGH]^jKLMbcWXY&)+6e*fg|*}&~K
#x (k:J.K.W[fgq[r[~$01[$\K!FT>r#   c                 *   d}t               }|d   d   $|d   d   |d   k7  rt        |d   d         |d<   d}|d   d   $|d   d   |d   k7  rt        |d   d         |d	<   d}|du r*d|vrt        |d         |d<   d	|vrt        |d         |d	<   |S )
NFcap_alert_thresholdshigh_thresholdcapacityAlertHighThresholdhighTcritical_thresholdcapacityAlertCriticalThresholdcritical)r   r;   )r   r>   r_   
thresholdsrt   	thresholds         r"   #to_modify_capacity_alert_thresholdsz8PowerFlexStoragePool.to_modify_capacity_alert_thresholds  s    F	-./?@LQ\]sQt R"%12N%ORP #K0F$GHX$Y ZIfF-./CDP234HI\0N2 2$'4J(KL`(a$bIj!FT>Y&$'5Q(R$S	&!*(+L9Y,Z([	*%r#   )NN)NNN)__name__
__module____qualname____doc__r   r&   rC   rM   rP   rT   r]   re   ru   r{   r   r   __classcell__)r!   s   @r"   r   r     s]    +
2 EIf HL#.0b ;?"0HP*#/0$<>@r#   r   c                     t        d0i dt        dd      dt        dd      dt        dd      dt        dd      dt        ddg d	
      dt        dd      dt        dd      dt        d      dt        d      dt        ddgd      dt        d      dt        d      dt        d      dt        d      dt        dd      dt        d      dt        dt        t        d      t        d                  d t        dt        t        g d!d"      t        d      t        d      #            d$t        dt        t        g d!d%      t        d      t        d      #            d&t        dt        t        d"d%g'      t        d      t        d      #            d(t        dt        t        d      t        d      t        dd)*      +            d,t        d-dd.d/g
      S )1z]This method provides parameters required for the ansible
    Storage Pool module on powerflexr   Fr;   )requiredtyper   r   r   rF   )HDDSSDTRANSITIONAL)r   r   choicesrG   boolrH   enable_zero_padding)r   rep_cap_max_ratiointrmcache_write_handling_modeCachedPassthrough)r   defaultspare_percentageenable_rebalanceenable_fragmentationenable_rebuildrR    parallel_rebuild_rebalance_limitr   r   )r   r   )r   optionsr}   )	unlimitedlimitNumOfConcurrentIosfavorAppIosr   )rh   rm   ro   rk   r   rw   )r   rV   i   )r   r   )rW   rY   rZ   stateTpresentabsent rc   r   r#   r"   r   r   .  sK     %NE:%Ne%8%N  $U?%N "5u=	%N
 U >@%N %f5%N %f5%N !f-%N E*%N %)(M1JT\$]%N 5)%N 6*%N "v.%N (%N  #E>!%N" *.5)9#%N$ "vtU+#/81 2%%N* 7;PT Waz{&*&6 $% 0Q2 73+%N2 &*vt Wano&*&6 $% 0@2 &33%N: ,0VT!:M JK&*&6 $% 0F2 ,3;%NB !fdV$!v.E487: ;C%NJ Duy(6KLK%N %Nr#   c                       e Zd Zd Zy)StoragePoolExitHandlerc                     |r|j                  |d         }||j                  d<    |j                  j                  di |j                   y )Nr(   r\   r   r   )rC   r   r   	exit_json)r   pool_objr>   s      r"   handlezStoragePoolExitHandler.handleZ  sH    #44\RVEW4XL2>./!!!4HOO4r#   Nr   r   r   r   r   r#   r"   r   r   Y  s    5r#   r   c                       e Zd Zd Zy)StoragePoolDeleteHandlerc                     |d   dk(  r5|r3d}t         j                  |       |j                  j                  |       t	               j                  ||       y )Nr   r   z>Deleting storage pool is not supported through ansible module.r-   )r6   r7   r   r8   r   r   )r   r   r_   r>   r.   s        r"   r   zStoragePoolDeleteHandler.handlec  sK    w8+%CIIcNOO%%#%. '',?r#   Nr   r   r#   r"   r   r   b  s    @r#   r   c                       e Zd Zd Zy)*StoragePoolModifyPersistentChecksumHandlerc                    	 |d   dk(  rW|rU|d   P|j                  ||      }|i k7  r8|j                  j                  s|j                  ||      }d|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                  j                  |       Y d }~y d }~ww xY w)	Nr   r   rV   r>   r_   Tr   z-Modify Persistent Checksum failed with error r-   )re   r   rI   r]   r   r   r   r:   r;   r6   r7   r8   )r   r   r_   r>   rd   rA   	error_msgs          r"   r   z1StoragePoolModifyPersistentChecksumHandler.handlen  s    	57#y0\45A$,$J$J%1$/ %K %1M %*'99+3+K+K-9,7 ,L ,9L 6:	2$&--h\R 	5''*1vh0IIIi OO%%)%44		5s   A:A= =	C?C

CNr   r   r#   r"   r   r   m  s    5r#   r   c                       e Zd Zd Zy)1StoragePoolModifyRebalanceIOPriorityPolicyHandlerc                    	 |d   dk(  rv|rt|d   o|j                  ||      }|Z|j                  j                  s5|j                  j                  j                  |d   |d   |d   |d   	      }d
|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                  j                  |       Y d }~y d }~ww xY w)Nr   r   rk   r   r(   rh   ri   rj   r   rh   rm   ro   Tr   z6Modify rebalance IO Priority Policy failed with error r-   )ru   r   rI   r%   r2   rk   r   r   r   r:   r;   r6   r7   r8   r   r   r_   r>   rs   rA   r   s          r"   r   z8StoragePoolModifyRebalanceIOPriorityPolicyHandler.handle  s   	57#y0\=>J"*"Q"Q%1$/ #R #K #.'99+3+B+B+O+O+l+l0<T0B'28'<:EFV:W4?
4K	 ,m ,ML
 6:	268??+Wcd 	5''*1vh0IIIi OO%%)%44		5   BB 	C.%?C))C.Nr   r   r#   r"   r   r         5r#   r   c                       e Zd Zd Zy)3StoragePoolSetVtreeMigrationIOPriorityPolicyHandlerc                    	 |d   dk(  rv|rt|d   o|j                  ||      }|Z|j                  j                  s5|j                  j                  j                  |d   |d   |d   |d   	      }d
|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                  j                  |       Y d }~y d }~ww xY w)Nr   r   rw   r   r(   rh   ri   rj   r   Tr   zDSet Vtree Migration I/O Priority Policy operation failed with error r-   )r{   r   rI   r%   r2   &set_vtree_migration_io_priority_policyr   r   r   r:   r;   r6   r7   r8   r   s          r"   r   z:StoragePoolSetVtreeMigrationIOPriorityPolicyHandler.handle  s   	57#y0\CDP"*"W"W%1$/ #X #K #.'99+3+B+B+O+O+v+v0<T0B'28'<:EFV:W4?
4K	 ,w ,ML
 6:	2=?FFxQ\^jk 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r     r   r#   r   c                       e Zd Zd Zy)=StoragePoolSetProtectedMaintenanceModeIOPriorityPolicyHandlerc                    	 |d   dk(  rv|rt|d   o|j                  ||      }|Z|j                  j                  s5|j                  j                  j                  |d   |d   |d   |d   	      }d
|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                  j                  |       Y d }~y d }~ww xY w)Nr   r   r}   r   r(   rh   ri   rj   r   Tr   zNSet Protected Maintenance Mode IO Priority Policy operation failed with error r-   )r   r   rI   r%   r2   1set_protected_maintenance_mode_io_priority_policyr   r   r   r:   r;   r6   r7   r8   r   s          r"   r   zDStoragePoolSetProtectedMaintenanceModeIOPriorityPolicyHandler.handle  s   	57#y0\NO["*"b"b%1$/ #c #K #.'99+3+B+B+O+O  ,B  ,B0<T0B'28'<:EFV:W4?
4K	 ,B ,ML
 6:	2?AHHS^`lm 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r     r   r#   r   c                       e Zd Zd Zy)/StoragePoolModifyCapacityAlertThresholdsHandlerc                    	 |d   dk(  ry|rw|d   r|j                  |||d         }|i k7  rV|j                  j                  s1|j                  j                  j                  |d   |d   |d         }d	|j                  d
<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                  j                  |       Y d }~y d }~ww xY w)Nr   r   r   )r>   r_   r   r(   r   r   )r   cap_alert_high_thresholdcap_alert_critical_thresholdTr   z=Modify Capacity Alert Thresholds operation failed with error r-   )r   r   rI   r%   r2   set_cap_alert_thresholdsr   r   r   r:   r;   r6   r7   r8   )r   r   r_   r>   r   rA   r   s          r"   r   z6StoragePoolModifyCapacityAlertThresholdsHandler.handle  s   	57#y0\56B ( L LZfYdXcQgYi !M !jI !B'99+3+B+B+O+O+h+h0<T0B9B69J=Fz=R ,i ,TL 6:	2IKRRS[]hjvw 	5''*1vh0IIIi OO%%)%44		5s   BB 	C1(?C,,C1Nr   r   r#   r"   r   r     s    5r#   r   c                       e Zd Zd Zy)8StoragePoolModifyRebuildRebalanceParallelismLimitHandlerc                    	 |d   dk(  rl|rj|d   e|d   |d   k7  rZ|j                   j                  s5|j                  j                  j	                  |d   t        |d               }d|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   *numOfParallelRebuildRebalanceJobsPerDevicer(   Tr   zGModify Rebuild/Rebalance Parallelism Limit operation failed with error r-   )r   rI   r%   r2   'set_rebuild_rebalance_parallelism_limitr;   r   r   r   r:   r6   r7   r8   r   r   r_   r>   rA   r   s         r"   r   z?StoragePoolModifyRebuildRebalanceParallelismLimitHandler.handle  s    	57#y0\ABN#$FG<  YE  LF  F#??55'/'>'>'K'K's's(.K@b4c0d(f15HOOI.;=DDX{\hi 	5''*1vh0IIIi OO%%)%44		5   BB 	C$?CC$Nr   r   r#   r"   r   r         5r#   r   c                       e Zd Zd Zy)0StoragePoolModifyRMCacheWriteHandlingModeHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   rmcacheWriteHandlingModer(   Tr   z5Modify RMCache Write Handling Mode failed with error r-   )r   rI   r%   r2   set_rmcache_write_handling_moder   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z7StoragePoolModifyRMCacheWriteHandlingModeHandler.handle  s    	57#y0\<=I#$ABlSmFnn#??55'/'>'>'K'K'k'k(.<Y0Z(\15HOOI.DFMMhXceqr 	5''*1vh0IIIi OO%%)%44		5   BB	 		C?CCNr   r   r#   r"   r   r     r   r#   r   c                       e Zd Zd Zy)'StoragePoolModifySparePercentageHandlerc                    	 |d   dk(  rl|rj|d   e|d   |d   k7  rZ|j                   j                  s5|j                  j                  j	                  |d   t        |d               }d|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   sparePercentager(   Tr   z4Modify Spare Percentage operation failed with error r-   )r   rI   r%   r2   set_spare_percentager;   r   r   r   r:   r6   r7   r8   r   s         r"   r   z.StoragePoolModifySparePercentageHandler.handle  s    	57#y0\12>;OaCbfr  tE  gF  DF#??55'/'>'>'K'K'`'`(.K@R4S0T(V15HOOI.<>EEhP[]ij 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r         5r#   r   c                       e Zd Zd Zy)%StoragePoolEnableFragmentationHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   fragmentationEnabledr(   Tr   z9Enable/Disable Fragmentation operation failed with error r-   )r   rI   r%   r2   set_fragmentation_enabledr   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z,StoragePoolEnableFragmentationHandler.handle,  s    	57#y0\56B{SiGjnz  |R  oS  HS#??55'/'>'>'K'K'e'e(.<R0S(U15HOOI.35<<X{T`a 	5''*1vh0IIIi OO%%)%44	5r   Nr   r   r#   r"   r   r   +  r   r#   r   c                       e Zd Zd Zy)StoragePoolEnableRebuildHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   rebuildEnabledr(   Tr   z3Enable/Disable Rebuild operation failed with error r-   )r   rI   r%   r2   set_rebuild_enabledr   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z&StoragePoolEnableRebuildHandler.handle@  s    	57#y0\/0<M]A^bno  cA  BA#??55'/'>'>'K'K'_'_(.<L0M(O15HOOI.13::8[R^_ 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r   ?  r   r#   r   c                       e Zd Zd Zy)!StoragePoolEnableRebalanceHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   rebalanceEnabledr(   Tr   z+Enable/Disable Rebalance failed with error r-   )r   rI   r%   r2   set_rebalance_enabledr   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z(StoragePoolEnableRebalanceHandler.handleS  s    	57#y0\12>;OaCbfr  tF  gG  DG#??55'/'>'>'K'K'a'a(.<N0O(Q15HOOI.+-44X{LY 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r   R  r   r#   r   c                       e Zd Zd Zy)&StoragePoolModifyRepCapMaxRatioHandlerc                    	 |d   dk(  rl|rj|d   e|d   |d   k7  rZ|j                   j                  s5|j                  j                  j	                  |d   t        |d               }d|j                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   replicationCapacityMaxRatior(   Tr   zBModify Replication Capacity max ratio operation failed with error r-   )r   rI   r%   r2   set_rep_cap_max_ratior;   r   r   r   r:   r6   r7   r8   r   s         r"   r   z-StoragePoolModifyRepCapMaxRatioHandler.handlef  s    	57#y0\23?KPcDdht  vS  iT  ET#??55'/'>'>'K'K'a'a(.K@S4T0U(W15HOOI.-/66xl[ 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r   e  r   r#   r   c                       e Zd Zd Zy)#StoragePoolEnableZeroPaddingHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   r   zeroPaddingEnabledr(   Tr   z8Enable/Disable zero padding operation failed with error r-   )r   rI   r%   r2   set_zero_padding_policyr   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z*StoragePoolEnableZeroPaddingHandler.handley  s    	57#y0\45AkRgFhlx  zN  mO  GO#??55'/'>'>'K'K'c'c(.<Q0R(T15HOOI.24;;HkS_` 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r   x  r   r#   r   c                       e Zd Zd Zy)StoragePoolUseRFCacheHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   rG   
useRfcacher(   Tr   z,Modify RF cache operation failed with error r-   )r   rI   r%   r2   set_use_rfcacher   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z#StoragePoolUseRFCacheHandler.handle  s    	57#y0\}-9k->X\hiu\v>v#??55'/'>'>'K'K'['[(.M0J(L15HOOI./188;P\] 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r   r     r   r#   r   c                       e Zd Zd Zy)StoragePoolUseRMCacheHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d         }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   rH   
useRmcacher(   Tr   z,Modify RM cache operation failed with error r-   )r   rI   r%   r2   set_use_rmcacher   r   r   r:   r;   r6   r7   r8   r   s         r"   r   z#StoragePoolUseRMCacheHandler.handle  s    	57#y0\}-9k->X\hiu\v>v#??55'/'>'>'K'K'['[(.M0J(L15HOOI.(*11(KV 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r  r    r   r#   r  c                       e Zd Zd Zy)StoragePoolRenameHandlerc                    	 |d   dk(  rc|ra|d   \|d   |d   k7  rQ|j                   j                  s,|j                  j                  j	                  |d   |d          d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |	       Y d }~y d }~ww xY w)
Nr   r   rR   r)   r(   Tr   z+Modify storage pool name failed with error r-   )r   rI   r%   r2   renamer   r  r   r:   r;   r6   r7   r8   r   s         r"   r   zStoragePoolRenameHandler.handle  s    	57#y0\67CTkHlp|  ~D  qE  IE#??55 //<<CCLQUDVXcd{X|}15HOOI.(*11(KV 	5''*1vh0IIIi OO%%)%44		5r   Nr   r   r#   r"   r
  r
    s    5r#   r
  c                       e Zd Zd Zy)!StoragePoolModifyMediaTypeHandlerc                    	 |d   dk(  rZ|rX|V||d   k7  rN|j                   j                  s)|j                  j                  j	                  |d   |      }d|j
                  d<   t               j                  |||       y # t        $ rI}dt        |       }t        j                  |       |j                   j                  |       Y d }~y d }~ww xY w)	Nr   r   	mediaTyper(   Tr   z$Modify Media Type failed with error r-   )r   rI   r%   r2   set_media_typer   r
  r   r:   r;   r6   r7   r8   )r   r   r_   r>   rF   rA   r   s          r"   r   z(StoragePoolModifyMediaTypeHandler.handle  s    	57#y0\)jL<U.U#??55'/'>'>'K'K'Z'Z(.
(<15HOOI.$&--h\R 	5''*1vh0IIIi OO%%)%44		5s   A=B   	C	?CCNr   r   r#   r"   r  r    r   r#   r  c                       e Zd Zd Zy)StoragePoolCreateHandlerc                 D   |d   dk(  r||z|j                   j                  sUt        j                  d       |d   r| j                   j	                  d       |j                  |d   |||d   |d	   
      }d|j                  d<   t               j                  ||||       y )Nr   r   zCreating new storage poolr   znstorage_pool_name is missing & name required to create a storage pool. Please enter a valid storage_pool_name.r-   r   rG   rH   )rK   r<   rF   rG   rH   Tr   )	r   rI   r6   infor8   rM   r   r  r   )r   r   r_   r>   r<   rF   s         r"   r   zStoragePoolCreateHandler.handle  s    w9,1E??--4501KK))1 * 2
  (;;)*=>) +M : +M :  <  < *.HOOI&)+228[,Xbcr#   Nr   r   r#   r"   r  r    s    dr#   r  c                       e Zd Zd Zy)StoragePoolHandlerc                    |j                          |d   }|dk(  rd}d }|d   s|d   r|j                  |d   |d         d   }|j                  |d   |d	   |
      }|j                  |       t	               j                  |||||       y )NrF   r   rE   r   r   )r   r   r(   r   r   )r   r   r<   )r>   )rT   r&   rC   rP   r  r   )r   r   r_   rF   r<   r>   s         r"   r   zStoragePoolHandler.handle  s    ))+ .
''J-.+>V2W22%01G%H'23K'L 3 NNRTE  00M^A_CNObCc7< 1 > 	))|)D "))(KuV`ar#   Nr   r   r#   r"   r  r    s    br#   r  c                  t    t               } t               j                  | | j                  j                         y)zh Create PowerFlex storage pool object and perform action on it
        based on user input from playbookN)r   r  r   r   rO   )objs    r"   mainr    s)     
 CSZZ%6%67r#   __main__N)-r   
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   `ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell.libraries.powerflex_baser   _ansible_collections.dellemc.powerflex.plugins.module_utils.storage.dell.libraries.configurationr   Gansible_collections.dellemc.powerflex.plugins.module_utils.storage.dellr	   
get_loggerr6   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r   r   r#   r"   <module>r'     s`   R @ @gRZx^
@ 5 e}%o= od	(NV5 5@ @5 505 565 565 565 545 5(5 5(5 5&5 5(5 5&5 5&5 5&5 5&5 5&5 5&5 5$5 5&d d.b b$8 zF r#   