
    Vhz                     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_functionaZ  
---
module: edit_ipv6
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Set ipv6 information
description:
   - Set ipv6 information on kaytus Server.
notes:
   - Does not support C(check_mode).
options:
    interface_name:
        description:
            - Set interface name. Select the LAN interface to be configured.
        choices: ['eth0', 'eth1', 'bond0']
        required: True
        type: str
    ipv6_status:
        description:
            - Enable or disable IPV6.
        choices: ['enable', 'disable']
        type: str
    ipv6_dhcp_enable:
        description:
            - Enable 'Enable DHCP' to dynamically configure IPv6 address using Dynamic Host Configuration Protocol (DHCP).
        choices: ['dhcp', 'static']
        type: str
    ipv6_address:
        description:
            - If DHCP is disabled, specify a static IPv6 address to be configured for the selected interface.
            - Required when I(ipv6_dhcp_enable=static).
        type: str
    ipv6_index:
        description:
            - Ipv6 index(0-15).
            - Required when I(ipv6_dhcp_enable=static).
        type: int
    ipv6_prefix:
        description:
            - The subnet prefix length for the IPv6 settings(0-128).
            - Required when I(ipv6_dhcp_enable=static).
        type: int
    ipv6_gateway:
        description:
            - If DHCP is disabled, specify a static Default Gateway to be configured for the selected interface.
            - Required when I(ipv6_dhcp_enable=static).
        type: str
extends_documentation_fragment:
    - kaytus.ksmanage.ksmanage
aU  
- name: Ipv6 test
  hosts: ksmanage
  connection: local
  gather_facts: false
  vars:
    ksmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set ipv6 information"
    kaytus.ksmanage.edit_ipv6:
      interface_name: "eth0"
      ipv6_status: "disable"
      provider: "{{ ksmanage }}"

  - name: "Set ipv6 information"
    kaytus.ksmanage.edit_ipv6:
      interface_name: "eth0"
      ipv6_status: "enable"
      ipv6_dhcp_enable: "dhcp"
      provider: "{{ ksmanage }}"

  - name: "Set ipv6 information"
    kaytus.ksmanage.edit_ipv6:
      interface_name: "eth0"
      ipv6_status: "enable"
      ipv6_dhcp_enable: "static"
      ipv6_address: "::ffff:100:2:36:10"
      ipv6_index: 12
      ipv6_prefix: 16
      ipv6_gateway: "::"
      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)Networkc                 ^    || _         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/kaytus/ksmanage/plugins/modules/edit_ipv6.py__init__zNetwork.__init__y   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zNetwork.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetipv6
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzNetwork.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Network.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzNetwork.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
   x   s    @+.r   r
   c                  4   t        t        ddg d      t        ddddg      t        dddd	g      t        dd
      t        dd
      t        dd
      t        dd
            } | j                  t               t        |       }|j	                          y )NstrT)eth0eth1bond0)typerequiredchoicesFenabledisabledhcpstatic)r0   r1   int)interface_nameipv6_statusipv6_dhcp_enableipv6_address
ipv6_indexipv6_prefixipv6_gateway)r   updater   r
   r'   )r   net_objs     r   mainrA      s    ?XYeeh	=RS5568BTUuu5UU3ee4uu5	M /0m$GLLNr   __main__N)
__future__r   r   r   r0   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Aansible_collections.kaytus.ksmanage.plugins.module_utils.ksmanager   r   objectr
   rA   r(   r"   r   r   <module>rK      sW    C B2h$L
 5 vf :  zF r   