
    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_fan
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Set fan information
description:
   - Set fan information on kaytus Server.
notes:
   - Does not support C(check_mode).
options:
    mode:
        description:
            - Control mode, Manual or Automatic , Manual must be used with fans_peed.
        choices: ['Automatic', 'Manual']
        type: str
    id:
        description:
            - Fan id 255 is for all fans, 0~n.
        type: int
    fan_speed:
        description:
            - Fan speed (duty ratio), range in 1 - 100.
        type: int
extends_documentation_fragment:
    - kaytus.ksmanage.ksmanage
a  
- name: Fan test
  hosts: ksmanage
  connection: local
  gather_facts: false
  vars:
    ksmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set fan information"
    kaytus.ksmanage.edit_fan:
      mode: "Automatic"
      provider: "{{ ksmanage }}"

  - name: "Set fan information"
    kaytus.ksmanage.edit_fan:
      mode: "Manual"
      id: 1
      fan_speed: 80
      provider: "{{ ksmanage }}"
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)ksmanage_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)Fanc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/kaytus/ksmanage/plugins/modules/edit_fan.py__init__zFan.__init__V   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zFan.init_module\   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )N
fancontrol
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzFan.run_commandb   sJ    +7<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzFan.show_resulth   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzFan.workl   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
   U   s    @+.r   r
   c                      t        t        ddddg      t        dd      t        dd            } | j                  t               t        |       }|j	                          y )	NstrF	AutomaticManual)typerequiredchoicesint)r/   r0   )modeid	fan_speed)r   updater   r
   r'   )r   fan_objs     r   mainr8   r   sU    uu{H6MNUU+EE2M
 /0- GLLNr   __main__N)
__future__r   r   r   r/   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Aansible_collections.kaytus.ksmanage.plugins.module_utils.ksmanager   r   objectr
   r8   r(   r"   r   r   <module>rB      sU    C B:4
 5 v& : zF r   