File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_asg.cpython-310.pyc
Back
o ;j~� � @ sl d Z ddlZddlZddlZddlZddlZddlmZ ddl Z ddlZ ddlZ e� e�ZdZz>ddlZddlZddlm mZ ddlm mZ ddlZe� d��ej� ddlZddlmZ e� d��ej� dZW n eyx d ZY nw d d� Z dd � Z!d<dd�Z"d<dd�Z# d=dd�Z$ d=dd�Z%dd� Z&dd� Z'd>dd�Z(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,�Z0d<d-d.�Z1d<d/d0�Z2 1 2 3 d@d4d5�Z3d6d7� Z4 d>d8d9�Z5 d>d:d;�Z6dS )Aa� Connection module for Amazon Autoscale Groups .. versionadded:: 2014.7.0 :configuration: This module accepts explicit autoscale 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 at: .. code-block:: text 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 asg.keyid: GKTADJGHEIQSXMKKRBJ08H asg.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml asg.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 :depends: boto :depends: boto3 � N)�OrderedDictz%Y-%m-%dT%H:%M:%SZ�boto)�ClientError�boto3TFc C sF t jj�� } | du r!td tddtd� ttj t dtd d�� | S ) z, Only load if boto libraries exist. Tzboto.assign_funcs�asgz ec2.autoscale)�module�pack� _get_ec2_connzboto.get_connection_func�ec2) �salt�utilsZversionsZcheck_boto_reqs� __utils__�__name__�__salt__�setattr�sys�modules)Z has_boto_reqs� r �I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_asg.py�__virtual__Q s � �r c C s t r td tddd� d S d S )Nzboto3.assign_funcsZautoscaling�_get_conn_autoscaling_boto3)Zget_conn_funcname)�HAS_BOTOr r )�optsr r r �__init__b s ��r c C s� t ||||d�}d} z|j| gd�}|rW dS d|� �}t�|� W dS tjjyY } z'|rI| jdkrIt�d� t� d � |d 8 }W Y d} ~ q t� | � W Y d} ~ dS d} ~ ww )z� Check to see if an autoscale group exists. CLI Example: .. code-block:: bash salt myminion boto_asg.exists myasg region=us-east-1 ��region�key�keyid�profile� T��namesz-The autoscale group does not exist in region F� Throttling�.Throttled by AWS API, retrying in 5 seconds...� � N)� _get_conn�get_all_groups�log�debugr � exception�BotoServerError�code�time�sleep�error) �namer r r r �conn�retriesZ_conn�msg�er r r �existsi s( ��r5 c C sB t ||||d�}d} z�|j| gd�}|r|d }ni W S t� }g d�} | D ]U} | dkrPg }|jD ]}t� } |j| d<