%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s(dZddlmZmZmZddlZeje�Zd�Z	d�Z
ddddddddeddddddddddd�Z
ddddddddd�Zd�Zeddddd	�Zd
�Zdddddd�Zdddddd�Zdddddd
�ZdS(u

Manage Elasticache
==================

.. versionadded:: 2014.7.0

Create, destroy and update Elasticache clusters. Be aware that this interacts
with Amazon's services, and so may incur charges.

Note: This module currently only supports creation and deletion of
elasticache resources and will not modify clusters when their configuration
changes in your state files.

This module uses ``boto``, which can be installed via package, or pip.

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 `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 file or
in the minion's config file:

.. code-block:: yaml

    elasticache.keyid: GKTADJGHEIQSXMKKRBJ08H
    elasticache.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

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

.. code-block:: yaml

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

.. code-block:: yaml

    Ensure myelasticache exists:
      boto_elasticache.present:
        - name: myelasticache
        - engine: redis
        - cache_node_type: cache.t1.micro
        - num_cache_nodes: 1
        - notification_topic_arn: arn:aws:sns:us-east-1:879879:my-sns-topic
        - region: us-east-1
        - keyid: GKTADJGHEIQSXMKKRBJ08H
        - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    # Using a profile from pillars
    Ensure myelasticache exists:
      boto_elasticache.present:
        - name: myelasticache
        - engine: redis
        - cache_node_type: cache.t1.micro
        - num_cache_nodes: 1
        - notification_topic_arn: arn:aws:sns:us-east-1:879879:my-sns-topic
        - region: us-east-1
        - profile: myprofile

    # Passing in a profile
    Ensure myelasticache exists:
      boto_elasticache.present:
        - name: myelasticache
        - engine: redis
        - cache_node_type: cache.t1.micro
        - num_cache_nodes: 1
        - notification_topic_arn: arn:aws:sns:us-east-1:879879:my-sns-topic
        - region: us-east-1
        - profile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsNcC@sdtkrdStSdS(u)
    Only load if boto is available.
    uboto_elasticache.existsuboto_elasticacheN(t__salt__tFalse(((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pyt__virtual__VscO@s
t||�S(N(tpresent(targstkwargs((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytcache_cluster_present`sc*C@s(i|d6td6dd6id6}|r�|r�td|||||�}|d}|
scg}
ntdd	|d
|d|d|d
|d|�}|
j|�d(}ntd|||||�}|d(kr�d}||d<d(|d<|S|stdr'dj|�}||d<d(|d<|Stdd|d|d|d|d|d|d|d|d|d|
d|d|d |d!|
d"|	d#|d|d|d
|d|�}|r�d(|dd$<td|||||�}||dd%<q$t|d<d&j|�|d<|Snd'j|�|d<|S()us
    Ensure the cache cluster exists.

    name
        Name of the cache cluster (cache cluster id).

    engine
        The name of the cache engine to be used for this cache cluster. Valid
        values are memcached or redis.

    cache_node_type
        The compute and memory capacity of the nodes in the cache cluster.
        cache.t1.micro, cache.m1.small, etc. See: https://boto.readthedocs.io/en/latest/ref/elasticache.html#boto.elasticache.layer1.ElastiCacheConnection.create_cache_cluster

    num_cache_nodes
        The number of cache nodes that the cache cluster will have.

    preferred_availability_zone
        The EC2 Availability Zone in which the cache cluster will be created.
        All cache nodes belonging to a cache cluster are placed in the
        preferred availability zone.

    port
        The port number on which each of the cache nodes will accept
        connections.

    cache_parameter_group_name
        The name of the cache parameter group to associate with this cache
        cluster. If this argument is omitted, the default cache parameter group
        for the specified engine will be used.

    cache_security_group_names
        A list of cache security group names to associate with this cache
        cluster. Use this parameter only when you are creating a cluster
        outside of a VPC.

    replication_group_id
        The replication group to which this cache cluster should belong. If
        this parameter is specified, the cache cluster will be added to the
        specified replication group as a read replica; otherwise, the cache
        cluster will be a standalone primary that is not part of any
        replication group.

    auto_minor_version_upgrade
        Determines whether minor engine upgrades will be applied automatically
        to the cache cluster during the maintenance window. A value of True
        allows these upgrades to occur; False disables automatic upgrades.

    security_group_ids
        One or more VPC security groups associated with the cache cluster. Use
        this parameter only when you are creating a cluster in a VPC.

    cache_subnet_group_name
        The name of the cache subnet group to be used for the cache cluster.
        Use this parameter only when you are creating a cluster in a VPC.

    engine_version
        The version number of the cache engine to be used for this cluster.

    notification_topic_arn
        The Amazon Resource Name (ARN) of the Amazon Simple Notification
        Service (SNS) topic to which notifications will be sent. The Amazon SNS
        topic owner must be the same as the cache cluster owner.

    preferred_maintenance_window
        The weekly time range (in UTC) during which system maintenance can
        occur. Example: sun:05:00-sun:09:00

    wait
        Boolean. Wait for confirmation from boto that the cluster is in the
        available state.

    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.
    unameuresultuucommentuchangesu'boto_elasticache.get_cache_subnet_groupuvpc_idu"boto_secgroup.convert_to_group_idstgroupstvpc_idtregiontkeytkeyidtprofileuboto_elasticache.get_configu/Failed to retrieve cache cluster info from AWS.utestu'Cache cluster {0} is set to be created.uboto_elasticache.createtnametnum_cache_nodestcache_node_typetenginetreplication_group_idtengine_versiontcache_parameter_group_nametcache_subnet_group_nametcache_security_group_namestsecurity_group_idstpreferred_availability_zonetpreferred_maintenance_windowtporttnotification_topic_arntauto_minor_version_upgradetwaituoldunewu#Failed to create {0} cache cluster.uCache cluster {0} is present.N(tTrueRtextendtNonet__opts__tformatR(RRRRRRRRRRRRRRRRRR
RRtrett
_subnet_groupRt_security_group_idstconfigtmsgtcreated((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pyRdsjj"
	
	
		





!
c	C@s/i|d6td6dd6id6}	tdd|d|d	|d
|d|d|�}
|
s!td
r�dj|�|	d<d|	d<|	Stdd|d|d|d|d|d	|d
|d|d|�	}|s�t|	d<dj|�|	d<|	Sd|	dd<||	dd<dj|�|	d<|	Sd|	d<|	S(u�
    Ensure ElastiCache subnet group exists.

    .. versionadded:: 2015.8.0

    name
        The name for the ElastiCache subnet group. This value is stored as a lowercase string.

    subnet_ids
        A list of VPC subnet IDs for the cache subnet group.  Exclusive with subnet_names.

    subnet_names
        A list of VPC subnet names for the cache subnet group.  Exclusive with subnet_ids.

    description
        Subnet group description.

    tags
        A list of tags.

    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.
    unameuresultuucommentuchangesu$boto_elasticache.subnet_group_existsRttagsRR
RRutestu&Subnet group {0} is set to be created.u$boto_elasticache.create_subnet_groupt
subnet_idstsubnet_namestdescriptionu"Failed to create {0} subnet group.uoldunewuSubnet group {0} created.uSubnet group present.N(R RR#R$R"R(RR,R-R.R+RR
RRR%texistsR*((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytsubnet_group_present
s4$

"

	

cO@s
t||�S(N(tabsent(RR((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytcache_cluster_absentLsc	C@s�i|d6td6dd6id6}td|||||�}|r�tdrodj|�|d<d|d<|Std	||||||�}|r�||dd
<d|dd<q�t|d<dj|�|d<nd
j||�|d<|S(u�
    Ensure the named elasticache cluster is deleted.

    name
        Name of the cache cluster.

    wait
        Boolean. Wait for confirmation from boto that the cluster is in the
        deleting state.

    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.
    unameuresultuucommentuchangesuboto_elasticache.existsutestu'Cache cluster {0} is set to be removed.uboto_elasticache.deleteuoldunewu#Failed to delete {0} cache cluster.u{0} does not exist in {1}.N(R RR#R$R"R(	RRRR
RRR%t
is_presenttdeleted((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pyR1Ps "


cO@s
t||�S(N(tcreategroup(RR((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytreplication_group_present~sc	C@si|d6dd6dd6id6}td|||||�}	|	s�tdrndj|�|d<d|d<ntd	||||||||�}
|
r�td
|||||�}d|dd<||dd<t|d<qt|d<d
j|�|d<ndj|�|d<t|d<|S(u
    Ensure the a replication group is create.

    name
        Name of replication group

    wait
        Waits for the group to be available

    primary_cluster_id
        Name of the master cache node

    replication_group_description
        Description for the group

    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.
    unameuresultuucommentuchangesuboto_elasticache.group_existsutestu%Replication {0} is set to be created.u)boto_elasticache.create_replication_groupu+boto_elasticache.describe_replication_groupuoldunewu'Failed to create {0} replication group.u{0} replication group exists .N(R"RR#R$R R(Rtprimary_cluster_idtreplication_group_descriptionRRR
RRR%R3R*R(((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pyR5�s*"	






c	
C@si|d6td6dd6id6}tdd|d|d	|d
|d|d|�}|szt|d<d
j|�|d<|Stdr�dj|�|d<d|d<|Std|||||�}|s�t|d<dj|�|d<|S||dd<d|dd<dj|�|d<|S(Nunameuresultuucommentuchangesu$boto_elasticache.subnet_group_existsRR+RR
RRu,{0} ElastiCache subnet group does not exist.utestu2ElastiCache subnet group {0} is set to be removed.u$boto_elasticache.delete_subnet_groupu.Failed to delete {0} ElastiCache subnet group.uoldunewu%ElastiCache subnet group {0} deleted.(R RR$R#R"R(	RR+RR
RRR%R/R4((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytsubnet_group_absent�s.

"



c	C@sHi|d6td6dd6id6}tdd|d|d	|d
|d|�}|s�t|d<dj|�|d<tj|d�|Std
r�dj|�|d<t|d<|Std|||||�}|st|d<tj|d�dj|�|d<|S||dd<d|dd<dj|�|d<tj|d�|S(Nunameuresultuucommentuchangesuboto_elasticache.group_existsRRR
RRu1{0} ElastiCache replication group does not exist.utestu7ElastiCache replication group {0} is set to be removed.u)boto_elasticache.delete_replication_groupu3Failed to delete {0} ElastiCache replication group.uoldunewu*ElastiCache replication group {0} deleted.(	R RR$tlogtinfoR#RterrorR"(	RR+RR
RRR%R/R4((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pytreplication_group_absent�s4





(t__doc__t
__future__RRRtloggingt	getLoggert__name__R:RR	R"R RR0R2R1R6R5R9R=(((s@/usr/lib/python2.7/site-packages/salt/states/boto_elasticache.pyt<module>MsD	
	�	@	.	6

Zerion Mini Shell 1.0