
    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_dns
version_added: "1.0.0"
author:
    - WangBaoshan (@ispim)
short_description: Set dns information
description:
   - Set dns information on Inspur server.
notes:
   - Does not support C(check_mode).
options:
    dns_status:
        description:
            - DNS status.
        choices: ['enable', 'disable']
        type: str
    host_cfg:
        description:
            - Host Settings.
        choices: ['manual', 'auto']
        type: str
    host_name:
        description:
            - Host Name.
            - Required when I(host_cfg=manual).
        type: str
    domain_manual:
        description:
            - Domain Settings.
        choices: ['manual', 'auto']
        type: str
    domain_iface:
        description:
            - Network Interface,input like 'eth0_v4', 'eth0_v6', 'eth1_v4', 'eth1_v6', 'bond0_v4', 'bond0_v6'.
            - Required when I(domain_manual=auto).
        type: str
    domain_name:
        description:
            - Domain Name.
            - Required when I(domain_manual=manual).
        type: str
    dns_manual:
        description:
            - DNS Settings.
        choices: ['manual', 'auto']
        type: str
    dns_iface:
        description:
            - DNS Interface,input like 'eth0', 'eth1', 'bond0'.
            - Required when I(dns_manual=auto).
        type: str
    dns_priority:
        description:
            - IP Priority.
            - Required when I(dns_manual=auto).
        choices: ['4', '6']
        type: str
    dns_server1:
        description:
            - DNS Server1 IPv4 or IPv6 address.
            - Required when I(dns_manual=manual).
        type: str
    dns_server2:
        description:
            - DNS Server2 IPv4 or IPv6 address.
            - Required when I(dns_manual=manual).
        type: str
    dns_server3:
        description:
            - DNS Server3 IPv4 or IPv6 address.
            - Required when I(dns_manual=manual).
        type: str
    register_status1:
        description:
            - BMC register status 1.
            - Only the M6 model supports this parameter.
        choices: ['enable', 'disable']
        type: str
    registration_method1:
        description:
            - Registration method 1.
            - Only the M6 model supports this parameter.
            - Required when I(register_status1=enable).
        choices: ['nsupdate', 'dhcp', 'hostname']
        type: str
    register_status2:
        description:
            - BMC register status 2.
            - Only the M6 model supports this parameter.
        choices: ['enable', 'disable']
        type: str
    registration_method2:
        description:
            - Registration method 2.
            - Only the M6 model supports this parameter.
            - Required when I(register_status2=enable).
        choices: ['nsupdate', 'dhcp', 'hostname']
        type: str
extends_documentation_fragment:
    - inspur.ispim.ism
a  
- name: DNS test
  hosts: ism
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set dns information"
    inspur.ispim.edit_dns:
      dns_status: "disable"
      provider: "{{ ism }}"

  - name: "Set dns information"
    inspur.ispim.edit_dns:
      dns_status: "enable"
      host_cfg: "manual"
      host_name: "123456789"
      domain_manual: "auto"
      domain_iface: "eth0_v4"
      dns_manual: "manual"
      dns_server1: "100.2.2.2"
      dns_server2: "100.2.2.3"
      dns_server3: "100.2.2.4"
      provider: "{{ ism }}"

  - name: "Set dns information"
    inspur.ispim.edit_dns:
      dns_status: "enable"
      host_cfg: "manual"
      host_name: "123456789"
      domain_manual: "manual"
      domain_name: "inspur.com"
      dns_manual: "auto"
      dns_iface: "eth0"
      dns_priority: "4"
      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)DNSc                 ^    || _         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_dns.py__init__zDNS.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zDNS.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetdns
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzDNS.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DNS.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzDNS.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
      s    @+.r   r
   c                  l   t        di dt        ddddg      dt        dddd	g      d
t        dd      dt        dddd	g      dt        dd      dt        dd      dt        dddd	g      dt        dd      dt        ddddg      dt        dd      dt        dd      dt        dd      dt        ddddg      dt        ddg d      dt        ddddg      dt        ddg d      } | j                  t               t        |       }|j	                          y )N
dns_statusstrFenabledisable)typerequiredchoiceshost_cfgmanualauto	host_name)r0   r1   domain_manualdomain_ifacedomain_name
dns_manual	dns_ifacedns_priority46dns_server1dns_server2dns_server3register_status1registration_method1)nsupdatedhcphostnameregister_status2registration_method2r"   )r   updater   r
   r'   )r   dns_objs     r   mainrK      sr    UUXy<QR558V:LM EE2 &?QR	
 uu5 ee4 UUXv<NO EE2 uusCjI ee4 ee4 ee4 558YBWX "uuFfg 558YBWX  "uuFfg!M$ *+- GLLNr   __main__N)
__future__r   r   r   r0   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   9ansible_collections.inspur.ispim.plugins.module_utils.ismr   r   objectr
   rK   r(   r"   r   r   <module>rU      sX    C BeN*X
 5 i& :0 zF r   