
    VhK                     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_ntp
version_added: "1.0.0"
author:
    - WangBaoshan (@ispim)
short_description: Set NTP
description:
   - Set NTP on Inspur server.
notes:
   - Does not support C(check_mode).
options:
    auto_date:
        description:
            - Date auto synchronize.
        choices: ['enable', 'disable']
        type: str
    ntp_time:
        description:
            - NTP time(YYYYmmddHHMMSS).
            - Only the M5 model supports this parameter.
        type: str
    time_zone:
        description:
            - UTC time zone,chose from {-12, -11.5, -11, ... ,11,11.5,12}.
        type: str
    server1:
        description:
            - NTP Server1(ipv4 or ipv6 or domain name), set when auto_dateis enable.
        type: str
    server2:
        description:
            - NTP Server2(ipv4 or ipv6 or domain name), set when auto_date is enable.
        type: str
    server3:
        description:
            - NTP Server3(ipv4 or ipv6 or domain name), set when auto_date is enable.
        type: str
    server4:
        description:
            - NTP Server1(ipv4 or ipv6 or domain name), set when auto_dateis enable.
        type: str
    server5:
        description:
            - NTP Server2(ipv4 or ipv6 or domain name), set when auto_date is enable.
        type: str
    server6:
        description:
            - NTP Server3(ipv4 or ipv6 or domain name), set when auto_date is enable.
        type: str
    syn_cycle:
        description:
            - NTP syn cycle(minute),sync cycle(5-1440).
        type: int
    max_variety:
        description:
            - NTP Maximum jump time(minute),max variety(1-60).
            - Only the M6 model supports this parameter.
        type: int
extends_documentation_fragment:
    - inspur.ispim.ism
a6  
- name: NTP test
  hosts: ism
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set ntp"
    inspur.ispim.edit_ntp:
      auto_date: "enable"
      server2: "time.nist.gov"
      provider: "{{ ism }}"

  - name: "Set ntp"
    inspur.ispim.edit_ntp:
      auto_date: "disable"
      ntp_time: "20200609083600"
      provider: "{{ ism }}"

  - name: "set ntp"
    inspur.ispim.edit_ntp:
      time_zone: "8"
      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)NTPc                 ^    || _         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_ntp.py__init__zNTP.__init__}   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zNTP.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsettime
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzNTP.run_command   sJ    +4<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzNTP.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzNTP.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      t        dd      t        dd      t        dd      t        dd      t        dd      t        dd      t        dd      t        dd      t        dd            } | j                  t               t        |       }|j	                          y )	NstrFenabledisable)typerequiredchoices)r/   r0   int)	auto_datentp_time	time_zoneserver1server2server3server4server5server6	syn_cyclemax_variety)r   updater   r
   r'   )r   ntp_objs     r   mainr@      s    EEHi;PQ551EE2%%0%%0%%0%%0%%0%%0EE2ee4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
   r@   r(   r"   r   r   <module>rJ      sV    C B=~>
 5 i& :& zF r   