
    Vhj                         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  ej                  d      Zd	Z G d
 de      Zd Zd Zedk(  r e        yy)z1Ansible module for managing storage pool on Unity    )absolute_importdivisionprint_functiona  
module: storagepool
version_added: '1.1.0'
short_description: Manage storage pool on Unity
description:
- Managing storage pool on Unity storage system contains the operations
  Get details of storage pool,
  Create a storage pool,
  Modify storage pool.

extends_documentation_fragment:
  - dellemc.unity.unity

author:
- Ambuj Dubey (@AmbujDube) <ansible.team@dell.com>

options:
  pool_name:
    description:
    - Name of the storage pool, unique in the storage system.
    type: str

  pool_id:
    description:
    - Unique identifier of the pool instance.
    type: str

  new_pool_name:
    description:
    - New name of the storage pool, unique in the storage system.
    type: str

  pool_description:
    description:
    - The description of the storage pool.
    type: str

  fast_cache:
    description:
    - Indicates whether the fast cache is enabled for the storage pool.
    - C(Enabled) - FAST Cache is enabled for the pool.
    - C(Disabled) - FAST Cache is disabled for the pool.
    choices: [enabled, disabled]
    type: str

  fast_vp:
    description:
    - Indicates whether to enable scheduled data relocations for the pool.
    - C(Enabled) - Enabled scheduled data relocations for the pool.
    - C(Disabled) - Disabled scheduled data relocations for the pool.
    choices: [enabled, disabled]
    type: str

  raid_groups:
    description:
    - Parameters to create RAID group from the disks and add it to the pool.
    type: dict
    suboptions:
      disk_group_id:
        description:
        - Id of the disk group.
        type: str

      disk_num:
        description:
        - Number of disks.
        type: int

      raid_type:
        description:
        - RAID group types or RAID levels.
        choices: [None, RAID5, RAID0, RAID1, RAID3, RAID10, RAID6, Mixed, Automatic]
        type: str

      stripe_width :
        description:
        - RAID group stripe widths, including parity or mirror disks.
        choices: ['BEST_FIT', '2', '4', '5', '6', '8', '9', '10', '12', '13', '14', '16']
        type: str

  alert_threshold:
    description:
    - Threshold at which the system will generate alerts about the free space in the pool, specified as a percentage.
    - Minimum threshold limit is 50.
    - Maximum threshold limit is 84.
    type: int

  is_harvest_enabled:
    description:
    - Enable/Disable automatic deletion of snapshots based on pool space usage.
    type: bool

  pool_harvest_high_threshold:
    description:
    - Max threshold for space used in pool beyond which the system automatically starts deleting snapshots in the pool.
    - Applies when the automatic deletion of snapshots based on pool space usage is enabled for the system and pool.
    - Minimum pool harvest high threshold value is 1.
    - Maximum pool harvest high threshold value is 99.
    type: float

  pool_harvest_low_threshold:
    description:
    - Min threshold for space used in pool below which the system automatically stops deletion of snapshots in the pool.
    - Applies when the automatic deletion of snapshots based on pool space usage is enabled for the system and pool.
    - Minimum pool harvest low threshold value is 0.
    - Maximum pool harvest low threshold value is 98.
    type: float

  is_snap_harvest_enabled:
    description:
    - Enable/Disable automatic deletion of snapshots based on pool space usage.
    type: bool

  snap_harvest_high_threshold:
    description:
    - Max threshold for space used in snapshot beyond which the system automatically starts deleting snapshots in the pool.
    - Applies when the automatic deletion of snapshots based on pool space usage is enabled for the pool.
    - Minimum snap harvest high threshold value is 1.
    - Maximum snap harvest high threshold value is 99.
    type: float

  snap_harvest_low_threshold:
    description:
    - Min threshold for space used in snapshot below which the system will stop automatically deleting snapshots in the pool.
    - Applies when the automatic deletion of snapshots based on pool space usage is enabled for the pool.
    - Minimum snap harvest low threshold value is 0.
    - Maximum snap harvest low threshold value is 98.
    type: float

  pool_type:
    description:
    - Indicates storage pool type.
    choices: [TRADITIONAL, DYNAMIC]
    type: str

  state:
    description:
    - Define whether the storage pool should exist or not.
    - C(Present) - indicates that the storage pool should exist on the system.
    - C(Absent) - indicates that the storage pool should not exist on the system.
    choices: [absent, present]
    type: str
    required: true

notes:
- Deletion of storage pool is not allowed through Ansible module.
- The I(check_mode) is not supported.
a.  
- name: Get Storage pool details using pool_name
  dellemc.unity.storagepool:
    unispherehost: "{{unispherehost}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    pool_name: "{{pool_name}}"
    state: "present"

- name: Get Storage pool details using pool_id
  dellemc.unity.storagepool:
    unispherehost: "{{unispherehost}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    pool_id: "{{pool_id}}"
    state: "present"

- name: Modify Storage pool attributes using pool_name
  dellemc.unity.storagepool:
    unispherehost: "{{unispherehost}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    pool_name: "{{pool_name}}"
    new_pool_name: "{{new_pool_name}}"
    pool_description: "{{pool_description}}"
    fast_cache: "{{fast_cache_enabled}}"
    fast_vp: "{{fast_vp_enabled}}"
    state: "present"

- name: Modify Storage pool attributes using pool_id
  dellemc.unity.storagepool:
    unispherehost: "{{unispherehost}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    pool_id: "{{pool_id}}"
    new_pool_name: "{{new_pool_name}}"
    pool_description: "{{pool_description}}"
    fast_cache: "{{fast_cache_enabled}}"
    fast_vp: "{{fast_vp_enabled}}"
    state: "present"

- name: Create a StoragePool
  dellemc.unity.storagepool:
    unispherehost: "{{unispherehost}}"
    username: "{{username}}"
    password: "{{password}}"
    validate_certs: "{{validate_certs}}"
    pool_name: "Test"
    pool_description: "test pool"
    raid_groups:
      disk_group_id: "dg_16"
      disk_num: 2
      raid_type: "RAID10"
      stripe_width: "BEST_FIT"
    alert_threshold: 50
    is_harvest_enabled: true
    pool_harvest_high_threshold: 60
    pool_harvest_low_threshold: 40
    is_snap_harvest_enabled: true
    snap_harvest_high_threshold: 70
    snap_harvest_low_threshold: 50
    fast_vp: "enabled"
    fast_cache: "enabled"
    pool_type: "DYNAMIC"
    state: "present"
a  
 changed:
    description: Whether or not the storage pool has changed.
    returned: always
    type: bool
    sample: true

 storage_pool_details:
    description: The storage pool details.
    returned: When storage pool exists.
    type: dict
    contains:
        id:
            description: Pool id, unique identifier of the pool.
            type: str
        name:
            description: Pool name, unique in the storage system.
            type: str
        is_fast_cache_enabled:
            description: Indicates whether the fast cache is enabled for the storage
                         pool.
                         true - FAST Cache is enabled for the pool.
                         false - FAST Cache is disabled for the pool.
            type: bool
        is_fast_vp_enabled:
            description: Indicates whether to enable scheduled data relocations
                         for the storage pool.
                         true - Enabled scheduled data relocations for the pool.
                         false - Disabled scheduled data relocations for the pool.
            type: bool
        size_free_with_unit:
            description: Indicates size_free with its appropriate unit
                         in human readable form.
            type: str
        size_subscribed_with_unit:
            description: Indicates size_subscribed with its appropriate unit in
                         human readable form.
            type: str
        size_total_with_unit:
            description: Indicates size_total with its appropriate unit in human
                         readable form.
            type: str
        size_used_with_unit:
            description: Indicates size_used with its appropriate unit in human
                         readable form.
            type: str
        snap_size_subscribed_with_unit:
            description: Indicates snap_size_subscribed with its
                         appropriate unit in human readable form.
            type: str
        snap_size_used_with_unit:
            description: Indicates snap_size_used with its
                         appropriate unit in human readable form.
            type: str
        drives:
            description: Indicates information about the drives
                         associated with the storage pool.
            type: list
            contains:
                id:
                    description: Unique identifier of the drive.
                    type: str
                name:
                    description: Indicates name of the drive.
                    type: str
                size:
                    description: Indicates size of the drive.
                    type: str
                disk_technology:
                    description: Indicates disk technology of the drive.
                    type: str
                tier_type:
                    description: Indicates tier type of the drive.
                    type: str
    sample: {
        "alert_threshold": 50,
        "creation_time": "2022-03-08 14:05:32+00:00",
        "description": "",
        "drives": [
            {
                "disk_technology": "SAS",
                "id": "dpe_disk_22",
                "name": "DPE Drive 22",
                "size": 590860984320,
                "tier_type": "PERFORMANCE"
            },
            {
                "disk_technology": "SAS",
                "id": "dpe_disk_23",
                "name": "DPE Drive 23",
                "size": 590860984320,
                "tier_type": "PERFORMANCE"
            },
            {
                "disk_technology": "SAS",
                "id": "dpe_disk_24",
                "name": "DPE Drive 24",
                "size": 590860984320,
                "tier_type": "PERFORMANCE"
            }
        ],
        "existed": true,
        "harvest_state": "UsageHarvestStateEnum.IDLE",
        "hash": 8744642897210,
        "health": {
            "UnityHealth": {
                "hash": 8744642799842
            }
        },
        "id": "pool_280",
        "is_all_flash": false,
        "is_empty": false,
        "is_fast_cache_enabled": false,
        "is_fast_vp_enabled": false,
        "is_harvest_enabled": true,
        "is_snap_harvest_enabled": true,
        "metadata_size_subscribed": 105763569664,
        "metadata_size_used": 57176752128,
        "name": "test_pool",
        "object_id": 12884902146,
        "pool_fast_vp": {
            "UnityPoolFastVp": {
                "hash": 8744647518980
            }
        },
        "pool_space_harvest_high_threshold": 59.0,
        "pool_space_harvest_low_threshold": 40.0,
        "pool_type": "StoragePoolTypeEnum.DYNAMIC",
        "raid_type": "RaidTypeEnum.RAID10",
        "rebalance_progress": null,
        "size_free": 470030483456,
        "size_free_with_unit": "437.75 GB",
        "size_subscribed": 447215820800,
        "size_subscribed_with_unit": "416.5 GB",
        "size_total": 574720311296,
        "size_total_with_unit": "535.25 GB",
        "size_used": 76838068224,
        "size_used_with_unit": "71.56 GB",
        "snap_size_subscribed": 128851369984,
        "snap_size_subscribed_with_unit": "120.0 GB",
        "snap_size_used": 2351104,
        "snap_size_used_with_unit": "2.24 MB",
        "snap_space_harvest_high_threshold": 80.0,
        "snap_space_harvest_low_threshold": 60.0,
        "tiers": {
            "UnityPoolTierList": [
                {
                    "disk_count": [
                        0,
                        3,
                        0
                    ],
                    "existed": true,
                    "hash": 8744643017382,
                    "name": [
                        "Extreme Performance",
                        "Performance",
                        "Capacity"
                    ],
                    "pool_units": [
                        null,
                        {
                            "UnityPoolUnitList": [
                                {
                                    "UnityPoolUnit": {
                                        "hash": 8744642786759,
                                        "id": "rg_4"
                                    }
                                },
                                {
                                    "UnityPoolUnit": {
                                        "hash": 8744642786795,
                                        "id": "rg_5"
                                    }
                                }
                            ]
                        },
                        null
                    ],
                    "raid_type": [
                        "RaidTypeEnum.NONE",
                        "RaidTypeEnum.RAID10",
                        "RaidTypeEnum.NONE"
                    ],
                    "size_free": [
                        0,
                        470030483456,
                        0
                    ],
                    "size_moving_down": [
                        0,
                        0,
                        0
                    ],
                    "size_moving_up": [
                        0,
                        0,
                        0
                    ],
                    "size_moving_within": [
                        0,
                        0,
                        0
                    ],
                    "size_total": [
                        0,
                        574720311296,
                        0
                    ],
                    "size_used": [
                        0,
                        104689827840,
                        0
                    ],
                    "stripe_width": [
                        null,
                        "RaidStripeWidthEnum._2",
                        null
                    ],
                    "tier_type": [
                        "TierTypeEnum.EXTREME_PERFORMANCE",
                        "TierTypeEnum.PERFORMANCE",
                        "TierTypeEnum.CAPACITY"
                    ]
                }
            ]
        }
    }

)AnsibleModule)utilsstoragepoolzAnsible/1.7.1c                   h    e Zd ZdZd ZddZd Zd ZddZd Z	d	 Z
d
 Zd Z	 	 	 	 	 ddZd Zd Zy)StoragePoolz"Class with storage pool operationsc                 p   t        j                         | _        | j                  j                  t	                      ddgg}ddgg}t        | j                  d||      | _        t        j                  | j                         t        j                  | j                  j                  t              | _        y)z. Define all parameters required by this module	pool_namepool_idF)argument_specsupports_check_modemutually_exclusiverequired_one_ofN)r   $get_unity_management_host_parametersmodule_paramsupdateget_storagepool_parametersr   moduleensure_required_libsget_unity_unisphere_connectionparamsapplication_typeconn)selfr   r   s      m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/dellemc/unity/plugins/modules/storagepool.py__init__zStoragePool.__init__  s    "GGI!!"<">?*I67'34 $$2D2D8=7I4CE 	""4;;/**4;;+=+=?OQ	    Nc                 x   	 | j                   j                  ||      }|j                         }|j                  d      }|r|j                  }||d<   t        j                  t        |d               |d<   t        j                  t        |d               |d<   t        j                  t        |d               |d	<   t        j                  t        |d
               |d<   t        j                  t        |d               |d<   t        j                  t        |d               |d<   t
        j                  j                  | j                   j                  |d         }g }|j                  |j                  j                                i }||d<   ||d<   |S # t        $ r}	t        |	      ddg}
t        fd|
D              rd}t         j#                  |       Y d}	~	ydj%                  t        |	            }t         j'                  |       | j(                  j+                  |       Y d}	~	yd}	~	ww xY w)z Get storage pool details)_idnamepool_fast_vpis_fast_vp_enabled	size_freesize_free_with_unitsize_subscribedsize_subscribed_with_unit
size_totalsize_total_with_unit	size_usedsize_used_with_unitsnap_size_subscribedsnap_size_subscribed_with_unitsnap_size_usedsnap_size_used_with_unitidUnityPoolTierListtiersz	not foundzno attributec              3   &   K   | ]  }|v  
 y w)N ).0eleerrors     r   	<genexpr>z*StoragePool.get_details.<locals>.<genexpr>  s     6C3%<6s   zpool details are not foundNz2Get details of storage pool failed with error: {0}msg)r   get_pool_get_properties_get_property_from_rawis_schedule_enabledr   convert_size_with_unitint	UnityPoolget_cliappendr3   	ExceptionstranyLOGinfoformatr8   r   	fail_json)r   r   r   api_responsedetailsr$   pool_instancepool_tier_listpool_tier_dicte
check_listerror_messager8   s               @r   get_detailszStoragePool.get_details  s!   -	599--'	-JL"224G!-!D!D" !%7%K%K",>G()-2&&s7;+?'@.BG)* 49&&s73D+E'F4HG/0 /4&&s7<+@'A/CG*+ .3&&s7;+?'@.BG)* 9>&&s73I+J'K9MG45 38&&s73C+D'E3GG./ "OO//		NMN!!=#6#6"G"G"IJN2@N./-GGN 
	5FE%~6J6:66 <'))/A IIm$KK!!m!44
	5s   FF 	H9%:H4$AH44H9c                 F   	 | j                   j                  d   r | j                   j                  d   |d   k7  ry| j                   j                  d    | j                   j                  d   |d   k7  ry| j                   j                  d   rC| j                   j                  d   dk(  r|d	   r!| j                   j                  d   d
k(  r|d	   ry| j                   j                  d   rC| j                   j                  d   dk(  r|d   r!| j                   j                  d   d
k(  r|d   ryt        j                  d       y# t        $ rU}dj                  t        |            }t        j                  |       | j                   j                  |       Y d}~yd}~ww xY w)zB Check if attributes of storage pool needs to be modified
        new_pool_namer"   Tpool_descriptionNdescription
fast_cacheenabledis_fast_cache_enableddisabledfast_vpr$   zmodify not requiredFzSFailed to determine if any modificationrequired for pool attributes with error: {0}r:   )	r   r   rI   rJ   rF   rK   rG   r8   rL   )r   storage_pool_detailsrR   rT   s       r   is_pool_modification_requiredz)StoragePool.is_pool_modification_required  sy   	5{{!!/2KK&&7(01{{!!"45AKK&&'9:(78{{!!,/KK&&|4	A,-DEKK&&|4
BG[\sGt{{!!),KK&&y1Y>,-AB[[''	2j@,-ABHH*+ 	5??Evc!f~ IIm$KK!!m!44		5s1   8E 8E 4AE AE ,E 	F AFF c                 F   t         j                  j                  | j                  j                  |      }	 |j                  ||||       | j                  |d      }t        j                  d       |S # t        $ r}| j                  j                  d   r| j                  j                  d   }	n| j                  j                  d   }	dj                  |	t        |            }
t        j                  |
       | j                  j                  |
       Y d}~yd}~ww xY w)	z# Modify attributes of storage pool )r"   rY   r\   is_fastvp_enabledNr   r   zModification Successfulr   r   z<Modify attributes of storage pool {0} failed with error: {1}r:   )r   rB   rC   r   rD   modifyrU   rI   rJ   rF   r   r   rK   rG   r8   rL   )r   r1   rW   rX   rZ   r^   pool_objnew_storage_pool_detailsrR   pool_identifierrT   s              r   pool_modifyzStoragePool.pool_modifyB  s     ??&&tyy~~r:	5OO<L2<.5  7 (,'7'7BF (8 (H$HH./++ 	5{{!!),"&++"4"4Y"?"&++"4"4["A))/Q)H IIm$KK!!m!44	5s   >A5 5	D >BDD c                    |xs |}g }	 t         j                  j                  | j                  j                        }|r|D ]  }|j
                  s|j
                  j                  |k(  s|j
                  j                  |k(  sC|j                  |j                  |j                  |j                  j                  |j                  j                  d}|j                  |        t        j                  d       |S # t        $ rU}dj                  t!        |            }	t        j#                  |	       | j$                  j'                  |	       Y d}~yd}~ww xY w)z! Get pool drives attached to pool)r1   r"   sizedisk_technology	tier_typez)Successfully retrieved pool drive detailsz1Get details of pool drives failed with error: {0}r:   N)r   UnityDiskListrC   r   rD   poolr1   r"   rj   rk   rl   rE   rI   rJ   rF   rK   rG   r8   r   rL   )
r   r   r   rg   pool_drives_listdrive_instancesdrive
pool_driverR   rT   s
             r   get_pool_driveszStoragePool.get_pool_drivesX  s   !.Y	5#1155diinnEO, <Ezzuzz}}'G5::??^mKm,1HHejjRWR\R\9>9N9N9S9S38??3G3G&I
 )//
;< HH@A## 	5))/A IIm$KK!!m!44		5s&   AC< 2C< A7C< <	EAEEc                     |t         j                  j                  v rt         j                  |   S d|z  }t        j	                  |       | j
                  j                  |       y)zo Get raid_type_enum.
             :param raid_type: The raid_type
             :return: raid_type enum
        zInvalid choice %s for Raid Typer:   N)r   RaidTypeEnum__members__rI   r8   r   rL   )r   	raid_typeerrormsgs      r   get_raid_type_enumzStoragePool.get_raid_type_enumm  sT     **666%%i0089DHIIhKK!!h!/r   c                     |dk7  rd|z   }|t         j                  j                  v rt         j                  |   S d|z  }t        j	                  |       | j
                  j                  |       y)z Get raid_stripe_width enum.
             :param stripe_width: The raid_stripe_width
             :return: raid_stripe_width enum
        BEST_FIT_z"Invalid choice %s for stripe widthr:   N)r   RaidStripeWidthEnumrv   rI   r8   r   rL   )r   stripe_widthrx   s      r   get_raid_stripe_width_enumz&StoragePool.get_raid_stripe_width_enumz  sf    
 :%-L544@@@,,\::;lJHIIhKK!!h!/r   c                     |dk(  ry|dk(  ryd|z  }t         j                  |       | j                  j                  |       y)z{ Get the storage pool_type enum.
             :param pool_type: The pool_type
             :return: pool_type enum
        TRADITIONAL   DYNAMIC   z'Invalid choice %s for Storage Pool Typer:   NrI   r8   r   rL   )r   	pool_typerx   s      r   get_pool_type_enumzStoragePool.get_pool_type_enum  sE     %)#@9LHIIhKK!!h!/r   c                    	 t         j                  j                  | j                  j                  |d         }|d   }|d   }|r| j                  |      nd}|d   }|r| j                  |      nd}t        j                  ||||      }|g}|S # t        $ rI}dt        |      z  }t        j                  |       | j                  j                  |	       Y d}~yd}~ww xY w)
z& Get the raid groups for creating pooldisk_group_id)r!   disk_numrw   Nr~   )
disk_groupr   rw   r~   ,Failed to create storage pool with error: %sr:   )r   UnityDiskGrouprC   r   rD   ry   r   RaidGroupParameterrF   rG   rI   r8   r   rL   )	r   raid_groupsdisk_objr   rw   r~   
raid_grouprR   rT   s	            r   get_raid_groupszStoragePool.get_raid_groups  s    	5++//		KP_D`/aH":.H#K0I //	:"& &~6L  ::<H%) 11X;Cy?KMJ &,K 	5JSQRVSMIIm$KK!!m!44	5s   BB 	C#?CC#c                 ~   |r=|dk  s|dkD  r3d}t         j                  |       | j                  j                  |       |r=|dk  s|dkD  r3d}t         j                  |       | j                  j                  |       |r=|dk  s|d	kD  r3d
}t         j                  |       | j                  j                  |       |r=|dk  s|dkD  r3d}t         j                  |       | j                  j                  |       |r?|dk  s|d	kD  r4d}t         j                  |       | j                  j                  |       yyy)z# Validates params for creating pool2   T   z<Alert threshold is not in the allowed value range of 50 - 84r:   r   c   zGPool harvest high threshold is not in the allowed value range of 1 - 99r   b   zFPool harvest low threshold is not in the allowed value range of 0 - 98zGSnap harvest high threshold is not in the allowed value range of 1 - 99zFSnap harvest low threshold is not in the allowed value range of 0 - 98Nr   )r   alert_thresholdpool_harvest_high_thresholdpool_harvest_low_thresholdsnap_harvest_high_thresholdsnap_harvest_low_thresholdrx   s          r   validate_create_pool_paramsz'StoragePool.validate_create_pool_params  s-    " 4"8LUHIIhKK!!h!/&,G!,KOjmoOo`HIIhKK!!h!/%+E+IMgjlMl_HIIhKK!!h!/&,G!,KOjmoOo`HIIhKK!!h!/%+E+IMgjlMl_HIIhKK!!h!/ Nm%r   c                 v   	 t         j                  j                  | j                  j                        }| j
                  j                  d   }|r| j                  |      nd}| j
                  j                  d   }d}d}d}d}	| j
                  j                  d   }
|
r2| j
                  j                  d   }| j
                  j                  d   }| j
                  j                  d   }|r2| j
                  j                  d   }| j
                  j                  d	   }	| j                  |||||	
       | j
                  j                  d   }|r| j                  |      nd}| j
                  j                  d   }|r
|dk(  rd}nd}|j                  | j                  j                  |||||
|||||	||       t        j                  d       | j                  |      }d}||fS # t        $ rI}dt        |      z  }t        j!                  |       | j
                  j#                  |       Y d}~yd}~ww xY w)z Creates a StoragePoolrX   Nr   is_harvest_enabledr   r   is_snap_harvest_enabledr   r   )r   r   r   r   r   r   r^   r[   TF)r"   rY   r   r   r   r   r   r   r   r   rb   r   z#Creation of storage pool successful)r   r   r:   )r   rB   rC   r   rD   r   r   r   r   r   createrI   rJ   rU   rF   rG   r8   rL   )r   r"   r   re   rX   r   r   r   r   r   r   r   r   r^   r_   changedrR   rT   s                     r   create_poolzStoragePool.create_pool  s<   2	5**499>>:H#{{112DE ..{;$( "kk001BCO*.')-&*.')-&!%!3!34H!I!.2kk.@.@A^._+-1[[-?-?@\-]*&*kk&8&89R&S#&.2kk.@.@A^._+-1[[-?-?@\-]*,,_IdHbIdHb	 - d
 **;7I //	:"& kk((3Gi'"G#GOODIINNCSal,;/A4K8S7Q8S7Q.5&/  	1 HH:;#'#3#3d#3#C G000 	5JSQRVSMIIm$KK!!m!44	5s   G#G& &	H8/?H33H8c                    | j                   j                  d   }| j                   j                  d   }| j                   j                  d   }| j                   j                  d   }| j                   j                  d   }| j                   j                  d   }| j                   j                  d   }| j                   j                  d   }|r
|d	k(  rd
}nd}|r
|d	k(  rd
}nd}t        di       }	| j                  ||      }
|
|	d<   |dk(  r5|
r3d}t        j                  |       | j                   j                  |       |dk(  rd|
sb|-t        |      dk7  r| j                  ||      \  |	d<   }
|
|	d<   n3d}t        j                  |       | j                   j                  |       |	d   r| j                  ||      |	d   d<   |dk(  r|
r|At        |      dk(  r3d}t        j                  |       | j                   j                  |       | j                  |
      }t        j                  dt        |             |r | j                  |
d   ||||      |	d<   d
|	d<    | j                   j                  di |	 y)zq
        Perform different actions on storage pool module based on parameters
        chosen in playbook
        r   r   rW   rX   rZ   r^   stater   r[   TF)r   r_   r_   absentz>Deletion of storage pool is not allowed through Ansible moduler:   presentNr   )r"   r   r   zIThe parameter pool_name length is 0. It is too short. The min length is 1rc   driveszMThe parameter new_pool_name length is 0. It is too short. The min length is 1z!Storage pool modification flag %sr1   r5   )r   r   dictrU   rI   r8   rL   lenr   rs   r`   rJ   rG   rh   	exit_json)r   r   r   rW   rX   rZ   r^   r   r   resultr_   rT   pool_modify_flags                r   perform_module_operationz$StoragePool.perform_module_operation  s   
 KK&&{3	++$$Y/**?;;;--.@A[[''5
++$$Y/""7+kk((7Y&!
"
)# !#

  $//C)=%&H!5.MIIm$KK!!m!4 I&:$Y1)<&&I;&O 8y!#71E-.!E		-(%%-%8 ()7;7K7KT[gp7K7qF)*84I"6(S-?1-D!E		-(%%-%8#--.BC HH8)*,  $$%9$%?%5z7L -. %)y!''r   )NN)NNNNN)__name__
__module____qualname____doc__r   rU   r`   rh   rs   ry   r   r   r   r   r   r   r5   r   r   r
   r
     sW    ,Q$/5b"5H5,5*0005* ;?@D?C@D?C	0645lH(r   r
   c                  l   t        d$i dt        dd      dt        dd      dt        dd      dt        dd      dt        ddd	d
g      dt        ddd	d
g      dt        ddddg      dt        ddt        t        dd      t        dd      t        ddg d      t        ddg d                  dt        dd      dt        dd      dt        dd      dt        dd      dt        dd      dt        dd      d t        dd      d!t        ddd"d#g      S )%z\This method provides parameters required for the ansible storage pool
       module on Unityr   FrG   )requiredtyper   rW   rX   rZ   r[   r]   )r   r   choicesr^   r   Tr   r   r   r   rA   )	NoneRAID5RAID0RAID1RAID3RAID10RAID6Mixed	Automatic)r{   2456891012131416)r   r   rw   r~   )r   r   optionsr   r   boolr   floatr   r   r   r   r   r   r   r5   )r   r5   r   r   r   r   H  s     E2e%0 E6 u59	
 UY=G=I J e%):D:F G Duy(6KL %fdE:5u5E @_ `u5 Cp q?r s" e%8#$  V<%& %)%g$F'( $(W#E)* !%e& A+, %)%g$F-. $(W#E/0 EM9;UV1 r   c                  8    t               } | j                          y)zd Create Unity storage pool object and perform action on it
        based on user input from playbookN)r
   r   )objs    r   mainr   g  s     -C  "r   __main__N)r   
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Cansible_collections.dellemc.unity.plugins.module_utils.storage.dellr   
get_loggerrI   r   objectr
   r   r   r   r5   r   r   <module>r      s    8 @ @SjENe
N 5 e}%" m(& m(`># zF r   