%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/boto_vpc.pyo

�
���^c@@sO
dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlm
Z
mZdZdZdZeje�ZddlmZdd	lmZyWddlZddlZddlZdd
lmZejd�jej�e Z!Wne"k
r1e#Z!nXy/ddl$Z$ejd�jej�e Z%Wne"k
rze#Z%nXd
�Z&d�Z'ddddddd�Z)ddddddd�Z*ddddddd�Z+ddddddd�Z,dddddddd�Z-ddddd�Z.ddddddd�Z/dddddddd�Z0ddddddddd�Z1dddddddd�Z2dddddddd�Z3ddddddddd�Z4dddddddddd�	Z5ddddddddd�Z6ddddddd�Z7ddddddddd�Z8dddddd�Z9dddddddddde#d �Z:ddddddd!�Z;ddddddddddd"�
Z<ddddd#�Z=ddddddd$�Z>ddddddddd%�Z?ddddddddd&�Z@dde#ddddd'�ZAdddddd^ddddd*�
ZBdddddd_ddddd+�
ZCdddddd`ddddd,�
ZDdddddddd-�ZEe#dddde#d.d/�ZFddddddd0�ZGddddddd1�ZHddddddd2�ZIdddddddddddddd3�
ZJddddddd4�ZKddddddd5�ZLddddddd6�ZMddddddddd7�ZNddddddddddd8�
ZOdde#ddddd9�ZPddddddddd:�ZQddddddddd;�ZRddddddddd<�ZSddddddddddde#ddddd=�ZTdddddddddddddddd>�ZUdddddddddddddddd?�ZVddddddddd@�ZWdddddddddA�ZXdddddddB�ZYdddddddddC�ZZddddddddddddD�Z[dddddddddE�Z\dddddF�Z]dddddG�Z^dddddddddddddddddH�Z_ddddddddI�Z`ddddddddddddJ�ZaddddddddK�ZbdddddddddL�ZcddddddM�ZddN�ZedO�ZfdP�ZgdQ�ZhdR�ZidS�ZjddddddT�Zkdddddddddde#dU�ZldV�ZmdddddW�ZndXdXdddde#dY�ZodZ�Zpdddddde#d[�Zqddddddd\�Zrddddddddd]�ZsdS(aut

Connection module for Amazon VPC

.. versionadded:: 2014.7.0

:depends:

- boto >= 2.8.0
- boto3 >= 1.2.6

:configuration: This module accepts explicit VPC credentials but can also
    utilize IAM roles assigned to the instance through Instance Profiles.
    Dynamic credentials are then automatically obtained from AWS API and no
    further configuration is necessary. More Information available here__.

.. __: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

If IAM roles are not used you need to specify them either in a pillar or
in the minion's config file:

.. code-block:: yaml

    vpc.keyid: GKTADJGHEIQSXMKKRBJ08H
    vpc.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

A region may also be specified in the configuration:

.. code-block:: yaml

    vpc.region: us-east-1

If a region is not specified, the default is us-east-1.

It's also possible to specify key, keyid and region via a profile, either
as a passed in dict, or as a string to pull from pillars or minion config:

.. code-block:: yaml

    myprofile:
        keyid: GKTADJGHEIQSXMKKRBJ08H
        key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
        region: us-east-1

.. versionchanged:: 2015.8.0
    All methods now return a dictionary. Create and delete methods return:

    .. code-block:: yaml

        created: true

    or

    .. code-block:: yaml

        created: false
        error:
          message: error message

    Request methods (e.g., `describe_vpc`) return:

    .. code-block:: yaml

        vpcs:
          - {...}
          - {...}

    or

    .. code-block:: yaml

        error:
          message: error message

.. versionadded:: 2016.11.0

Functions to request, accept, delete and describe VPC peering connections.
Named VPC peering connections can be requested using these modules.
VPC owner accounts can accept VPC peering connections (named or otherwise).

Examples showing creation of VPC peering connection

.. code-block:: bash

    # Create a named VPC peering connection
    salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da name=my_vpc_connection
    # Without a name
    salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da
    # Specify a region
    salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da region=us-west-2

Check to see if VPC peering connection is pending

.. code-block:: bash

    salt myminion boto_vpc.is_peering_connection_pending name=salt-vpc
    # Specify a region
    salt myminion boto_vpc.is_peering_connection_pending name=salt-vpc region=us-west-2
    # specify an id
    salt myminion boto_vpc.is_peering_connection_pending conn_id=pcx-8a8939e3

Accept VPC peering connection

.. code-block:: bash

    salt myminion boto_vpc.accept_vpc_peering_connection name=salt-vpc
    # Specify a region
    salt myminion boto_vpc.accept_vpc_peering_connection name=salt-vpc region=us-west-2
    # specify an id
    salt myminion boto_vpc.accept_vpc_peering_connection conn_id=pcx-8a8939e3

Deleting VPC peering connection via this module

.. code-block:: bash

    # Delete a named VPC peering connection
    salt myminion boto_vpc.delete_vpc_peering_connection name=salt-vpc
    # Specify a region
    salt myminion boto_vpc.delete_vpc_peering_connection name=salt-vpc region=us-west-2
    # specify an id
    salt myminion boto_vpc.delete_vpc_peering_connection conn_id=pcx-8a8939e3

i(tabsolute_importtprint_functiontunicode_literalsN(tSaltInvocationErrortCommandExecutionErroruprovisioningupending-acceptanceuactive(tsix(trange(tBotoServerErrorubotouboto3cC@stjjjdddd�S(ug
    Only load if boto libraries exist and if boto libraries are greater than
    a given version.
    tboto_veru2.8.0t	boto3_veru1.2.6(tsalttutilstversionstcheck_boto_reqs(((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt__virtual__�s
c	C@sctjjjt�tr3tdtddt�ntr_tdtddddd	d
d�ndS(Nuboto.assign_funcsuvpctpackuboto3.assign_funcsuec2tget_conn_funcnameu
_get_conn3tcache_id_funcnameu
_cache_id3texactly_one_funcname(
R
Rtcompattpack_dundert__name__tHAS_BOTOt	__utils__t__salt__t	HAS_BOTO3tNone(topts((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt__init__�scC@s�t||f�s!td��n|rQtd|d|d|d|d|�}n;td|d|d|d|d|�s�tjd|�d	S|S(
u�
    Check whether a VPC with the given name or id exists.
    Returns the vpc_id or None. Raises SaltInvocationError if
    both vpc_id and vpc_name are None. Optionally raise a
    CommandExecutionError if the VPC does not exist.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.check_vpc vpc_name=myvpc profile=awsprofile
    u:One (but not both) of vpc_id or vpc_name must be provided.tvpc_nametregiontkeytkeyidtprofiletvpc_iduVPC %s does not exist.N(t_exactly_oneRt_get_idt
_find_vpcstlogtinfoR(R"RRRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt	check_vpc�s	cK@s�y�y8td|d|d|d|�}t|d|�}	Wn*tk
rgtdjd|���nX|r�t||d|d|d|d|�r�itd6idj||�d	6d
6S|	|�}
|
rht|
t�r�itd6St	j
d||
j�t||
�t
||
�|rPt|d|d
|
jd|d|d|d|�nitd6|
jd6SnP|r�dj||�}ndj|�}t	j|�itd6i|d	6d
6SWn,tk
r�}itd6td|�d
6SXdS(ua
    Create a VPC resource. Returns the resource id if created, or False
    if not created.
    RRR R!ucreate_u4{0} function does not exist for boto VPC connection.ucreateduA {0} named {1} already exists.umessageuerroruA %s with id %s was createdtsub_resourcetresource_iduidu{0} {1} was not created.u{0} was not created.uboto.get_errorN(t	_get_conntgetattrtAttributeErrortformatt_get_resource_idtFalset
isinstancetbooltTrueR&R'tidt_maybe_set_name_tagt_maybe_set_tagst	_cache_idtwarningRR(tresourcetnamettagsRRR R!tkwargstconntcreate_resourcetrte((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_create_resource�sD!
	


		

cK@s�t||f�s!td��nyUtd|d|d|d|�}yt|d|�}	Wn*tk
r�tdjd|���nX|r�t||d|d|d|d|�}|s�itd6id	j||�d
6d6Sn|	||�r2t|d|d
|dt	d|d|d|d|�it	d6S|rMdj||�}
ndj|�}
itd6i|
d
6d6SWn,t
k
r�}
itd6td|
�d6SXdS(uM
    Delete a VPC resource. Returns True if successful, otherwise False.
    u2One (but not both) of name or id must be provided.RRR R!udelete_u4{0} function does not exist for boto VPC connection.udeletedu{0} {1} does not exist.umessageuerrorR)R*t
invalidateu{0} {1} was not deleted.u{0} was not deleted.uboto.get_errorN(R#RR+R,R-R.R/R0R7R3RR(R9R:R*RRR R!R<R=tdelete_resourceR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_delete_resources<!
	
c
C@sxt||f�s!td��ntd|d|d|d|�}dj|�}|jd�sm|d}nt||�}	i}
|r�i|d6|
d	<n|r�||
d
j|�<ny|	|
�}Wn,tk
r�}|jjd�r�dS�nX|rpt	|�dkrU|rMt
|d
|d|djd|d|d|d|�n|dStdj||���ndSdS(uj
    Get a VPC resource based on resource type and name or id.
    Cache the id if name was provided.
    u2One (but not both) of name or id must be provided.RRR R!uget_all_{0}usutag:Nameufiltersu{0}_idsu	.NotFoundiR)R*iu#Found more than one {0} named "{1}"N(
R#RR+R.tendswithR,RtcodeRtlenR7R4R(
R9R:R*RRR R!R=tft
get_resourcestfilter_parametersR?R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
_get_resourceEs<!


	c	C@s_t||f�r!td��nt|||f�sEtd��ntd|d|d|d|�}dj|�}	|	jd�s�|	d}	nt||	�}
i}|r�i|d	6|d
<n|r�||dj|�<n|rx7tj|�D]#\}}
|
|d
dj|�<q�Wny|
|�}Wn,t	k
rZ}|j
jd
�rTdS�nX|S(uI
    Get VPC resources based on resource type and name, id, or tags.
    u'Only one of name or id may be provided.uBAt least one of the following must be provided: id, name, or tags.RRR R!uget_all_{0}usutag:Nameufiltersu{0}_idsutag:{0}u	.NotFoundN(tallRtanyR+R.RER,Rt	iteritemsRRFR(R9R:R*R;RRR R!R=RHRIRJttag_namet	tag_valueR?R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_find_resourcesus0!
cC@sot|d|d|d|d|d|�}|r4|St|d|d|d|d|d|�}|rk|jSdS(u<
    Get an AWS id for a VPC resource by type and name.
    R)RRR R!R:N(R7RKR4(R9R:RRR R!t_idR?((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR/�scC@s\y0it||d|d|d|d|�d6SWn%tk
rW}itd|�d6SXdS(	u�
    Get an AWS id for a VPC resource by type and name.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.get_resource_id internet_gateway myigw

    RRR R!uiduboto.get_erroruerrorN(R/RR(R9R:R*RRR R!R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytget_resource_id�s
c	C@sqyEitt|d|d|d|d|d|d|d|��d6SWn%tk
rl}itd	|�d
6SXdS(u:
    Given a resource type and name, return {exists: true} if it exists,
    {exists: false} if it does not exist, or {error: {message: error text}
    on error.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.resource_exists internet_gateway myigw

    R:R*R;RRR R!uexistsuboto.get_erroruerrorN(R2RQRR(	R9R:R*R;RRR R!R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytresource_exists�sc	C@sDt||f�r!td��nt||||f�sHtd��ntd|d|d|d|�}iid6}	|r�|g|	d<n|r�||	dd	<n|r�||	dd
<n|r�x7tj|�D]#\}
}||	ddj|
�<q�Wn|j|	�}tj	d|	|�|r<g|D]}
|
j
^q)SgSd
S(uA
    Given VPC properties, find and return matching VPC ids.
    u/Only one of vpc_name or vpc_id may be provided.uOAt least one of the following must be provided: vpc_id, vpc_name, cidr or tags.RRR R!ufiltersuvpc_idsucidrutag:Nameutag:{0}u5The filters criteria %s matched the following VPCs:%sN(RLRRMR+RRNR.tget_all_vpcsR&tdebugR4(R"RtcidrR;RRR R!R=RJRORPtvpcstvpc((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR%�s*!
	
c	C@s|rJt||f�rJt|d|d|d|d|�}|rJ|Sntd|d|d|d|d|d|d|�}|r�tjdd	j|��t|�d
kr�|d}|r�t||d|d|d|d|�n|Std��ntjd
�dSdS(uF
    Given VPC properties, return the VPC id if a match is found.
    RRR R!RRWR;uMatching VPC: %su iiu.Found more than one VPC matching the criteria.u
No VPC found.N(
RMR7R%R&RVtjoinRGRR'R(	RRWR;RRR R!R"tvpc_ids((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR$	s(	

cC@shy<itd|d|d|d|d|d|d|�d6SWn%tk
rc}itd	|�d
6SXdS(u�
    Given VPC properties, return the VPC id if a match is found.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.get_id myvpc

    RRWR;RRR R!uiduboto.get_erroruerrorN(R$RR(R:RWR;RRR R!R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytget_id(s

!cC@s�y=td|d|d|d|d|d|d|d|�}WnWtk
r�}	td	|	�}
|
jd
i�jd�dkr�itd
6Si|
d6SXit|�d
6S(u
    Given a VPC ID, check to see if the given VPC ID exists.

    Returns True if the given VPC ID exists and returns False if the given
    VPC ID does not exist.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.exists myvpc

    R"RRWR;RRR R!uboto.get_erroruawsucodeuInvalidVpcID.NotFounduexistsuerror(R%RRtgetR0R2(R"R:RWR;RRR R!R[terrtboto_err((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytexists<s!c

C@s'y�td|d|d|d|	�}
|
j|d|�}|r�tjd|j�t||�t||�t|
|j||�t|
|j|�|r�t	||jd|d|d|d|	�nit
d6|jd6Stjd	�itd6SWn,t
k
r"}itd6td
|�d6SXdS(
u�
    Given a valid CIDR block, create a VPC.

    An optional instance_tenancy argument can be provided. If provided, the
    valid values are 'default' or 'dedicated'

    An optional vpc_name argument can be provided.

    Returns {created: true} if the VPC was created and returns
    {created: False} if the VPC was not created.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create '10.0.0.0/24'

    RRR R!tinstance_tenancyuThe newly created VPC id is %sucreateduiduVPC was not createduboto.get_erroruerrorN(R+t
create_vpcR&R'R4R5R6t_maybe_set_dnst_maybe_name_route_tableR7R3R8R0RR(
t
cidr_blockRaRtenable_dns_supporttenable_dns_hostnamesR;RRR R!R=RYR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreateYs$!


c
C@so|rtjd�|}nt||f�s=td��ny�td|d|d|d|�}|s�td|d|d|d|d|d|�}|s�itd	6id
j|�d6d6Sn|j|�r tj	d
|�|rt
|d|dtd|d|d|d|�nitd	6Stjd|�itd	6SWn,tk
rj}	itd	6t
d|	�d6SXdS(uC
    Given a VPC ID or VPC name, delete the VPC.

    Returns {deleted: true} if the VPC was deleted and returns
    {deleted: false} if the VPC was not deleted.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete vpc_id='vpc-6b1fe402'
        salt myminion boto_vpc.delete name='myvpc'

    uCboto_vpc.delete: name parameter is deprecated use vpc_name instead.u:One (but not both) of vpc_name or vpc_id must be provided.RRR R!RR;udeleteduVPC {0} not foundumessageuerroruVPC %s was deleted.R*RBuVPC %s was not deleted.uboto.get_errorN(R&R8R#RR+R$R0R.t
delete_vpcR'R7R3RR(
R"R:RR;RRR R!R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete�s4
	!

c	C@s�t||f�s!td��ny@td|d|d|d|�}t||||||�}WnWtk
r�}td|�}|jdi�jd�d	kr�idd
6Si|d6SX|s�idd
6Si|d6}	y|j|	�}
Wn%tk
r}itd|�d6SX|
r�|
d
}t	j
d|j�d}tg|D]}
|
t
||
�f^qG�}|jit
|d�jd6�i|d
6Sidd
6SdS(uG
    Given a VPC ID describe its properties.

    Returns a dictionary of interesting properties.

    .. versionchanged:: 2015.8.0
        Added vpc_name argument

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe vpc_id=vpc-123456
        salt myminion boto_vpc.describe vpc_name=myvpc

    u-A valid vpc id or name needs to be specified.RRR R!uboto.get_erroruawsucodeuInvalidVpcID.NotFounduvpcuerroruvpc_idsiu
Found VPC: %suidu
cidr_blocku
is_defaultustateutagsudhcp_options_iduinstance_tenancyuregionN(uidu
cidr_blocku
is_defaultustateutagsudhcp_options_iduinstance_tenancy(RMRR+R(RRR]RRUR&RVR4tdictR,tupdateR:(R"RRRR R!R=R^R_RJRXRYtkeystkt_r((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdescribe�s4!!

. c	C@s�d}yStd|d	|d
|d|�}	iid6}
|rM|g|
d
<n|rd||
dd<n|r{||
dd<n|r�x7tj|�D]#\}}||
ddj|�<q�Wn|	j|
�}
|
rMg}xi|
D]a}tg|D]}|t||�f^q��}|jit|d�jd6�|j	|�q�Wi|d6Sigd6SWn%t
k
r�}itd|�d6SXdS(u
    Describe all VPCs, matching the filter criteria if provided.

    Returns a list of dictionaries with interesting properties.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe_vpcs

    uidu
cidr_blocku
is_defaultustateutagsudhcp_options_iduinstance_tenancyRRR R!ufiltersuvpc_idsucidrutag:Nameutag:{0}uregionuvpcsuboto.get_erroruerrorN(uidu
cidr_blocku
is_defaultustateutagsudhcp_options_iduinstance_tenancy(R+RRNR.RURkR,RlR:tappendRR(R"R:RWR;RRR R!RmR=RJRORPRXtretRYRnRoR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
describe_vpcs�s<!

. c
C@st|||g�s$td��niid6}|rH||dd<n|r_||dd<n|rv||dd<n|r�x7tj|�D]#\}}||ddj|�<q�Wn|j|�}tjd||�|r�g|D]}	|	j^q�St	SdS(	uF
    Given subnet properties, find and return matching subnet ids
    uKAt least one of the following must be specified: subnet_name, cidr or tags.ufiltersucidrutag:NameuVpcIdutag:{0}u9The filters criteria %s matched the following subnets: %sN(
RMRRRNR.tget_all_subnetsR&RVR4R0(
tsubnet_nameR"RWR;R=RJRORPtsubnetstsubnet((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
_find_subnets(s$
	
cC@s
yMt||||||	�}|sLitd6idj|p@|�d6d6SWn,tk
r{}itd6td|�d6SXtdd|d|d	|d
|d|d|d
|d|d|	�	}|
r	td|d
|d|d|	�}
|
jditd6d|d�n|S(um
    Given a valid VPC ID or Name and a CIDR block, create a subnet for the VPC.

    An optional availability zone argument can be provided.

    Returns True if the VPC subnet was created and returns False if the VPC subnet was not created.

    .. versionchanged:: 2015.8.0
        Added vpc_name argument

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.create_subnet vpc_id='vpc-6b1fe402' \
                subnet_name='mysubnet' cidr_block='10.0.0.0/25'
        salt myminion boto_vpc.create_subnet vpc_name='myvpc' \
                subnet_name='mysubnet', cidr_block='10.0.0.0/25'
    ucreateduVPC {0} does not exist.umessageuerroruboto.get_errorusubnetR:R;R"tavailability_zoneReRRR R!tMapPublicIpOnLaunchuValuetSubnetIduid(	R(R0R.RRRAt
_get_conn3tmodify_subnet_attributeR3(R"ReRRyRuR;RRR R!tauto_assign_public_ipv4R@tsubnet_object_dicttconn3((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
create_subnetJs,!$cC@s1tddd|d|d|d|d|d|�S(	uF
    Given a subnet ID or name, delete the subnet.

    Returns True if the subnet was deleted and returns False if the subnet was not deleted.

    .. versionchanged:: 2015.8.0
        Added subnet_name argument

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete_subnet 'subnet-6a1fe403'

    R9usubnetR:R*RRR R!(RD(t	subnet_idRuRRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
delete_subnetssc
	C@s|rtjd�|}nt|||||f�sFtd��ny%td|d|d|d|	�}
Wn%tk
r�}itd|�d6SXiid	6}|r�|g|d
<n|r�||d	d<n|r�||d	d<n|r$x7tj|�D]#\}
}||d	d
j	|
�<q�Wn|r;||d	d<ny|
j
|�}WnWtk
r�}td|�}|jdi�jd�dkr�itd6Si|d6SXtj
d||�|r�tjd|p�|�itd6Stjd|p�|�itd6SdS(uA
    Check if a subnet exists.

    Returns True if the subnet exists, otherwise returns False.

    .. versionchanged:: 2015.8.0
        Added subnet_name argument
        Deprecated name argument

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.subnet_exists subnet_id='subnet-6a1fe403'

    uMboto_vpc.subnet_exists: name parameter is deprecated use subnet_name instead.u^At least one of the following must be specified: subnet id, cidr, subnet_name, tags, or zones.RRR R!uboto.get_erroruerrorufiltersu
subnet_idsutag:Nameucidrutag:{0}uavailability_zoneuawsucodeuInvalidSubnetID.NotFounduexistsu8The filters criteria %s matched the following subnets:%suSubnet %s exists.uSubnet %s does not exist.N(R&R8RMRR+RRRRNR.RtR]R0RVR'R3(R�R:RuRWR;tzonesRRR R!R=R^RJRORPRvR_((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt
subnet_exists�sF
	%
!	
c		C@s
y7td|d|d|d|�}|jd|�}Wn%tk
r^}itd|�d6SXt�}xY|D]Q}tjd|j�||krotjd	|j|j�|j	|j�qoqoW|s�id
d
6St|�dkr�i|j�d
6Sit
|�d6Sd
S(u
    Given a subnet (aka: a vpc zone identifier) or list of subnets, returns
    vpc association.

    Returns a VPC ID if the given subnets are associated with the same VPC ID.
    Returns False on an error or if the given subnets are associated with
    different VPC IDs.

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.get_subnet_association subnet-61b47516

    .. code-block:: bash

        salt myminion boto_vpc.get_subnet_association ['subnet-61b47516','subnet-2cb9785b']

    RRR R!t
subnet_idsuboto.get_erroruerroru"examining subnet id: %s for vpc_idu+subnet id: %s is associated with vpc id: %suvpc_idiuvpc_idsN(R+RtRRtsetR&RVR4R"taddRRGtpoptlist(	RvRRR R!R=R@R[Rw((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytget_subnet_association�s"!	
	c
@sy4tdd|d|d|d|d|d|��Wn%tk
r[}itd|�d	6SX�smidd6Stjd
�j�d}it�fd�|D��d6}t|dd|ddddd|d|d|d|�}	|	r�|	|dd<n|S(uL
    Given a subnet id or name, describe its properties.

    Returns a dictionary of interesting properties.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.describe_subnet subnet_id=subnet-123456
        salt myminion boto_vpc.describe_subnet subnet_name=mysubnet

    usubnetR:R*RRR R!uboto.get_erroruerroruFound subnet: %suidu
cidr_blockuavailability_zoneutagsuvpc_idc3@s$|]}|t�|�fVqdS(N(R,(t.0Rn(Rw(s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pys	<genexpr>sR=u#explicit_route_table_association_idN(uidu
cidr_blockuavailability_zoneutagsuvpc_id(	RKRRRR&RVR4Rkt _get_subnet_explicit_route_table(
R�RuRRR R!R@RmRrtexplicit_route_table_assoc((Rws9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdescribe_subnet�s"#c	C@s}yQtd|d|d|d|�}iid6}	|rH||	dd<n|r_||	dd<n|rv||	dd<n|jd	||	�}
tjd
|	|
�|
s�idd6Sg}d}x�|
D]}
i}x3|D]+}t|
|�r�t|
|�||<q�q�Wt|d|dd|�}|r4||d<n|j|�q�Wi|d6SWn%t	k
rx}it
d|�d6SXdS(u�
    Given a VPC ID or subnet CIDR, returns a list of associated subnets and
    their details. Return all subnets if VPC ID or CIDR are not provided.
    If a subnet id or CIDR is provided, only its associated subnet details will be
    returned.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.describe_subnets

    .. code-block:: bash

        salt myminion boto_vpc.describe_subnets subnet_ids=['subnet-ba1987ab', 'subnet-ba1987cd']

    .. code-block:: bash

        salt myminion boto_vpc.describe_subnets vpc_id=vpc-123456

    .. code-block:: bash

        salt myminion boto_vpc.describe_subnets cidr=10.0.0.0/21

    RRR R!ufiltersuvpcIdu	cidrBlockutag:NameR�u9The filters criteria %s matched the following subnets: %susubnetsuidu
cidr_blockuavailability_zoneutagsuvpc_idR=u#explicit_route_table_association_iduboto.get_erroruerrorN(uidu
cidr_blockuavailability_zoneutagsuvpc_id(R+RtR&RVRthasattrR,R�RqRR(R�tsubnet_namesR"RWRRR R!R=RJRvtsubnets_listRmtitemRwR�R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdescribe_subnets s8!
	



cC@s-y�|s|r[t||||||�}|s[itd6idj|pL|�d6d6Sntdd|d|d|d	|d
|d|�}|jd�r�|r�td|d	|d
|d|�}	|	j|d|�tjd
|d|p�|�n|SWn,t	k
r(}
itd6t
d|
�d6SXdS(u�
    Create an Internet Gateway, optionally attaching it to an existing VPC.

    Returns the internet gateway id if the internet gateway was created and
    returns False if the internet gateways was not created.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_internet_gateway \
                internet_gateway_name=myigw vpc_name=myvpc

    ucreateduVPC {0} does not exist.umessageuerroruinternet_gatewayR:R;RRR R!uidu&Attached internet gateway %s to VPC %suboto.get_errorN(R(R0R.RAR]R+tattach_internet_gatewayR&R'RR(tinternet_gateway_nameR"RR;RRR R!R?R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreate_internet_gatewaycs$
!	!c
C@sYy&|r3td|d|d|d|d|�}n|s[itd6idj|�d6d	6S|r�tdd
|d|d|d|d|�}|s�itd6idj|�d6d	6S|jr�td|d|d|d|�}|j||jdj�q�ntdd
|d|d|d|d|�SWn,t	k
rT}	itd6t
d|	�d	6SXd
S(ux
    Delete an internet gateway (by name or id).

    Returns True if the internet gateway was deleted and otherwise False.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_internet_gateway internet_gateway_id=igw-1a2b3c
        salt myminion boto_vpc.delete_internet_gateway internet_gateway_name=myigw

    uinternet_gatewayRRR R!udeletedu$internet gateway {0} does not exist.umessageuerrorR*iuboto.get_errorN(R/R0R.RKtattachmentsR+tdetach_internet_gatewayR"RDRR(
tinternet_gateway_idR�tdetachRRR R!tigwR=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_internet_gateway�s:
	
				upendingu	availablec
C@s�t|||||f�s*td��nigd6}
|rM|g|
d<n|r�td|d|d|d|d|	�}|s�tSn|r�|
djid	d
6|gd6�n|r�td|d|d|d|d|	�}|s�tSn|r|
djid
d
6|gd6�ntd|d|d|d|	�}g}xltd|jdddd|
�D]H}
x?|
jdg�D]+}|jd�|krz|j|�qzqzWqaWt	j
d|
|�|r�|StSdS(uI
    Given gateway properties, find and return matching nat gateways
    ulAt least one of the following must be provided: nat_gateway_id, subnet_id, subnet_name, vpc_id, or vpc_name.uFilteru
NatGatewayIdsusubnetRRR R!u	subnet-iduNameuValuesuvpcuvpc-iduboto3.paged_calltmarker_flagu	NextTokent
marker_arguNatGatewaysuStateu>The filters criteria %s matched the following nat gateways: %sN(RMRR/R0RqR|Rtdescribe_nat_gatewaysR]R&RV(tnat_gateway_idR�RuR"RtstatesRRR R!RJR�tnat_gatewaysRrtgw((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_find_nat_gateways�sD
%%!	
	
c

C@sIttd|d|d|d|d|d|d|d|d	|d
|	�
�S(uR
    Checks if a nat gateway exists.

    This function requires boto3 to be installed.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.nat_gateway_exists nat_gateway_id='nat-03b02643b43216fe7'
        salt myminion boto_vpc.nat_gateway_exists subnet_id='subnet-5b05942d'

    R�R�RuR"RR�RRR R!(R2R�(
R�R�RuR"RR�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytnat_gateway_exists�sc

C@sCtd|d|d|d|d|d|d|d|d	|d
|	�
S(u\
    Return a description of nat gateways matching the selection criteria

    This function requires boto3 to be installed.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe_nat_gateways nat_gateway_id='nat-03b02643b43216fe7'
        salt myminion boto_vpc.describe_nat_gateways subnet_id='subnet-5b05942d'

    R�R�RuR"RR�RRR R!(R�(
R�R�RuR"RR�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�scC@s�ySt||f�r$td��n|r|td|d|d|d|d|�}|s�itd6idj|�d	6d
6SnLtdd|d|d|d|d|�s�itd6idj|�d	6d
6Std|d|d|d|�}|s|jdd
�}|jd�}n|j	d|d|�}	it
d6|	jdi�jd�d6SWn,tk
r�}
itd6td|
�d
6SXdS(u
    Create a NAT Gateway within an existing subnet. If allocation_id is
    specified, the elastic IP address it references is associated with the
    gateway. Otherwise, a new allocation_id is created and used.

    This function requires boto3 to be installed.

    Returns the nat gateway id if the nat gateway was created and
    returns False if the nat gateway was not created.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_nat_gateway subnet_name=mysubnet

    u5Only one of subnet_name or subnet_id may be provided.usubnetRRR R!ucreateduSubnet {0} does not exist.umessageuerrorR*tDomainuvpcuAllocationIdR{tAllocationIdu
NatGatewayuNatGatewayIduiduboto.get_errorN(
RLRR/R0R.RKR|tallocate_addressR]tcreate_nat_gatewayR3RR(R�Rut
allocation_idRRR R!R�taddressR?R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�2s,

!+ic
	C@s�y\td|d|d|d|�}|jd|g�}	|	r[|	jddg�d}	n|jd|�|rx�t|dd	�D]�}
|	r|	d
dkrtjd
||
tj	dd�d�|jd|g�}	|	r|	jddg�d}	q�qnPq�Wn|rP|	rPx3|	jd�D]}|j
d|jd��q*Wnitd6SWn,tk
r�}it
d6td|�d6SXdS(u�
    Delete a nat gateway (by id).

    Returns True if the internet gateway was deleted and otherwise False.

    This function requires boto3 to be installed.

    .. versionadded:: 2016.11.0

    nat_gateway_id
        Id of the NAT Gateway

    releaes_eips
        whether to release the elastic IPs associated with the given NAT Gateway Id

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    wait_for_delete
        whether to wait for delete of the NAT gateway to be in failed or deleted
        state after issuing the delete call.

    wait_for_delete_retries
        NAT gateway may take some time to be go into deleted or failed state.
        During the deletion process, subsequent release of elastic IPs may fail;
        this state will automatically retry this number of times to ensure
        the NAT gateway is in deleted or failed state before proceeding.

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_nat_gateway nat_gateway_id=igw-1a2b3c

    RRR R!t
NatGatewayIdsuNatGatewaysitNatGatewayIdi����uStateudeletedufailedii�g@�@uNatGatewayAddressesR�uAllocationIduboto.get_erroruerrorN(udeletedufailed(R|R�R]Rtdelete_nat_gatewayRttimetsleeptrandomtrandinttrelease_addressR3RR0R(
R�trelease_eipsRRR R!twait_for_deletetwait_for_delete_retriesR�tgwinfotretrytaddrR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�gs*2!)	 c		C@s=td|d|d|d|d|d|d|d|d	|�S(
u�
    Given a valid VPN connection type, a static IP address and a customer
    gateway’s Border Gateway Protocol (BGP) Autonomous System Number,
    create a customer gateway.

    Returns the customer gateway id if the customer gateway was created and
    returns False if the customer gateway was not created.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_customer_gateway 'ipsec.1', '12.1.2.3', 65534

    ucustomer_gatewayttypet
ip_addresstbgp_asnR;RRR R!(RA(	tvpn_connection_typeR�R�tcustomer_gateway_nameR;RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreate_customer_gateway�s
cC@s1tddd|d|d|d|d|d|�S(	u
    Given a customer gateway ID or name, delete the customer gateway.

    Returns True if the customer gateway was deleted and returns False if the customer gateway was not deleted.

    .. versionchanged:: 2015.8.0
        Added customer_gateway_name argument

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete_customer_gateway 'cgw-b6a247df'

    R9ucustomer_gatewayR:R*RRR R!(RD(tcustomer_gateway_idR�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_customer_gateway�s
cC@s.tdd|d|d|d|d|d|�S(ua
    Given a customer gateway ID, check if the customer gateway ID exists.

    Returns True if the customer gateway ID exists; Returns False otherwise.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.customer_gateway_exists cgw-b6a247df
        salt myminion boto_vpc.customer_gateway_exists customer_gatway_name=mycgw

    ucustomer_gatewayR:R*RRR R!(RT(R�R�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcustomer_gateway_exists�sc
C@sEy|s|r[t|||	|
||�}|s[itd6idj|pL|�d6d6Sntdd|d|d|d	|d
|d|d|	d
|
d|d|�
}
|
jd�r
|r
td|	d
|
d|d|�}|j|
d|�tjd|
d|p|�n|
SWn,t	k
r@}itd6t
d|�d6SXdS(uj
    Given valid DHCP options, create a DHCP options record, optionally associating it with
    an existing VPC.

    Returns True if the DHCP options record was created and returns False if the DHCP options record was not deleted.

    .. versionchanged:: 2015.8.0
        Added vpc_name and vpc_id arguments

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_dhcp_options domain_name='example.com' \
                domain_name_servers='[1.2.3.4]' ntp_servers='[5.6.7.8]' \
                netbios_name_servers='[10.0.0.1]' netbios_node_type=1 \
                vpc_name='myvpc'

    ucreateduVPC {0} does not exist.umessageuerrorudhcp_optionsR:tdomain_nametdomain_name_serverstntp_serverstnetbios_name_serverstnetbios_node_typeRRR R!uiduAssociated options %s to VPC %suboto.get_errorN(R(R0R.RAR]R+tassociate_dhcp_optionsR&R'RR(R�R�R�R�R�tdhcp_options_nameR;R"RRRR R!R?R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreate_dhcp_options�s*
!	!c	@st||f�s!td��n|rX|rXtd|d|d|d|d|�}n|siiid6Sy:td|d|d|d|�}|jd|g��Wn%tk
r�}itd|�d	6SX�s�idd6Sd}it�fd�|D��d6S(u�
    Return a dict with the current values of the requested DHCP options set

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.get_dhcp_options 'myfunnydhcpoptionsname'

    .. versionadded:: 2016.3.0
    uTAt least one of the following must be specified: dhcp_options_name, dhcp_options_id.udhcp_optionsRRR R!tdhcp_options_idsuboto.get_erroruerrorudomain_nameudomain_name_serversuntp_serversunetbios_name_serversunetbios_node_typec3@s+|]!}|�djj|�fVqdS(iN(toptionsR](R�Rn(R?(s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pys	<genexpr>PsN(udomain_nameudomain_name_serversuntp_serversunetbios_name_serversunetbios_node_type(	RMRR/R+tget_all_dhcp_optionsRRRRk(	R�tdhcp_options_idRRR R!R=R@Rm((R?s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytget_dhcp_options,s$

!cC@s1tddd|d|d|d|d|d|�S(	u�
    Delete dhcp options by id or name.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete_dhcp_options 'dopt-b6a247df'

    R9udhcp_optionsR:R*RRR R!(RD(R�R�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_dhcp_optionsSs
c	
C@s�y�t||||||�}|sLitd6idj|p@|�d6d6Std|d|d|d|�}|j||�r�tjd	||�itd6Stjd
||�itd6idd6d6SWn,t	k
r�}itd6t
d|�d6SXd
S(uq
    Given valid DHCP options id and a valid VPC id, associate the DHCP options record with the VPC.

    Returns True if the DHCP options record were associated and returns False if the DHCP options record was not associated.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.associate_dhcp_options_to_vpc 'dhcp-a0bl34pp' 'vpc-6b1fe402'

    u
associateduVPC {0} does not exist.umessageuerrorRRR R!u3DHCP options with id %s were associated with VPC %su7DHCP options with id %s were not associated with VPC %su%DHCP options could not be associated.uboto.get_errorN(R(R0R.R+R�R&R'R3R8RR(	R�R"RRRR R!R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytassociate_dhcp_options_to_vpcis
!	
	
cC@sP|rtjd�|}ntdd|d|d|d|d|d|d	|�S(
u�
    Check if a dhcp option exists.

    Returns True if the dhcp option exists; Returns False otherwise.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.dhcp_options_exists dhcp_options_id='dhcp-a0bl34pp'

    uYboto_vpc.dhcp_options_exists: name parameter is deprecated use dhcp_options_name instead.udhcp_optionsR:R*R;RRR R!(R&R8RT(R�R:R�R;RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdhcp_options_exists�s
	c
C@s|p	|}
yt||||||	�}Wn,tk
rY}itd6td|�d6SX|s�itd6idj|
�d6d6St||f�r�td��n|r�td|d|d	|d
|d|	�}|sPitd6idj|�d6d6SnU|rPtdd
|d|d	|d
|d|	�sPitd6idj|�d6d6Snt	dd|d|d|d	|d
|d|	�}|j
d�r|ry;td|d	|d
|d|	�}
|
j|d|�}Wn,tk
r�}itd6td|�d6SX||d<n|S(uF
    Given a vpc_id, creates a network acl.

    Returns the network acl id if successful, otherwise returns False.

    .. versionchanged:: 2015.8.0
        Added vpc_name, subnet_id, and subnet_name arguments

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_network_acl 'vpc-6b1fe402'

    ucreateduboto.get_erroruerroruVPC {0} does not exist.umessageu5Only one of subnet_name or subnet_id may be provided.usubnetRRR R!uSubnet {0} does not exist.R*unetwork_aclR:R"uiduassociation_id(
R(RR0RR.RLRR/RKRAR]R+tassociate_network_acl(R"Rtnetwork_acl_nameR�RuR;RRR R!RRR@R?R=tassociation_id((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreate_network_acl�sB


	!
c
C@s�|r�tdd|d|d|d|d|�}|r�|jr�|jdj}y2td|d|d|d|�}	|	j|�Wq�tk
r�q�Xq�ntddd|d	|d|d|d|d|�S(
u�
    Delete a network acl based on the network_acl_id or network_acl_name provided.

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_network_acl network_acl_id='acl-5fb85d36' \
                disassociate=false

    .. code-block:: bash

        salt myminion boto_vpc.delete_network_acl network_acl_name='myacl' \
                disassociate=true

    unetwork_aclR:RRR R!iR9R*(RKtassociationsR�R+tdisassociate_network_aclRRD(
tnetwork_acl_idR�tdisassociateRRR R!tnetwork_aclR�R=((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_network_acl�s*!

cC@sP|rtjd�|}ntdd|d|d|d|d|d|d	|�S(
u�
    Checks if a network acl exists.

    Returns True if the network acl exists or returns False if it doesn't exist.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.network_acl_exists network_acl_id='acl-5fb85d36'
    uWboto_vpc.network_acl_exists: name parameter is deprecated use network_acl_name instead.unetwork_aclR:R*R;RRR R!(R&R8RT(R�R:R�R;RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytnetwork_acl_existss
	cC@sq|rXtd|d|d|d|d|�}|sXitd6idj|�d6d	6Sn|r�td
|d|d|d|d|�}|s�itd6idj|�d6d	6Sny�td|d|d|d|�}|j||�}	|	rtjd||�itd6|	d
6Stjd||�itd6idd6d	6SWn,t	k
rl}
itd6t
d|
�d	6SXdS(u�
    Given a network acl and subnet ids or names, associate a network acl to a subnet.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.associate_network_acl_to_subnet \
                network_acl_id='acl-5fb85d36' subnet_id='subnet-6a1fe403'

    .. code-block:: bash

        salt myminion boto_vpc.associate_network_acl_to_subnet \
                network_acl_id='myacl' subnet_id='mysubnet'

    unetwork_aclRRR R!u
associateduNetwork ACL {0} does not exist.umessageuerrorusubnetuSubnet {0} does not exist.u4Network ACL with id %s was associated with subnet %suidu8Network ACL with id %s was not associated with subnet %suACL could not be assocaited.uboto.get_errorN(R/R0R.R+R�R&R'R3R8RR(R�R�R�RuRRR R!R=R�R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytassociate_network_acl_to_subnets4

!	
	
cC@sCt||f�s!td��nt||f�rBtd��ny�|r�td|d|d|d|d|�}|s�itd6id	j|�d
6d6Sn|s�|r�t||||||�}ntd|d|d|d|�}|j|d|�}	it	d6|	d
6SWn,t
k
r>}
itd6td|
�d6SXdS(u�
    Given a subnet ID, disassociates a network acl.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.disassociate_network_acl 'subnet-6a1fe403'

    u@One (but not both) of subnet_id or subnet_name must be provided.u/Only one of vpc_id or vpc_name may be provided.usubnetRRR R!u
disassociateduSubnet {0} does not exist.umessageuerrorR"uassociation_iduboto.get_errorN(R#RRLR/R0R.R(R+R�R3RR(R�R"RuRRRR R!R=R�R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�Qs&

!cC@s|rd}nd}t||f�s6td��nx9dD]1}t�|dkr=tdj|���q=q=W|r�td	|d
|d|
d|d
|�}n|s�it|6idj|p�|�d6d6St|tj	�r2|dkr�d}q2yt
j|�}Wq2t
jk
r.}t|��q2Xny�t
d
|d|
d|d
|�}|rh|j}n	|j}||||||d|d|d|d|	d|
�}|r�tjd|�ntjd|�i||6SWn,tk
r
}it|6td|�d6SXdS(NureplaceducreateduJOne (but not both) of network_acl_id or network_acl_name must be provided.urule_numberuprotocolurule_actionu
cidr_blocku{0} is required.unetwork_aclRRR R!uNetwork ACL {0} does not exist.umessageuerrorualli����tegresst	icmp_codet	icmp_typetport_range_fromt
port_range_touNetwork ACL entry was %suNetwork ACL entry was not %suboto.get_error(urule_numberuprotocolurule_actionu
cidr_block(R#RtlocalsRR.R/R0R1Rtstring_typestsockettgetprotobynameterrorR+treplace_network_acl_entrytcreate_network_acl_entryR&R'R8RR(R�trule_numbertprotocoltrule_actionReR�R�R�R�R�R�treplaceRRR R!trkeytvR@R=RHtcreated((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_create_network_acl_entryxsJ	

	!		cC@st�}t|�S(u�
    Creates a network acl entry.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_network_acl_entry 'acl-5fb85d36' '32767' \
                'all' 'deny' '0.0.0.0/0' egress=true

    (R�R�(R�R�R�R�ReR�R�R�R�R�R�RRR R!R<((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR��s	cC@st�}tdt|�S(u�

    Replaces a network acl entry.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.replace_network_acl_entry 'acl-5fb85d36' '32767' \
                'all' 'deny' '0.0.0.0/0' egress=true

    R�(R�R�R3(R�R�R�R�ReR�R�R�R�R�R�RRR R!R<((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR��s	cC@sYt||f�s!td��nx9dD]1}t�|dkr(tdj|���q(q(W|r�td|d|d|d|d	|�}n|s�itd
6idj|p�|�d6d
6Syktd|d|d|d	|�}	|	j||d|�}
|
r
t	j
d�n
t	jd�i|
d
6SWn,tk
rT}itd
6t
d|�d
6SXdS(u�
    Deletes a network acl entry.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete_network_acl_entry 'acl-5fb85d36' '32767'

    uJOne (but not both) of network_acl_id or network_acl_name must be provided.urule_numberuegressu{0} is required.unetwork_aclRRR R!udeleteduNetwork ACL {0} does not exist.umessageuerrorR�uNetwork ACL entry was deleteduNetwork ACL was not deleteduboto.get_errorN(urule_numberuegress(R#RR�RR.R/R0R+tdelete_network_acl_entryR&R'R8RR(R�R�R�R�RRR R!R�R=tdeletedR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR��s*


!
cC@szt||||||�}|sIitd6idj|p=|�d6d6Std|d|d|d|d	|d
|d|�S(u
    Creates a route table.

    .. versionchanged:: 2015.8.0
        Added vpc_name argument

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.create_route_table vpc_id='vpc-6b1fe402' \
                route_table_name='myroutetable'
        salt myminion boto_vpc.create_route_table vpc_name='myvpc' \
                route_table_name='myroutetable'
    ucreateduVPC {0} does not exist.umessageuerroruroute_tableR;R"RRR R!(R(R0R.RA(R"Rtroute_table_nameR;RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytcreate_route_tables(cC@s1tddd|d|d|d|d|d|�S(	u�
    Deletes a route table.

    CLI Examples:

    .. code-block:: bash

        salt myminion boto_vpc.delete_route_table route_table_id='rtb-1f382e7d'
        salt myminion boto_vpc.delete_route_table route_table_name='myroutetable'

    R9uroute_tableR:R*RRR R!(RD(troute_table_idR�RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_route_tables
cC@sP|rtjd�|}ntdd|d|d|d|d|d|d	|�S(
u�
    Checks if a route table exists.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.route_table_exists route_table_id='rtb-1f382e7d'

    uWboto_vpc.route_table_exists: name parameter is deprecated use route_table_name instead.uroute_tableR:R*R;RRR R!(R&R8RT(R�R:R�R;RRR R!((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytroute_table_exists,s

	c	C@s#t||f�s!td��nt||||f�sHtd��ny�td|d|d|	d|
�}iid6}
|r�|g|
d<n|r�||
dd	<n|r�x7tj|�D]#\}}||
dd
j|�<q�Wn|j|
�}t|�dkrtd��ni|d
6|d6|d6|d6|d6}x�|djD]�}i|j	d
6|j
d6|jd6|jd6|d6}t
|j��t
|j��A}t|�dkrMtjd|�itd6SqMWtjd|�itd6SWn%tk
r}itd|�d6SXdS(u�
    Checks if a route exists.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.route_exists destination_cidr_block='10.0.0.0/20' gateway_id='local' route_table_name='test'

    uTAt least one of the following must be specified: route table name or route table id.utAt least one of the following must be specified: gateway id, instance id, interface id or VPC peering connection id.RRR R!ufiltersuroute_table_idsutag:Nameutag:{0}iu Found more than one route table.udestination_cidr_blocku
gateway_iduinstance_iduinterface_iduvpc_peering_connection_idiuRoute %s exists.uexistsuRoute %s does not exist.uboto.get_erroruerrorN(RMRR+RRNR.tget_all_route_tablesRGtroutestdestination_cidr_blockt
gateway_idtinstance_idtinterface_idR�titemsR&R'R3R8R0RR(R�R�R�R�R�RR;RRR R!tvpc_peering_connection_idR=RJRORPtroute_tablestroute_checktroute_matcht
route_dictt
route_compR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytroute_existsDsH!







"cC@szt||f�r!td��n|rytd|d|d|d|d|�}|syitd6idj|�d	6d
6Snt||f�r�td��n|r�td|d|d|d|d|�}|s�itd6id
j|�d	6d
6SnyUtd|d|d|d|�}|j||�}	tjd||�i|	d6SWn,t	k
ru}
itd6t
d|
�d
6SXdS(uv
    Given a route table and subnet name or id, associates the route table with the subnet.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.associate_route_table 'rtb-1f382e7d' 'subnet-6a1fe403'

    .. code-block:: bash

        salt myminion boto_vpc.associate_route_table route_table_name='myrtb' \
                subnet_name='mysubnet'

    u5Only one of subnet_name or subnet_id may be provided.usubnetRRR R!u
associateduSubnet {0} does not exist.umessageuerroru?Only one of route_table_name or route_table_id may be provided.uroute_tableuRoute table {0} does not exist.u,Route table %s was associated with subnet %suassociation_iduboto.get_errorN(RLRR/R0R.R+tassociate_route_tableR&R'RR(R�R�R�RuRRR R!R=R�R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR	�s4

!	
c	C@s�yjtd|d|d|d|�}|j|�rNtjd|�itd6Stjd|�itd6SWn,tk
r�}itd6td|�d	6SXd
S(u�
    Dissassociates a route table.

    association_id
        The Route Table Association ID to disassociate

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.disassociate_route_table 'rtbassoc-d8ccddba'

    RRR R!u:Route table with association id %s has been disassociated.u
disassociatedu>Route table with association id %s has not been disassociated.uboto.get_erroruerrorN(	R+tdisassociate_route_tableR&R'R3R8R0RR(R�RRR R!R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR
�s!c	C@s�y\td|d|d|d|�}|j||�}tjd||�itd6|d6SWn,tk
r�}itd6td|�d	6SXd
S(u�
    Replaces a route table association.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.replace_route_table_association 'rtbassoc-d8ccddba' 'rtb-1f382e7d'

    RRR R!u6Route table %s was reassociated with association id %sureplaceduassociation_iduboto.get_erroruerrorN(R+t*replace_route_table_association_with_assocR&R'R3RR0R(R�R�RRR R!R=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytreplace_route_table_association�s!	
cC@sVt||f�s!td��nt||||||
|||f	�sWtd��n|d"krrtd��ny�|r�td|d|	d|
d|d|�}|s�itd	6id
j|�d6d6Sn|r%td
|d|	d|
d|d|�}|s%itd	6idj|�d6d6Sn|r}td|d|	d|
d|d|�}|s}itd	6idj|�d6d6Sn|r�td|d|	d|
d|d|�}|s�itd	6idj|�d6d6S|dd}
n|rItd|d|	d|
d|d|�}|s8itd	6idj|�d6d6S|dd}
nWn,tk
rx}itd	6td|�d6SX|
s�t	dd|d|d|d|d|d|d|	d|
d|d|�
Sy^t
d|	d|
d|d|�}|jd|d|d |
�}itd	6|j
d�d!6SWn,tk
rQ}itd	6td|�d6SXd"S(#u�
    Creates a route.

    If a nat gateway is specified, boto3 must be installed

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.create_route 'rtb-1f382e7d' '10.0.0.0/16' gateway_id='vgw-a1b2c3'

    uJOne (but not both) of route_table_id or route_table_name must be provided.u�Only one of gateway_id, internet_gateway_name, instance_id, interface_id, vpc_peering_connection_id, nat_gateway_id, nat_gateway_subnet_id, nat_gateway_subnet_name or vpc_peering_connection_name may be provided.u#destination_cidr_block is required.uroute_tableRRR R!ucreateduroute table {0} does not exist.umessageuerroruinternet_gatewayu$internet gateway {0} does not exist.uvpc_peering_connectionu*VPC peering connection {0} does not exist.Ruu#nat gateway for {0} does not exist.iuNatGatewayIdR�uboto.get_errorurouteR�R�R�R�RRtRouteTableIdtDestinationCidrBlockR�uidN(R#RRR/R0R.R�RRRAR|tcreate_routeR3R](R�R�R�R�R�R�RRtvpc_peering_connection_nameRRR R!R�tnat_gateway_subnet_nametnat_gateway_subnet_idtgwsR@R�Rr((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�sv




!	cC@s�t||f�s!td��n|dkr<td��ny\|r�td|d|d|d|d|�}|s�itd6id	j|�d
6d6SnWn,tk
r�}itd6td|�d6SXtd
dd|d|d|d|d|d|�S(u�
    Deletes a route.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.delete_route 'rtb-1f382e7d' '10.0.0.0/16'

    uJOne (but not both) of route_table_id or route_table_name must be provided.u#destination_cidr_block is required.uroute_tableRRR R!ucreateduroute table {0} does not exist.umessageuerroruboto.get_errorR9urouteR*R�N(	R#RRR/R0R.RRRD(R�R�R�RRR R!R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdelete_routeN	s$
c
C@sRt||f�s!td��n|dkr<td��ny�|r�td|d|d|d|d|	�}|s�itd6id	j|�d
6d6Sntd|d|d|d|	�}|j||d|d
|d|d|
�rtj	d||�it
d6Stjd||�itd6SWn,tk
rM}itd6t
d|�d6SXdS(u�
    Replaces a route.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.replace_route 'rtb-1f382e7d' '10.0.0.0/16' gateway_id='vgw-a1b2c3'

    uJOne (but not both) of route_table_id or route_table_name must be provided.u#destination_cidr_block is required.uroute_tableRRR R!ureplaceduroute table {0} does not exist.umessageuerrorR�R�RRu7Route with cidr block %s on route table %s was replacedu;Route with cidr block %s on route table %s was not replaceduboto.get_errorN(R#RRR/R0R.R+t
replace_routeR&R'R3R8RR(
R�R�R�R�R�RRRR R!RR=R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyRt	s4
!

c	C@s�tjjjdd�t|||f�s:td��ny�td|d|d|d|�}iid6}|r~||d	<n|r�||dd
<n|r�x7tj|�D]#\}	}
|
|ddj	|	�<q�Wn|j
|�}|s�iSi}dd
dddg}
dddddg}ddddg}x�|D]�}x}|
D]u}t||�rDt||�||<|dkr�t
|||�||<n|dkr�t
|||�||<q�qDqDWq7W|SWn%tk
r�}itd|�d6SXdS(u�
    Given route table properties, return route table details if matching table(s) exist.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe_route_table route_table_id='rtb-1f382e7d'

    uNeonu^The 'describe_route_table' method has been deprecated and replaced by 'describe_route_tables'.u[At least one of the following must be specified: route table id, route table name, or tags.RRR R!ufiltersuroute_table_idsutag:Nameutag:{0}uiduvpc_idutagsuroutesuassociationsudestination_cidr_blocku
gateway_iduinstance_iduinterface_iduvpc_peering_connection_idumainuroute_table_idu	subnet_iduboto.get_erroruerrorN(R
RRt
warn_untilRMRR+RRNR.R�R�R,t	_key_iterRR(R�R�R;RRR R!R=RJRORPRtroute_tableRmt
route_keyst
assoc_keysR�R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdescribe_route_table�	sB!



$c	C@s�t||||f�s'td��ny�td|d|d|d|�}igd6}	|rn|g|	d<n|r�|	djidd	6|gd
6�n|r�|	djidd	6|gd
6�n|rxKtj|�D]7\}
}|	djidj|
�d	6|gd
6�q�Wn|j|	�jd
g�}|s=gSg}
idd6dd6dd6dd6dd6}idd6dd6dd6dd6d d!6d"d#6}id$d6d%d&6dd'6d(d)6}x|D]�}i}x�tj|�D]�\}}||kr�|dkrt	|||�||<q�|dkrCt	|||�||<q�|dkr�i||<xP|j|g�D]&}|jd*�|||jd+�<qlWq�|j|�||<q�q�W|
j|�q�W|
SWn%t
k
r�}itd,|�d-6SXd.S(/u!
    Given route table properties, return details of all matching route tables.

    This function requires boto3 to be installed.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe_route_tables vpc_id='vpc-a6a9efc3'

    ucAt least one of the following must be specified: route table id, route table name, vpc_id, or tags.RRR R!uFiltersu
RouteTableIdsuvpc-iduNameuValuesutag:Nameutag:{0}uRouteTablesuRouteTableIduiduVpcIduvpc_iduTagsutagsuRoutesuroutesuAssociationsuassociationsuDestinationCidrBlockudestination_cidr_blocku	GatewayIdu
gateway_iduInstanceuinstance_iduNetworkInterfaceIduinterface_iduNatGatewayIdunat_gateway_iduVpcPeeringConnectionIduvpc_peering_connection_iduRouteTableAssociationIduMainumainuroute_table_idu	subnet_iduSubnetIduValueuKeyuboto.get_erroruerrorN(RMRR|RqRRNR.tdescribe_route_tablesR]t
_key_remapRR(R�R�R"R;RRR R!R�RJRORPRttablesRmRRR�RtoutkeytinkeyttagitemR@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR�	sf!
%%







'cC@s(|jd|d|d|d|d|�S(NR�R�R�R�R�(R�(R=R�R�R�R�R�((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_create_dhcp_options:
scC@s0|r,|jd|�tjd||�ndS(NuNameu%s is now named as %s(tadd_tagR&RV(R:tobj((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR5A
scC@s{|rwy|j|�Wn>tk
rWx.|j�D]\}}|j||�q4WnXtjddj|�|�ndS(Nu'The following tags: %s were added to %su, (tadd_tagsR-RR#R&RVRZ(R;R$ttagtvalue((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR6G
s
cC@sh|r2|jd|d|�tjd||�n|rd|jd|d|�tjd||�ndS(NR"Rfu$DNS support was set to: %s on vpc %sRgu&DNS hostnames was set to: %s on vpc %s(tmodify_vpc_attributeR&RV(R=tvpcidtdns_supportt
dns_hostnames((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyRcS
scC@s�|jdi|d6�}|s0tjd�dSd}xG|D]?}x6t|di�D]"}t|dt�rV|}PqVqVWq=W|s�tjd�dSdj|�}t||�tjd||�dS(Ntfiltersuvpc_iduno default route table founduassociationsumainu{0}-default-tableu1Default route table name was set to: %s on vpc %s(	R�R&R8RR,R0R.R5RV(R=R)RRt
default_tablettabletassociationR:((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyRd\
s 



cC@smg}x`t||�D]O}i}x3|D]+}t||�r)t||�||<q)q)W|j|�qW|S(N(R,R�Rq(RRmR�t
elements_listtr_itemtelementtr_key((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyRp
s
cC@s|g}xo|j|g�D][}i}x?tj|�D].\}}||kr5|j|�||<q5q5W|j|�qW|S(N(R]RRNRq(RRmR�R0R1R2tr_outkeytr_inkey((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR{
sc
	C@s�|s*td|d|d|d|�}n|r�|jdi|d6�}xE|D]:}x1|jD]&}	|	j|kr`|	jr`|	jSq`WqPWndS(uk
    helper function to find subnet explicit route table associations

    .. versionadded:: 2016.11.0
    RRR R!R,uvpc_idN(R+R�R�R�tmainR4R(
R�R"R=RRR R!tvpc_route_tablestvpc_route_tabletrt_association((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR��
s$
cC@satd|d|d|d|	�}|rEt||�rEtd��nt||f�sftd��nt||f�s�td��n|r�td|d|d|d|d|	�}|s�id	j|�d
6Sn|rtd|d|d|d|d|	�}|sid	j|�d
6Snytjd�|sR|jd|d
|d|
�}n$|jd|d
|d|d|
�}|j	di�}
|
j	dd�}dj|�}tj|�|rtjd�|j
d|gdidd6|d6g�tjd�|dj|�7}ni|d6SWn8tjj
k
r\}tjd�itd|�d
6SXdS( u�
    Request a VPC peering connection between two VPCs.

    .. versionadded:: 2016.11.0

    requester_vpc_id
        ID of the requesting VPC. Exclusive with requester_vpc_name.

    requester_vpc_name
        Name tag of the requesting VPC.  Exclusive with requester_vpc_id.

    peer_vpc_id
        ID of the VPC to create VPC peering connection with. This can be a VPC in
        another account. Exclusive with peer_vpc_name.

    peer_vpc_name
        Name tag of the VPC to create VPC peering connection with. This can only
        be a VPC in the same account, else resolving it into a vpc ID will almost
        certainly fail. Exclusive with peer_vpc_id.

    name
        The name to use for this VPC peering connection.

    peer_owner_id
        ID of the owner of the peer VPC. Defaults to your account ID, so a value
        is required if peering with a VPC in a different account.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    dry_run
        If True, skip application and return status.

    CLI Example:

    .. code-block:: bash

        # Create a named VPC peering connection
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da name=my_vpc_connection
        # Without a name
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da
        # Specify a region
        salt myminion boto_vpc.request_vpc_peering_connection vpc-4a3e622e vpc-be82e9da region=us-west-2

    RRR R!uXA VPC peering connection with this name already exists! Please specify a different name.uAExactly one of requester_vpc_id or requester_vpc_name is requiredu8Exactly one of peer_vpc_id or peer_vpc_name is required.Ru'Could not resolve VPC name {0} to an IDuerroru(Trying to request vpc peering connectiontVpcIdt	PeerVpcIdtDryRuntPeerOwnerIduVpcPeeringConnectionuVpcPeeringConnectionIduERRORuVPC peering {0} requested.u)Adding name tag to vpc peering connectiont	ResourcestTagsuNameuKeyuValueu*Applied name tag to vpc peering connectionu With name {0}.umsgu0Got an error while trying to request vpc peeringuboto.get_errorN(R|t_vpc_peering_conn_id_for_nameRR#R$R.R&RVtcreate_vpc_peering_connectionR]tcreate_tagstbotocoret
exceptionstClientErrorR�R(trequester_vpc_idtrequester_vpc_nametpeer_vpc_idt
peer_vpc_nameR:t
peer_owner_idRRR R!tdry_runR=tvpc_peeringtpeeringtpeering_conn_idtmsgR^((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytrequest_vpc_peering_connection�
sZ;	
			

		

cC@smidd6|gd6idd6tttgd6g}|jd|�jdg�}g|D]}|d^qYS(u
    :param name: The name of the VPC peering connection.
    :type name: String
    :param conn: The boto aws ec2 connection.
    :return: The id associated with this peering connection

    Returns the VPC peering connection ids
    given the VPC peering connection name.
    utag:NameuNameuValuesustatus-codetFiltersuVpcPeeringConnectionsuVpcPeeringConnectionId(tACTIVEtPENDING_ACCEPTANCEtPROVISIONINGt describe_vpc_peering_connectionsR](R:R=R,tpeeringstx((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt_get_peering_connection_idss

		c	C@s5td|d|d|d|�}it||�d6S(u
    Returns any VPC peering connection id(s) for the given VPC
    peering connection name.

    VPC peering connection ids are only returned for connections that
    are in the ``active``, ``pending-acceptance`` or ``provisioning``
    state.

    .. versionadded:: 2016.11.0

    :param name: The string name for this VPC peering connection
    :param region: The aws region to use
    :param key: Your aws key
    :param keyid: The key id associated with this aws account
    :param profile: The profile to use
    :return: dict

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.describe_vpc_peering_connection salt-vpc
        # Specify a region
        salt myminion boto_vpc.describe_vpc_peering_connection salt-vpc region=us-west-2

    RRR R!uVPC-Peerings(R|RX(R:RRR R!R=((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytdescribe_vpc_peering_connection$s	uc		C@s�t||f�s!td��ntd|d|d|d|�}|rxt||�}|sxtdj|���qxny2tjd�|jd|d	|�id
d6SWn8tj	j
k
r�}tjd�itd
|�d6SXdS(u�
    Request a VPC peering connection between two VPCs.

    .. versionadded:: 2016.11.0

    :param conn_id: The ID to use. String type.
    :param name: The name of this VPC peering connection. String type.
    :param region: The AWS region to use. Type string.
    :param key: The key to use for this connection. Type string.
    :param keyid: The key id to use.
    :param profile: The profile to use.
    :param dry_run: The dry_run flag to set.
    :return: dict

    Warning: Please specify either the ``vpc_peering_connection_id`` or
    ``name`` but not both. Specifying both will result in an error!

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.accept_vpc_peering_connection name=salt-vpc
        # Specify a region
        salt myminion boto_vpc.accept_vpc_peering_connection name=salt-vpc region=us-west-2
        # specify an id
        salt myminion boto_vpc.accept_vpc_peering_connection conn_id=pcx-8a8939e3

    uIOne (but not both) of vpc_peering_connection_id or name must be provided.RRR R!u�No ID found for this VPC peering connection! ({0}) Please make sure this VPC peering connection exists or invoke this function with a VPC peering connection IDu'Trying to accept vpc peering connectionR<tVpcPeeringConnectionIdu VPC peering connection accepted.umsgu/Got an error while trying to accept vpc peeringuboto.get_erroruerrorN(
R#RR|R@R.R&RVtaccept_vpc_peering_connectionRCRDRER�R(	tconn_idR:RRR R!RKR=R^((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR[Js$$		
	
cC@s`tjd�t||�}|s.dg}n*t|�dkrXtdj|���n|dS(u.
    Get the ID associated with this name
    u$Retrieving VPC peering connection idiu�Found multiple VPC peering connections with the same name!! Please make sure you have only one VPC peering connection named {0} or invoke this function with a VPC peering connection IDiN(R&RVRXRRGRR.(R:R=tids((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR@�s
	c
	C@s�t||f�s!td��ntd|d|d|d|�}|rxt||�}|sxtdj|���qxny2tjd�|jd|d	|�id
d6SWnJtj	j
k
r�}td|�}	tjd
|p�||	�i|	d6SXdS(u�
    Delete a VPC peering connection.

    .. versionadded:: 2016.11.0

    conn_id
        The connection ID to check.  Exclusive with conn_name.

    conn_name
        The connection name to check.  Exclusive with conn_id.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    dry_run
        If True, skip application and simply return projected status.

    CLI Example:

    .. code-block:: bash

        # Create a named VPC peering connection
        salt myminion boto_vpc.delete_vpc_peering_connection conn_name=salt-vpc
        # Specify a region
        salt myminion boto_vpc.delete_vpc_peering_connection conn_name=salt-vpc region=us-west-2
        # specify an id
        salt myminion boto_vpc.delete_vpc_peering_connection conn_id=pcx-8a8939e3

    u5Exactly one of conn_id or conn_name must be provided.RRR R!u4Couldn't resolve VPC peering connection {0} to an IDu'Trying to delete vpc peering connectionR<RZuVPC peering connection deleted.umsguboto.get_erroru#Failed to delete VPC peering %s: %suerrorN(
R#RR|R@R.R&RVtdelete_vpc_peering_connectionRCRDRERR�(
R\t	conn_nameRRR R!RKR=R^R@((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyR^�s )!	
c
	C@st||f�s!td��ntd|d|d|d|�}|rl|jd|g�jdg�}nRidd	6|gd
6idd	6tttgd
6g}|jd|�jdg�}|s�tSt	|�d
kr�tdj
|p�|���n|ddd}	|	tkS(ui
    Check if a VPC peering connection is in the pending state.

    .. versionadded:: 2016.11.0

    conn_id
        The connection ID to check.  Exclusive with conn_name.

    conn_name
        The connection name to check.  Exclusive with conn_id.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.is_peering_connection_pending conn_name=salt-vpc
        # Specify a region
        salt myminion boto_vpc.is_peering_connection_pending conn_name=salt-vpc region=us-west-2
        # specify an id
        salt myminion boto_vpc.is_peering_connection_pending conn_id=pcx-8a8939e3

    u5Exactly one of conn_id or conn_name must be provided.RRR R!tVpcPeeringConnectionIdsuVpcPeeringConnectionsutag:NameuNameuValuesustatus-codeRQiujFound more than one ID for the VPC peering connection ({0}). Please call this function with an ID instead.iuStatusuCode(R#RR|RUR]RRRSRTR0RGR.(
R\R_RRR R!R=RXR,tstatus((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pytis_peering_connection_pending�s%!$ 	cC@s�t||f�s!td��nt||f�sBtd��n|r�td|d|d|d|d|�}|s�tjd|�tSntd|d|d|d|�}id	d
6|gd6idd
6ttt	gd6g}	|r|	id
d
6|gd6g7}	n|	idd
6|gd6g7}	|j
d|	�jdg�}
|
sNtSt|
�dkr~tdj
|pr|���n|
ddd}t|tk�S(u�
    Check if a VPC peering connection is in the pending state, and requested from the given VPC.

    .. versionadded:: 2016.11.0

    conn_id
        The connection ID to check.  Exclusive with conn_name.

    conn_name
        The connection name to check.  Exclusive with conn_id.

    vpc_id
        Is this the ID of the requesting VPC for this peering connection.  Exclusive with vpc_name.

    vpc_name
        Is this the Name of the requesting VPC for this peering connection.  Exclusive with vpc_id.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_vpc.is_peering_connection_pending name=salt-vpc

    u5Exactly one of conn_id or conn_name must be provided.u3Exactly one of vpc_id or vpc_name must be provided.RRRR R!u&Could not resolve VPC name %s to an IDurequester-vpc-info.vpc-iduNameuValuesustatus-codeuvpc-peering-connection-idutag:NameRQuVpcPeeringConnectionsiujFound more than one ID for the VPC peering connection ({0}). Please call this function with an ID instead.iuStatusuCode(R#RR(R&R8R0R|RRRSRTRUR]RGR.R2(R\R_R"RRRR R!R=R,RXRa((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt#peering_connection_pending_from_vpcs.('! !	(upendingu	available(upendingu	available(upendingu	available(tt__doc__t
__future__RRRtloggingR�R�R�tsalt.utils.compatR
tsalt.utils.versionstsalt.exceptionsRRRTRSRRt	getLoggerRR&tsalt.extRtsalt.ext.six.movesRtbotoRCtboto.vpctboto.exceptionRtsetLeveltCRITICALR3RtImportErrorR0tboto3RRRRR(RARDRKRQR/RSRTR%R$R\R`RhRjRpRsRxR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RR	R
RRRRRRR"R5R6RcRdRRR�RPRXRYR[R@R^RbRc(((s9/usr/lib/python2.7/site-packages/salt/modules/boto_vpc.pyt<module>{s�





		1	+	/	&		(	*169"		'@	-	%B(33		4	J	.& 			:	#	0&				1							&		B	1Y	$/;S								r	#:		<	<		

Zerion Mini Shell 1.0