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_vpc_interface.pyc

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lmZmZmZd	dlmZm	Z	d	dl
mZd
�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�ndS(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: nxos_vpc_interface
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages interface VPC configuration
description:
  - Manages interface VPC configuration
author:
  - Jason Edelman (@jedelman8)
  - Gabriele Gerbino (@GGabriele)
notes:
  - Tested against NXOSv 7.3.(0)D1(1) on VIRL
  - Either vpc or peer_link param is required, but not both.
  - C(state=absent) removes whatever VPC config is on a port-channel
    if one exists.
  - Re-assigning a vpc or peerlink from one portchannel to another is not
    supported.  The module will force the user to unconfigure an existing
    vpc/pl before configuring the same value on a new portchannel
options:
  portchannel:
    description:
      - Group number of the portchannel that will be configured.
    required: true
  vpc:
    description:
      - VPC group/id that will be configured on associated portchannel.
  peer_link:
    description:
      - Set to true/false for peer link config on associated portchannel.
    type: bool
  state:
    description:
      - Manages desired state of the resource.
    required: true
    choices: ['present','absent']
    default: present
s8
- nxos_vpc_interface:
    portchannel: 10
    vpc: 100
s�
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["interface port-channel100", "vpc 10"]
i����(t
get_configtload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCsGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(t
isinstancetlisttextendtappend(t
command_liststflat_command_listtcommand((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytflatten_listQs
cCs�g}g}y(t|dg�d}|dd}Wntttfk
rQ|SX|r�t|t�rs|g}nx"|D]}|j|d�qzWn|S(Ns show port-channel summary | jsonit
TABLE_channeltROW_channeltgroup(RtKeyErrortAttributeErrort	TypeErrorRtdictR(tmoduletportchannelstpc_listtbodytpc((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytget_portchannel_list[s
cCs�i}y(t|dg�d}|dd}Wn tttfk
rPd}nX|r�t|t�rr|g}nx/|D]$}t|d�|t|d�<qyWn|S(Nsshow vpc brief | jsonit	TABLE_vpctROW_vpcsvpc-ifindexsvpc-id(RRRRtNoneRRtstr(Rtpc_vpc_mappingRt	vpc_tabletvpc((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pyt(get_existing_portchannel_to_vpc_mappingsos

%cCsTt}t|ddg�}|jd�}x#|D]}d|kr1t}q1q1W|S(NtflagsR&s
s	peer-link(tFalseRtsplittTrue(Rtfoundtruntvpc_listteach((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytpeer_link_exists�s

cCsTd}y,t|dg�d}|ddd}Wntttfk
rO|SX|S(Nsshow vpc brief | jsonitTABLE_peerlinktROW_peerlinkspeerlink-ifindex(R"RRRR(Rt	peer_linkR((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytget_active_vpc_peer_link�scCsFd}t}d}d}i}y(t|dg�d}|dd}Wn tttfk
rhi}nX|r�|jdd�}n|r�t|d�}	||	kr�||d<t|d	<||d
<q�nt	|�}
xi|
j
�D][\}}t|d�}
|
|kr�|
}t|�}||d<||d	<||d
<q�q�W|S(Ntsshow vpc brief | jsoniR1R2speerlink-ifindexitportchannels	peer-linkR&(R"R)RRRRtgetR#R+R'titems(RR6tpeer_link_pcR3R&RtconfigRttabletplpctmappingtexisting_vpctport_channeltport_ch((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytget_portchannel_vpc_config�s8




cCs�g}|jd�rN|jd�rN|jd�|jddj|��n�|jd�r�|jd�r�|jd�|jddj|��nW|jd�r�|jd�r�dj|�}|j|�|jddj|��n|S(Ns	peer-linksno vpc peer-linkisinterface port-channel{0}s
vpc peer-linkR&svpc {0}(R7Rtinserttformat(R6tdeltatconfig_valuetexistingtcommandsR((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pyt$get_commands_to_config_vpc_interface�s


cCs,g}t||||�}|j|�|S(N(RHR(R6RDRERFRGR((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pyt
state_present�s	
cCsvg}|jd�r+d}|j|�n%|jd�rPd}|j|�n|rr|jddj|��n|S(NR&sno vpcs	peer-linksno vpc peer-linkisinterface port-channel{0}(R7RRBRC(R6RFRGR((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytstate_absent�sc
Cs�tdtdtdd�dtdtdd�dtdtdd�dtd	d
dgdd��}|jt�td
|dddggdt�}t�}g}t||�itd6|d6}|jd}|jd}|jd}|jd}i|d6|d6|d6}	d}
|t
|�krf|j�sPt|�t
|�krf|j
dd�qfn|rXt|�}||kr�|||jd�kr�|j
ddd||�nxT|j�D]F\}}
||
jd�kr�||kr�|j
ddd|�q�q�Wt|�rOt|�}
|
d|krO|j
dd�qOn|}nt|dk	r�t|�r�t|�ddd�}
|
|kr�|r�|j
ddddj|
��q�q�nd}ntd �|	j�D��}t||�}|dkrKtt|j��j|j���}|rot||||�}qon$|d
kro|rot||�}nt|�}|r�|jr�|jdtd!|�q�t||�t|d<d"|kr�|jd#�q�n||d!<|j|�dS($NR6trequiredttypeR#R&R3tbooltstatetchoicestabsenttpresenttdefaultt
argument_spectmutually_exclusivetsupports_check_modetchangedtwarningss	peer-linktmsgsWThe portchannel you are trying to make a VPC or PL is not created yet. Create it first!tPoshThis vpc is already configured on another portchannel. Remove it first before trying to assign it here. texisting_portchannels^This portchannel already has another VPC configured. Remove it first before assigning this oneR>i����sPThat port channel is the current PEER LINK. Remove it if you want it to be a VPCis9A peer link already exists on the device. Remove it firsttcurrent_peer_linksPo{0}css-|]#\}}|dk	r||fVqdS(N(R"(t.0tktv((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pys	<genexpr>0sRGt	configurei(RR+R)tupdateRR
RR	tparamsR"Rtisdigittintt	fail_jsonR'tstripR8R0R4RCRAtsett
differenceRIRJRt
check_modet	exit_jsonRtpop(RSRRWRGtresultsR6R&R3RNtargstactive_peer_linkR=tvpcidtexisting_pcREtproposedRFRDtcmds((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pytmain�s|
		




%%!		'	


t__main__N(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNt&ansible.module_utils.network.nxos.nxosRRRRR	tansible.module_utils.basicR
RRR'R0R4RARHRIRJRrt__name__(((sS/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_vpc_interface.pyt<module>s(


'	
					&				[

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