
    VhJ                     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mZ  G d de      Zd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona	  
---
module: edit_pdisk
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Set physical disk
description:
   - Set physical disk on ieisystem Server.
notes:
   - Does not support C(check_mode).
options:
    ctrl_id:
        description:
            - Raid controller ID.
        type: int
    device_id:
        description:
            - Physical drive id.
        type: int
    option:
        description:
            - Set operation options for a physical disk.
            - UG is Unconfigured Good, UB is Unconfigured Bad.
            - OFF is offline, FAIL is Failed, RBD is Rebuild.
            - ON is Online, JB is JBOD, ES is Drive Erase stop.
            - EM is Drive Erase Simple, EN is Drive Erase Normal.
            - ET is Drive Erase Through, LOC is Locate, STL is Stop Locate.
            - HS is Hot spare.
            - Only the M5 model supports C(HS) Settings.
        choices: ['UG', 'UB', 'OFF', 'FAIL', 'RBD', 'ON', 'JB', 'ES', 'EM', 'EN', 'ET', 'LOC', 'STL', 'HS']
        type: str
    action:
        description:
            - Action while set physical drive hotspare.
            - Required when I(option=HS).
            - Only the M5 model supports this parameter.
        choices: ['remove', 'global', 'dedicate']
        type: str
    revertible:
        description:
            - IsRevertible while set physical drive hotspare.
            - Required when I(option=HS) and I(action=dedicate).
            - Only the M5 model supports this parameter.
        choices: ['yes', 'no']
        type: str
    encl:
        description:
            - IsEnclAffinity while set physical drive hotspare.
            - Required when I(option=HS) and I(action=dedicate).
            - Only the M5 model supports this parameter.
        choices: ['yes', 'no']
        type: str
    logical_drivers:
        description:
            - Logical Drivers while set physical drive hotspare, input multiple Logical Drivers index like 0, 1, 2.....
            - Required when I(option=HS) and I(action=dedicate).
            - Only the M5 model supports this parameter.
        type: list
        elements: int
    duration:
        description:
            - Duration range is 1-255, physical drive under PMC raid controller.
            - Required when I(option=LOC).
            - Only the M6 model supports this parameter.
        type: int
extends_documentation_fragment:
    - ieisystem.inmanage.inmanage
ab  
- name: Edit pdisk test
  hosts: inmanage
  connection: local
  gather_facts: false
  vars:
    inmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Edit pdisk"
    ieisystem.inmanage.edit_pdisk:
      ctrl_id: 0
      device_id: 1
      option: "LOC"
      provider: "{{ inmanage }}"

  - name: "M5 Edit pdisk"
    ieisystem.inmanage.edit_pdisk:
      ctrl_id: 0
      device_id: 1
      option: "HS"
      action: "dedicate"
      revertible: "yes"
      encl: "yes"
      logical_drivers: 1
      provider: "{{ inmanage }}"
a1  
message:
    description: Messages returned after module execution.
    returned: always
    type: str
state:
    description: Status after module execution.
    returned: always
    type: str
changed:
    description: Check to see if a change was made on the device.
    returned: always
    type: bool
)AnsibleModule)inmanage_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)Diskc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     q/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ieisystem/inmanage/plugins/modules/edit_pdisk.py__init__zDisk.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zDisk.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetpdisk
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzDisk.run_command   sJ    +5<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzDisk.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workz	Disk.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
      s    @+.r   r
   c                  T   t        t        dd      t        dd      t        ddg d      t        ddg d      t        dddd	g      t        dddd	g      t        d
dd      t        dd            } | j                  t               t        |       }|j	                          y )NintF)typerequiredstr)UGUBOFFFAILRBDONJBESEMENETLOCSTLHS)r-   r.   choices)removeglobaldedicateyesnolist)r-   elementsr.   )ctrl_id	device_idoptionaction
revertibleencllogical_driversduration)r   updater   r
   r'   )r   disk_objs     r   mainrP      s    %%0EE2  9S  T8XYUUUDMJuuudmD&55I551	M /0M"HMMOr   __main__N)
__future__r   r   r   r-   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Dansible_collections.ieisystem.inmanage.plugins.module_utils.inmanager   r   objectr
   rP   r(   r"   r   r   <module>rZ      sX    C BDL@
 5 y6 :  zF r   