
    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: add_ldisk
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Create logical disk
description:
   - Create logical disk on ieisystem Server.
notes:
   - Does not support C(check_mode).
options:
    ctrl_id:
        description:
            - Raid controller ID.
            - Required when controller type is LSI, PMC or MV.
        type: int
    level:
        description:
            - RAID Level, 0 - RAID0, 1 - RAID1, 5 - RAID5, 6 - RAID6, 10 - RAID10.
            - Required when controller type is LSI or PMC.
        choices: [0, 1, 5, 6, 10]
        type: int
    size:
        description:
            - Strip Size, 0 - 32k, 1 - 64k, 2 - 128k, 3 - 256k, 4 - 512k, 5 - 1024k.
            - Required when controller type is LSI, PMC or MV.
            - When the controller type is MV, size is [0, 1].
            - When the controller type is LSI or PMC, size is [1, 2, 3, 4, 5].
        choices: [0, 1, 2, 3, 4, 5]
        type: int
    access:
        description:
            - Access Policy, 1 - Read Write, 2 - Read Only, 3 - Blocked.
            - Required when controller type is LSI.
        choices: [1, 2, 3]
        type: int
    r:
        description:
            - Read Policy, 1 - Read Ahead, 2 - No Read Ahead.
            - Required when controller type is LSI.
        choices: [1, 2]
        type: int
    w:
        description:
            - Write Policy, 1 - Write Through, 2 - Write Back, 3 - Write caching ok if bad BBU.
            - Required when controller type is LSI.
        choices: [1, 2, 3]
        type: int
    io:
        description:
            - IO Policy, 1 - Direct IO, 2 - Cached IO.
            - Required when controller type is LSI.
        choices: [1, 2]
        type: int
    cache:
        description:
            - Drive Cache, 1 - Unchanged, 2 - Enabled, 3 - Disabled.
            - Required when controller type is LSI.
        choices: [1, 2, 3]
        type: int
    init:
        description:
            - Init State, 1 - No Init, 2 - Quick Init, 3 - Full Init.
            - Required when controller type is LSI.
        choices: [1, 2, 3]
        type: int
    select:
        description:
            - Select Size, from 1 to 100.
            - Required when controller type is LSI.
        type: int
    slot:
        description:
            - Slot Num, input multiple slotNumber like 0, 1, 2....
            - Required when controller type is LSI or PMC.
        type: list
        elements: int
    accelerator:
        description:
            - Driver accelerator, 1 - 1h, 2 - 2h, 3 - 3h.
            - Required when controller type is PMC.
        choices: [1, 2, 3]
        type: int
    vname:
        description:
            - Virtual drive name.
            - Required when controller type is PMC or server model is M7.
            - Required when controller type is MV.
        type: str
extends_documentation_fragment:
    - ieisystem.inmanage.inmanage
a,  
- name: Add ldisk test
  hosts: inmanage
  connection: local
  gather_facts: false
  vars:
    inmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Add LSI ldisk"
    ieisystem.inmanage.add_ldisk:
      ctrl_id: 0
      level: 1
      size: 1
      access: 1
      r: 1
      w: 1
      io: 1
      cache: 1
      init: 2
      select: 10
      slot: 0,1
      provider: "{{ inmanage }}"

  - name: "Add PMC ldisk"
    ieisystem.inmanage.add_ldisk:
      ctrl_id: 0
      level: 1
      size: 1
      accelerator: 1
      slot: 0,1
      vname: "test"
      provider: "{{ inmanage }}"

  - name: "Add MV ldisk"
    ieisystem.inmanage.add_ldisk:
      ctrl_id: 0
      size: 1
      vname: "test"
      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     p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ieisystem/inmanage/plugins/modules/add_ldisk.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addldisk
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        dd      t        ddg d      t        ddg d      t        ddg d      t        dddd	g      t        ddg d      t        dddd	g      t        ddg d      t        ddg d      t        dd      t        d
dd      t        ddg d      t        dd            } | j                  t               t        |       }|j	                          y )NintF)typerequired)r            
   )r-   r.   choices)r   r/            r0   )r/   r4   r5   r/   r4   list)r-   elementsr.   str)ctrl_idlevelsizeaccessrwiocacheinitselectslotacceleratorvname)r   updater   r
   r'   )r   disk_objs     r   mainrI      s    %%07GHuu6HI	B
EEAq6
:
EE9
=UUQF;yAuui@/v>eeYG.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
   rI   r(   r"   r   r   <module>rS      sX    C B\|,\
 5 y6 :* zF r   