File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_elasticache.cpython-310.pyc
Back
o ;j*^ � @ s� d Z ddlZddlZddlmZ ddlZddlmZ e� e �ZzddlZddl ZddlZe� d��ej� dZW n eyC dZY nw dd � Zd2d d�Zd2dd �Z d3dd�Zd2dd�Z d3dd�Zd2dd�Zd2dd�Zd2dd�Z d3dd�Z d3dd�Z d3dd�Z d4d d!�Zd2d"d#�Z d2d$d%�Z! d5d&d'�Z"d6d(d)�Z# d2d*d+�Z$d2d,d-�Z% d2d.d/�Z& d2d0d1�Z'dS )7a Connection module for Amazon Elasticache .. versionadded:: 2014.7.0 :configuration: This module accepts explicit elasticache 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 elasticache.keyid: GKTADJGHEIQSXMKKRBJ08H elasticache.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml elasticache.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 � N)�OrderedDict)�SaltInvocationError�botoTFc C s. t jjjdd�} | du rtd tdtd� | S )z, Only load if boto libraries exist. F)Zcheck_boto3Tzboto.assign_funcsZelasticache)�pack)�salt�utilsZversionsZcheck_boto_reqsZ __utils__�__name__�__salt__)Z has_boto_reqs� r �Q/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_elasticache.py�__virtual__G s r c C �V t ||||d�}z|�| � W dS tjjy* } zt�|� W Y d}~dS d}~ww )z� Check to see if a cache cluster exists. CLI Example: .. code-block:: bash salt myminion boto_elasticache.exists myelasticache ��region�key�keyid�profileTNF)� _get_conn�describe_cache_clustersr � exception�BotoServerError�log�debug��namer r r r �conn�er r r �existsR � ��r c C r )z� Check to see if a replication group exists. CLI Example: .. code-block:: bash salt myminion boto_elasticache.group_exists myelasticache r TNF)r �describe_replication_groupsr r r r r r r r r �group_existsf r r c C s� t ||||d�}|sdS z/|�| ||�} |st�d| � W dS t�d� t| ||||�} | s2W dS | d dkr;W dS q tjj ya } zd| � d �}t� |� t�|� i W Y d}~S d}~ww ) z� Create replication group. CLI Example: .. code-block:: bash salt myminion boto_elasticache.create_replication_group myelasticache myprimarycluster description r N�Created cache cluster %s.T� �status� availablez#Failed to create replication group �.)r �create_replication_groupr �info�time�sleep�describe_replication_groupr r r �errorr ) r �primary_cluster_idZreplication_group_description�waitr r r r r �cc�configr �msgr r r r&