
    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_functionaA  
---
module: edit_kvm
version_added: "1.0.0"
author:
    - WangBaoshan (@ispim)
short_description: Set KVM
description:
   - Set KVM on Inspur server.
notes:
   - Does not support C(check_mode).
options:
    client_type:
        description:
            - Client Type.
            - Only the M6 model supports this parameter.
        choices: ['vnc', 'viewer']
        type: str
    kvm_encryption:
        description:
            - Encrypt KVM packets.
        choices: ['enable', 'disable']
        type: str
    media_attach:
        description:
            - Two types of VM attach mode are available.
            - Attach is Immediately attaches Virtual Media to the server upon bootup.
            - Auto is Attaches Virtual Media to the server only when a virtual media session is started.
            - Only the M5 model supports this parameter.
        choices: ['attach', 'auto']
        type: str
    keyboard_language:
        description:
            - Select the Keyboard Language.
            - AD is Auto Detect, DA is Danish, NL-BE is Dutch Belgium, NL-NL is Dutch Netherland,
            - GB is English UK ,US is English US, FI is Finnish, FR-BE is French Belgium, FR is French France,
            - DE is German Germany, DE-CH is German Switzerland, IT is Italian, JP is Japanese,
            - NO is Norwegian, PT is Portuguese, ES is Spanish, SV is Swedish, TR_F is Turkish F, TR_Q is Turkish Q.
        choices: ['AD', 'DA', 'NL-BE', 'NL-NL', 'GB', 'US', 'FI', 'FR-BE', 'FR', 'DE', 'DE-CH', 'IT', 'JP', 'ON', 'PT', 'EC', 'SV', 'TR_F','TR_Q']
        type: str
    retry_count:
        description:
            - Number of times to be retried in case a KVM failure occurs.Retry count ranges from 1 to 20.
            - Only the M5 model supports this parameter.
        type: int
    retry_time_interval:
        description:
            - The Identification for retry time interval configuration (5-30) seconds.
            - Only the M5 model supports this parameter.
        type: int
    local_monitor_off:
        description:
            - Server Monitor OFF Feature Status.
        choices: ['enable', 'disable']
        type: str
    automatic_off:
        description:
            - Automatically OFF Server Monitor, When KVM Launches.
        choices: ['enable', 'disable']
        type: str
    non_secure:
        description:
            - Enable/disable Non Secure Connection Type.
            - Only the M6 model supports this parameter.
            - Required when I(client_type=vnc).
        choices: ['enable', 'disable']
        type: str
    ssh_vnc:
        description:
            - Enable/disable VNC over SSH in BMC.
            - Only the M6 model supports this parameter.
            - Required when I(client_type=vnc).
        choices: ['enable', 'disable']
        type: str
    stunnel_vnc:
        description:
            - Enable/disable VNC over Stunnel in BMC.
            - Only the M6 model supports this parameter.
            - Required when I(client_type=vnc).
        choices: ['enable', 'disable']
        type: str
extends_documentation_fragment:
    - inspur.ispim.ism
a  
- name: KVM test
  hosts: ism
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set KVM"
    inspur.ispim.edit_kvm:
      kvm_encryption: "enable"
      media_attach: "auto"
      keyboard_language: "AD"
      retry_count: 13
      retry_time_interval: 10
      local_monitor_off: "enable"
      automatic_off: "enable"
      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)KVMc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/inspur/ispim/plugins/modules/edit_kvm.py__init__zKVM.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zKVM.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetkvm
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzKVM.run_command   sJ    +3<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzKVM.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzKVM.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ddg      t        ddddg      t        dddd	g      t        ddg d
      t        dd      t        dd      t        ddddg      t        ddddg      t        ddddg      t        ddddg      t        ddddg            } | j                  t               t        |       }|j	                          y )NstrFvncviewer)typerequiredchoicesenabledisableattachauto)ADDAzNL-BEzNL-NLGBUSFIzFR-BEFRDEzDE-CHITJPONPTECSVTR_FTR_Qint)r/   r0   )client_typekvm_encryptionmedia_attachkeyboard_languageretry_countretry_time_intervallocal_monitor_offautomatic_off
non_securessh_vncstunnel_vnc)r   updater   r
   r'   )r   kvm_objs     r   mainrS      s    eeeX=NO9@UVuux>PQEE(kl ee4 ee<EEHiCXY)?TUUUXy<QR%%(I9NOeeh	=RSM *+- GLLNr   __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
   rS   r(   r"   r   r   <module>r]      sW    C BSj2
 5 i& :* zF r   