
    Vh                     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 (@ispim)
short_description: Set physical disk
description:
   - Set physical disk on Inspur server.
notes:
   - Does not support C(check_mode).
options:
    info:
        description:
            - Show controller and pdisk info.
        choices: ['show']
        type: str
    ctrl_id:
        description:
            - Raid controller ID.
            - Required when I(Info=None).
        type: int
    device_id:
        description:
            - physical drive id.
            - Required when I(Info=None).
        type: int
    option:
        description:
            - Set operation options fo 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.
            - Required when I(Info=None).
            - 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(Info=None) and 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(Info=None) and 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(Info=None) and 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(Info=None) and 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:
    - inspur.ispim.ism
a  
- name: Edit pdisk test
  hosts: ism
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Show pdisk information"
    inspur.ispim.edit_pdisk:
      info: "show"
      provider: "{{ ism }}"

  - name: "Edit pdisk"
    inspur.ispim.edit_pdisk:
      ctrl_id: 0
      device_id: 1
      option: "LOC"
      provider: "{{ ism }}"

  - name: "M5 Edit pdisk"
    inspur.ispim.edit_pdisk:
      ctrl_id: 0
      device_id: 1
      option: "HS"
      action: "dedicate"
      revertible: "yes"
      encl: "yes"
      logical_drivers: 1
      provider: "{{ ism }}"
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)ism_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     k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/inspur/ispim/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                  p   t        t        dddg      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strFshow)typerequiredchoicesint)r.   r/   )UGUBOFFFAILRBDONJBESEMENETLOCSTLHS)removeglobaldedicateyesnolist)r.   elementsr/   )	infoctrl_id	device_idoptionaction
revertibleencllogical_driversduration)r   updater   r
   r'   )r   disk_objs     r   mainrR      s    uuvh?%%0EE2  9S  T8XYUUUDMJuuudmD&55I551
M *+M"HMMOr   __main__N)
__future__r   r   r   r.   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   9ansible_collections.inspur.ispim.plugins.module_utils.ismr   r   objectr
   rR   r(   r"   r   r   <module>r\      sX    C BL\#J
 5 i6 :" zF r   