Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/nxos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZddlmZmZmZddlmZmZddlmZddlmZddlmZddlmZd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d �Z)d!�Z*d"�Z+d#�Z,d$�Z-d%�Z.d&�Z/d'�Z0e1d(kr�e0�ndS()i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiont
deprecatedtstatustnetworktsupported_bysX

---
module: nxos_vlan
extends_documentation_fragment: nxos
version_added: "2.1"
short_description: Manages VLAN resources and attributes.
description:
  - Manages VLAN configurations on NX-OS switches.
deprecated:
  removed_in: '2.13'
  alternative: nxos_vlans
  why: Updated modules released with more functionality
author: Jason Edelman (@jedelman8)
options:
  vlan_id:
    description:
      - Single VLAN ID.
    type: int
  vlan_range:
    description:
      - Range of VLANs such as 2-10 or 2,5,10-15, etc.
    type: str
  name:
    description:
      - Name of VLAN or keyword 'default'.
    type: str
  interfaces:
    description:
      - List of interfaces that should be associated to the VLAN or keyword 'default'.
    version_added: "2.5"
    type: list
  associated_interfaces:
    description:
      - This is a intent option and checks the operational state of the for given vlan C(name)
        for associated interfaces. If the value in the C(associated_interfaces) does not match with
        the operational state of vlan interfaces on device it will result in failure.
    version_added: "2.5"
    type: list
  vlan_state:
    description:
      - Manage the vlan operational state of the VLAN
    default: active
    choices: ['active','suspend']
    type: str
  admin_state:
    description:
      - Manage the VLAN administrative state of the VLAN equivalent
        to shut/no shut in VLAN config mode.
    default: up
    choices: ['up','down']
    type: str
  mapped_vni:
    description:
      - The Virtual Network Identifier (VNI) ID that is mapped to the
        VLAN. Valid values are integer and keyword 'default'. Range 4096-16773119.
    version_added: "2.2"
    type: str
  state:
    description:
      - Manage the state of the resource.
    default: present
    choices: ['present','absent']
    type: str
  mode:
    description:
      - Set VLAN mode to classical ethernet or fabricpath.
        This is a valid option for Nexus 5000 and 7000 series.
    choices: ['ce','fabricpath']
    default: 'ce'
    type: str
    version_added: "2.4"
  aggregate:
    description: List of VLANs definitions.
    version_added: "2.5"
    type: list
  purge:
    description:
      - Purge VLANs not defined in the I(aggregate) parameter.
        This parameter can be used without aggregate as well.
      - Removal of Vlan 1 is not allowed and will be ignored by purge.
    type: bool
    default: 'no'
  delay:
    description:
      - Time in seconds to wait before checking for the operational state on remote
        device. This wait is applicable for operational state arguments.
    default: 10
    type: int
s
- name: Ensure a range of VLANs are not present on the switch
  nxos_vlan:
    vlan_range: "2-10,20,50,55-60,100-150"
    state: absent

- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
  nxos_vlan:
    vlan_id: 50
    admin_state: down
    name: WEB

- name: Ensure VLAN is NOT on the device
  nxos_vlan:
    vlan_id: 50
    state: absent

- name: Add interfaces to VLAN and check intent (config + intent)
  nxos_vlan:
    vlan_id: 100
    interfaces:
      - Ethernet2/1
      - Ethernet2/5
    associated_interfaces:
      - Ethernet2/1
      - Ethernet2/5

- name: Check interfaces assigned to VLAN
  nxos_vlan:
    vlan_id: 100
    associated_interfaces:
      - Ethernet2/1
      - Ethernet2/5

- name: Create aggregate of vlans
  nxos_vlan:
    aggregate:
      - { vlan_id: 4000, mode: ce }
      - { vlan_id: 4001, name: vlan-4001 }

- name: purge vlans - removes all other vlans except the ones mentioned in aggregate)
  nxos_vlan:
    aggregate:
      - vlan_id: 1
      - vlan_id: 4001
    purge: yes

s�
commands:
    description: Set of command strings to send to the remote device
    returned: always
    type: list
    sample: ["vlan 20", "vlan 55", "vn-segment 5000"]
N(tdeepcopy(tget_capabilities(t
get_configtload_configtrun_commands(tnormalize_interfacetnxos_argument_spec(t
AnsibleModule(tConnectionError(tCustomNetworkConfig(tremove_default_speccC`s)x"|D]}|d|kr|SqWdS(Ntvlan_id((Rtlstto((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytsearch_obj_in_list�s
cC`s�t|�}d}x$|D]}||kr||=qqWt|�}|d=|d|dkr�tt|j��t|j���}|SdS(Nt
interfacestassociated_interfacestdelayt
vlan_rangeR(s
interfacessassociated_interfacessdelays
vlan_range(Rtdicttsettitems(twtobjtctentriestkeyRt	diff_dict((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytget_diff�s
(cC`sC|d}d|kr?t|d�}|t|�kr?tSntS(NtnametVLANi(tinttTruetFalse(RRtcnametvid((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytis_default_name�s
cC`s�t�}|jd}|\}}t|�jd�}|jd�}x�|D]�}|d}	|d}
|jd�pyg}|d}|d}
|d	}|d
}|d}|d=t|	|�p�i}tjd|�s�|jd�r
|
d
kr
d}
|d<n|dkr8|r|jdj	|	��qqM|dkrM|s�|jdj	|	��|
r�|
dkr�|jdj	|
��n|
r�|jdj	|
��n|r�|jdj	|��n|dkr�|dkr�|jdj	|��n|dkr|jd�n|dkr2|jd�n|jd�|r|ddkrxW|D]L}|jdj	|��|jd�|jd �|jd!j	|	��q\Wqqt
||�}|r�|jdj	|	��x||j�D]n\}}|dkrX|
dkr6|
dk	rU|jdj	|��qUqXt||	�sX|jd"�qXn|d	kr�|r�|jdj	|��n|dkr�|dkr�|ddkr�|jd#�q�q�|dkr�|jdj	|��q�n|d
kr-|dkr|jd�q-|dkr-|jd�q-n|dkr�|r�|jdj	|��q�q�Wt
|�d$kr~|jd�q�|2n|rx|ddkrx|ds"x�|D]o}|jdj	|	��|jd�|jdj	|��|jd�|jd �|jd!j	|	��q�Wqt|�t|d�krtt|�t|d��}xw|D]o}|jdj	|	��|jd�|jdj	|��|jd�|jd �|jd!j	|	��qeWtt|d�t|��}xz|D]o}|jdj	|	��|jd�|jdj	|��|jd�|jd �|jd%j	|	��q�Wqq|r|ddkr|drx~|dD]o}|jdj	|	��|jd�|jdj	|��|jd�|jd �|jd%j	|	��q�WqqqMqMW|r�xj|D]_}|dd&krY|jd'�q0nt|d|�}|s0|jdj	|d��q0q0Wn|S((Ntpurgetdevice_infotnetwork_os_platformRR%Rt
mapped_vnitmodet
vlan_statetadmin_statetstatesN[567]tcetabsentsno vlan {0}tpresentsvlan {0}tdefaultsname {0}smode {0}s	state {0}tNonesvn-segment {0}tupsno shutdowntdowntshutdowntexitis
interface {0}t
switchportsswitchport mode accesssswitchport access vlan {0}sno names
no vn-segmentisno switchport access vlan {0}t1s;Deletion of vlan 1 is not allowed; purge will ignore vlan 1(tlisttparamsR	tgetRtretmatchR9tappendtformatR$RR,tlenRtwarn(tupdatestmoduletcommandsR-twantthavetinfotos_platformRRR%RR0R1R2R3R4tobj_in_havetitdiffR"tvaluetmissing_interfacestsuperfluous_interfacesthtobj_in_want((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytmap_obj_to_commands�s�	








/



 




 



 



 



'

$cC`s�g}|jd}x�|jd�D]�}|dkr9Pnd|kr�|jd�\}}t|�t|�}}|jgt||d�D]}t|�^q��q#|j|�q#W|S(NRt,tnonet-i(RAtsplitR'textendtrangetstrRE(RJtresultRtparttstarttendRQ((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytwant_vlan_list_s
6cC`s@g}|r<x-|D]"}|jt|jd���qWn|S(NR(RER_RB(RMR`RV((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pythave_vlan_listns

#cC`s�t�}t|�}t|�}|jddkrst|�j|�}xy|D]}|jdj|��qPWnR|jddkr�t|�j|�}x'|D]}|jdj|��q�Wn|S(NR4R6sno vlan {0}R7svlan {0}(	R@RdReRARtintersectionRERFt
difference(RJRMRKtproposed_vlans_listtexisting_vlans_listtvlanstvlan((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytvlan_range_commandsvs	

cC`s2d}|r.g|D]}t|�^q}n|S(N(R9R
(Rt
normalizedRQ((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pyt	normalize�s"cC`s�g}|jdrgS|jjd�}|r�xc|D]�}x7|D]/}|j|�dkrC|j|||<qCqCW|j�}t|d�|d<t|d�|d<t|d�|d<t|d�|d<|j|�q6Wn�t|jd�}t|jd�}|ji	t|jd�d6|jdd6|d6|jdd6t|jd�d6|jd	d	6|jd
d
6|jdd6|d6�|S(NRt	aggregateRR0RRR%R2R4R3R1(RARBR9tcopyR_RnRE(RJRRotitemR"tdRR((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytmap_params_to_obj�s8


	cC`s3|jd�}|dkrdS|dkr/dSdS(Nsvlanshowbr-shutstatet
noshutdownR:R<R;(RB(Rkt	shutstate((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytparse_admin_state�s
cC`s=d}|r9tjd|�}|r9|jd�}q9n|S(Ns
mode (\S+)i(R9RCtsearchtgroup(tconfigR1RD((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pyt
parse_mode�scC`sCd}|r9tjd|�}|r9|jd�}q9nt|�S(Nsvn-segment (\S+)i(R9RCRwRxR_(RytvniRD((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pyt	parse_vni�scC`s�g}x�|jd�D]�}d|j�kr�d|kr�|jd�}t|d�}t|djd�d�}|djd�d}xFt||d�D]!}|j|dt|��q�Wq|j|�qW|S(NRYtethR[iit/(R\tlowerR'R^RER_(Rtvlan_intRQt	int_rangetstopRbR}tr((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytget_vlan_int�s"cC`szg}|jd�}|rvt|t�rgg|D]}|j�^q1}dj|�}t|�}qvt|�}n|S(Nsvlanshowplist-ifidxRY(RBt
isinstanceR@tstriptjoinR�(RJRkR�RRQtinterfaces_listtinterfaces_str((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytparse_interfaces�scC`s%dj|�g}|j|�}|S(Nsvlan {0}(RFtget_section(tnetcfgRtparentsRy((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytparse_vlan_config�scC`s�i}|d}t||�}t|�|d<|jd�|d<|jd�|d<t|�|d<t|�|d<t|�|d	<t||�|d
<|S(Nsvlanshowbr-vlanid-utfRsvlanshowbr-vlannameR%svlanshowbr-vlanstateR2R3R1R0R(R�R_RBRvRzR|R�(RJR�toutputRkRRRy((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytparse_vlan_options�s
cC`sjt�}xZ|D]R}tjd|tj�}|rUi}|jd�}t|�|d<tjdj|�|tj�}|rU|jd�}	|	|d<tjdj|tj|	��|tj�}
|
rR|
jd�}|dkr�d}d	}
n|d
krd}d}
n|dkr,d}d	}
n|d
krGd}d}
n||d<|
|d<dj|j	��}t�}tjdj|tj|	�|�|tj�}|r|jd�}|j
�}x3|D](}t|jd��}|j
|�q�Wn|r||d<n
d|d<t||�}t|�|d<t|�|d<qRqUn|j
|�qW|S(Ns(\d+)iRs{0}\s*(\S+)R%s{0}\s*{1}\s*(\S+)t	suspendedtsuspendR:s	sus/lshutR;tactives	act/lshutR2R3RYs{0}\s*{1}\s*{2}\s*(.*)RR1R0(R@RCRwtMRxR_RFtescapeR�t
splitlinesR\R
R�RER9R�RzR|(RJR�RjtobjsRkt
vlan_matchRRt
name_matchR%tstate_matchtvlan_state_matchR2R3Rtintfs_matchtintfsRQtintfRy((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytparse_vlan_non_structureds\	
!
-				

	!


cC`s$t�}d}dg}t||dd�d}|r tdddt|dd	g��}t|t�rd}y|d
d}Wntk
r�|SX|rt|t�r�xg|D](}t||||�}|j	|�q�Wqt|t�rt||||�}|j	|�qqq t�}t
jd|j��}x�|D]�}	|	sVqDnt
|	�dkrD|	j�}	|	dj�r�t
jd
|	t
j�}
|
r�|
jd�}|j|�}|d}
dj|||
d!�}|j	|�q�q�qDqDW|rt|||�}q |Sn|S(Nsshow vlan brief | jsontcheck_rct
retry_jsonitindentitcontentstflagstalltTABLE_vlanbriefxbrieftROW_vlanbriefxbriefs
\n(\d+)|\n{2}s^(\d+)$it(R@R9RRR
R�RtKeyErrorR�RERCR\R�RGtisdigitRwR�RxtindexR�R�(RJR�R�tcommandR�RjRkRt
splitted_linetlineRDtvtpos1tpos2tvlaninfo((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytmap_config_to_obj<sP		

	

cC`s�d}t}x�|D]�}|jd�dkr4qn|drb|rbtj|jd�t}n|dkr}t|�}nxh|dD]\}t|d|�}|r�d|kr�||dkr�|j	dd||df�q�q�WqWdS(NRtchangedRRRtmsgs&Interface %s not configured on vlan %s(
R9R)RBttimetsleepRAR(R�Rt	fail_json(RLRJR`RMtis_delayRRQRP((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytcheck_declarative_intent_paramsos
	"cC`s�tdtdtdd�dtdt�dtdt�dtdd�d	tdd�d
tddd
gdtdd�dtdt�dtdddd�dtdddgdddt�dtdddgdtdd�dtdddddg��}t|�}tdt�|d<t|�tdtddddd|�dtdtdd ��}|j|�|jt�dddgg}ddgddgddgg}td!|d"|d#|d$t�}t�}itd%6}|r�||d&<nt	|�}t
|�}	|jdr6t||�}
|
|d'<nt
|	|f|�}
|
|d'<|
r�|jstt||
�nt|d%<n|	r�t|	||�n|j|�d(S()s+ main entry point for module execution
    RtrequiredttypeR'RR%RR@RR2tchoicesR�R�R8R0Ri
R4R7R6R3R:R;R1R5t
fabricpathRotelementsRtoptionsR-tboolt
argument_spectrequired_one_oftmutually_exclusivetsupports_check_modeR�twarningsRKN(RR)RR(RtupdateRRR@R�RsRARlRXt
check_modeRR�t	exit_json(telement_spectaggregate_specR�R�R�RJR�R`RMRLRK((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pytmain�s\!!!


				




	
t__main__(2t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRCR�RpRt&ansible.module_utils.network.nxos.nxosR	R
RRR
Rtansible.module_utils.basicRtansible.module_utils.connectionRt*ansible.module_utils.network.common.configRt)ansible.module_utils.network.common.utilsRRR$R,RXRdReRlRnRsRvRzR|R�R�R�R�R�R�R�R�t__name__(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/_nxos_vlan.pyt<module>sN


Z1			
	�					&		
	
		
			:	3		C

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]