
    Vh                     p    d 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 ddlmZ d	 Zed
k(  r e        yy)z
The module file for eos_vlans
    )absolute_importdivisionprint_functiona  
module: eos_vlans
short_description: VLANs resource module
description: This module provides declarative management of VLANs on Arista EOS network
  devices.
version_added: 1.0.0
author: Nathaniel Case (@qalthos)
notes:
- Tested against Arista EOS 4.24.6F
- This module works with connection C(network_cli). See the L(EOS Platform Options,../network/user_guide/platform_eos.html).
options:
  config:
    description: A dictionary of VLANs options
    type: list
    elements: dict
    suboptions:
      name:
        description:
        - Name of the VLAN.
        type: str
      vlan_id:
        description:
        - ID of the VLAN. Range 1-4094
        type: int
        required: true
      state:
        description:
        - Operational state of the VLAN
        type: str
        choices:
        - active
        - suspend
  running_config:
    description:
    - This option is used only with state I(parsed).
    - The value of this option should be the output received from the EOS device
      by executing the command B(show running-config | section vlan).
    - The state I(parsed) reads the configuration from C(running_config) option
      and transforms it into Ansible structured data as per the resource module's
      argspec and the value
    type: str
  state:
    description:
    - The state of the configuration after module completion
    type: str
    choices:
    - merged
    - replaced
    - overridden
    - deleted
    - rendered
    - gathered
    - parsed
    default: merged

a6  
# Using deleted

# Before state:
# -------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty

- name: Delete attributes of the given VLANs.
  arista.eos.eos_vlans:
    config:
      - vlan_id: 20
    state: deleted

# After state:
# ------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten


# Using merged

# Before state:
# -------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty

- name: Merge given VLAN attributes with device configuration
  arista.eos.eos_vlans:
    config:
      - vlan_id: 20
        state: suspend
    state: merged

# After state:
# ------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty
#    state suspend


# Using overridden

# Before state:
# -------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty

- name: Override device configuration of all VLANs with provided configuration
  arista.eos.eos_vlans:
    config:
      - vlan_id: 20
        state: suspend
    state: overridden

# After state:
# ------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 20
#    state suspend


# Using replaced

# Before state:
# -------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty

- name: Replace all attributes of specified VLANs with provided configuration
  arista.eos.eos_vlans:
    config:
      - vlan_id: 20
        state: suspend
    state: replaced

# After state:
# ------------
#
# veos(config-vlan-20)#show running-config | section vlan
# vlan 10
#    name ten
# !
# vlan 20
#    state suspend

# using parsed

# parsed.cfg
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty
#    state suspend

- name: Use parsed to convert native configs to structured data
  arista.eos.eos_vlans:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Output:
# -------
#   parsed:
#     - vlan_id: 10
#       name: ten
#     - vlan_id: 20
#       state: suspend

# Using rendered:

- name: Use Rendered to convert the structured data to native config
  arista.eos.eos_vlans:
    config:
      - vlan_id: 10
        name: ten
      - vlan_id: 20
        state: suspend
    state: rendered

# Output:
# ------
# rendered:
#   - "vlan 10"
#   - "name ten"
#   - "vlan 20"
#   - "state suspend"

# Using gathered:
# native_config:
# vlan 10
#    name ten
# !
# vlan 20
#    name twenty
#    state suspend

- name: Gather vlans facts from the device
  arista.eos.eos_vlans:
    state: gathered

# Output:
# ------

# gathered:
#   - vlan_id: 10
#     name: ten
#   - vlan_id: 20
#     state: suspend
an  
before:
  description: The configuration as structured data prior to module invocation.
  returned: always
  type: list
  sample: >
    The configuration returned will always be in the same format
     of the parameters above.
after:
  description: The configuration as structured data after module completion.
  returned: when changed
  type: list
  sample: >
    The configuration returned will always be in the same format
     of the parameters above.
commands:
  description: The set of commands pushed to the remote device.
  returned: always
  type: list
  sample: ['vlan 10', 'no name', 'vlan 11', 'name Eleven']
)AnsibleModule)	VlansArgs)Vlansc                      g d} dg}t        t        j                  | d|      }t        |      j	                         } |j
                  di | y)z`
    Main entry point for module execution

    :returns: the result form module invocation
    ))statemergedconfig)r
   replacedr   )r
   
overriddenr   )r
   renderedr   )r
   parsed)running_config)r   r   T)argument_specrequired_ifsupports_check_modemutually_exclusiveN )r   r   r   r   execute_module	exit_json)r   r   moduleresults       h/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/arista/eos/plugins/modules/eos_vlans.pymainr   ,  sW    K 77-- -	F 6]))+FFv    __main__N)__doc__
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Sansible_collections.arista.eos.plugins.module_utils.network.eos.argspec.vlans.vlansr   Ransible_collections.arista.eos.plugins.module_utils.network.eos.config.vlans.vlansr   r   __name__r   r   r   <module>r+      s[   2 A @ 7pqd
. 5 e2 zF r   