
    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_service
version_added: "1.0.0"
author:
    - WangBaoshan (@ispim)
short_description: Set service settings
description:
   - Set service settings on Inspur server.
notes:
   - Does not support C(check_mode).
options:
    service_name:
        description:
            - Displays service name of the selected slot(readonly).
            - The I(vnc) option is not supported in M5.
            - The I(fd-media/telnet/snmp) option is not supported in M6.
        choices: ['web', 'kvm', 'cd-media', 'fd-media', 'hd-media', 'ssh', 'telnet', 'solssh', 'snmp', 'vnc']
        type: str
        required: true
    state:
        description:
            - Displays the current status of the service, either active or inactive state.
            - Check this option to start the inactive service.
        choices: ['active', 'inactive']
        type: str
    interface:
        description:
            - It shows the interface in which service is running.
            - The user can choose any one of the available interfaces.
            - Only the M5 model supports this parameter.
        choices: ['eth0', 'eth1', 'both', 'bond0']
        type: str
    non_secure_port:
        description:
            - Used to configure non secure port number for the service.
            - Port value ranges from 1 to 65535.
        type: int
    secure_port:
        description:
            - Used to configure secure port number for the service.
            - Port value ranges from 1 to 65535.
        type: int
    timeout:
        description:
            - Displays the session timeout value of the service.
            - For web, SSH and telnet service, user can configure the session timeout value.
            - Web timeout value ranges from 300 to 1800 seconds.
            - SSH and Telnet timeout value ranges from 60 to 1800 seconds.
            - timeout value should be in multiples of 60 seconds.
        type: int
extends_documentation_fragment:
    - inspur.ispim.ism
ah  
- name: Edit service test
  hosts: ism
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Edit kvm"
    inspur.ispim.edit_service:
      service_name: "kvm"
      state: "active"
      timeout: "1200"
      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)Servicec                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/inspur/ispim/plugins/modules/edit_service.py__init__zService.__init__k   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zService.init_moduleq   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )N
setservice
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzService.run_commandw   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Service.show_result}   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzService.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
   j   s    @+.r   r
   c                     t        t        ddg d      t        ddddg      t        ddg d      t        d	d
      t        d	d
      t        d	d
            } | j                  t               t        |       }|j	                          y )NstrT)
webkvmzcd-mediazfd-mediazhd-mediasshtelnetsolsshsnmpvnc)typerequiredchoicesFactiveinactive)eth0eth1bothbond0int)r4   r5   )service_namestate	interfacenon_secure_portsecure_porttimeout)r   updater   r
   r'   )r   service_objs     r   mainrF      s    ut  >Z  [*7MNEE;\]%%8ee4%%0M *+-(Kr   __main__N)
__future__r   r   r   r4   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   9ansible_collections.inspur.ispim.plugins.module_utils.ismr   r   objectr
   rF   r(   r"   r   r   <module>rP      sV    C B5n*
 5 if : zF r   