File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_vpc.cpython-310.pyc
Back
o ;jC� � @ sz d Z ddlZddlZddlZddlZddlZddlZddlm Z m Z dZdZdZ e�e�ZzddlZddlZddlZddlmZ e�d��ej� d ZW n eyW d ZY nw zddlZe�d��ej� d ZW n eyt d ZY nw dd � Zdd� Z d�dd�Z d�dd�Z d�dd�Z d�dd�Z! d�dd�Z"d�dd�Z# d�dd�Z$ d�dd�Z% d�d d!�Z& d�d"d#�Z' d�d$d%�Z( d�d&d'�Z) d�d(d)�Z* d�d*d+�Z+ d�d,d-�Z, d�d.d/�Z-d�d0d1�Z. d�d2d3�Z/ d�d4d5�Z0 d�d6d7�Z1d�d8d9�Z2 d�d:d;�Z3 d�d<d=�Z4 d�d>d?�Z5 d�d@dA�Z6 B d�dCdD�Z7 B d�dEdF�Z8 B d�dGdH�Z9 d�dIdJ�Z: Kd�dLdM�Z; d�dNdO�Z< d�dPdQ�Z= d�dRdS�Z> d�dTdU�Z? d�dVdW�Z@ d�dXdY�ZA d�dZd[�ZB d�d\d]�ZC d�d^d_�ZD d�d`da�ZE d�dbdc�ZF d�ddde�ZG d�dfdg�ZH d�dhdi�ZI d�djdk�ZJ d�dldm�ZK d�dndo�ZL d�dpdq�ZM d�drds�ZN d�dtdu�ZO d�dvdw�ZP d�dxdy�ZQ d�dzd{�ZR d�d|d}�ZS d�d~d�ZT d�d�d��ZU d�d�d��ZV d�d�d��ZW d�d�d��ZXd�d�� ZYd�d�� ZZd�d�� Z[d�d�� Z\d�d�� Z]d�d�� Z^ d�d�d��Z_ d�d�d��Z`d�d�� Za d�d�d��Zb d�d�d��Zcd�d�� Zd d�d�d��Ze d�d�d��Zf d�d�d��ZgdS )�at 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 � N)�CommandExecutionError�SaltInvocationErrorZprovisioningzpending-acceptanceZactive)�BotoServerError�botoTF�boto3c C s t jjjddd�S )zg Only load if boto libraries exist and if boto libraries are greater than a given version. z2.8.0z1.2.6)Zboto_verZ boto3_ver)�salt�utilsZversionsZcheck_boto_reqs� r r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_vpc.py�__virtual__� s r c C s8 t rtd tdtd� trtd tdddd d� d S d S ) Nzboto.assign_funcs�vpc)�packzboto3.assign_funcsZec2� _get_conn3Z _cache_id3)Zget_conn_funcnameZcache_id_funcnameZexactly_one_funcname)�HAS_BOTO� __utils__�__name__Z__salt__� HAS_BOTO3)�optsr r r �__init__� s ��r c C sT t || f�s td��|rt|||||d�} | S t| ||||d�s(t�d| � dS | S )a� 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 z:One (but not both) of vpc_id or vpc_name must be provided.��vpc_name�region�key�keyid�profile)�vpc_idr r r r zVPC %s does not exist.N)�_exactly_oner �_get_id� _find_vpcs�log�info�r r r r r r r r r � check_vpc� s � �� �r"