%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyc

�
���^c@@sdZddlmZmZmZddlZddlmZddlZ	ddl
Z	ddlZ	ddlm
Z
eje�ZydddlZddlZddlmZejd�jej�ejd�jej�eZWnek
r�eZnXd	�Zd
�Zddddd�Zddddd�Zddddd
�Z ddddddddddd�
Z!ddddd�Z"dddddddddd�	Z#ddddddd�Z$ddddddd�Z%ddddddd�Z&dS(u�
Connection module for Amazon Elasticsearch Service

.. versionadded:: 2016.11.0

:configuration: This module accepts explicit AWS credentials but can also
    utilize IAM roles assigned to the instance trough 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

        lambda.keyid: GKTADJGHEIQSXMKKRBJ08H
        lambda.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    A region may also be specified in the configuration:

    .. code-block:: yaml

        lambda.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

    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_function`) return:

    .. code-block:: yaml

        domain:
          - {...}
          - {...}

    or

    .. code-block:: yaml

        error:
          message: error message

:depends: boto3

i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tSaltInvocationError(tClientErrorubotouboto3cC@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.4.0(tsalttutilstversionstcheck_boto_reqs(((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyt__virtual__kscC@s1tjjjt�tr-tdtd�ndS(Nuboto3.assign_funcsues(RR	tcompattpack_dundert__name__tHAS_BOTOt	__utils__(topts((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyt__init__ysc	C@s�td|d|d|d|�}y!|jd|�}itd6SWnTtk
r�}|jjdi�jd�d	kr�itd6Sitd
|�d6SXdS(
u
    Given a domain name, check to see if the given domain exists.

    Returns True if the given domain exists and returns False if the given
    function does not exist.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.exists mydomain

    tregiontkeytkeyidtprofilet
DomainNameuexistsuErroruCodeuResourceNotFoundExceptionuboto3.get_erroruerrorN(t	_get_conntdescribe_elasticsearch_domaintTrueRtresponsetgettFalseR(RRRRRtconntdomainte((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytexistss!$c

C@s�td|d|d|d|�}y�|jd|�}|r�d|kr�|jdi�}d}itg|D]'}||krm||j|�f^qm�d6Sidd6SWn%tk
r�}	itd|	�d6SXdS(u�
    Given a domain name describe its status.

    Returns a dictionary of interesting properties.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.status mydomain

    RRRRRuDomainStatusuEndpointuCreateduDeletedu
DomainNameuDomainIdu
EBSOptionsuSnapshotOptionsuAccessPoliciesu
ProcessinguAdvancedOptionsuARNuElasticsearchVersionudomainuboto3.get_erroruerrorN(uEndpointuCreateduDeletedu
DomainNameuDomainIdu
EBSOptionsuSnapshotOptionsuAccessPoliciesu
ProcessinguAdvancedOptionsuARNuElasticsearchVersion(RRRtdicttNoneRR(
RRRRRRR tkeystkR!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytstatus�s!?c
	C@s�td|d|d|d|�}y�|jd|�}|r�d|kr�|d}d}itg|D]3}||kre||j|i�jd�f^qe�d
6Sidd
6SWn%tk
r�}	itd|	�d6SXdS(u�
    Given a domain name describe its properties.

    Returns a dictionary of interesting properties.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.describe mydomain

    RRRRRuDomainConfiguElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptionsuOptionsudomainuboto3.get_erroruerrorN(uElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptions(Rt$describe_elasticsearch_domain_configR#RR$RR(
RRRRRRR R%R&R!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytdescribe�s!
Kc	C@s�ygtd|d|d|d|	�}i}x�dD]�}
t�|
dk	r1t�|
}t|tj�r�ytjjj	|�}Wq�t
k
r�}itd6dj|
|j
�d
6SXn|||
<q1q1Wd|kr�tjjj|d�|d<nd
|krtj|d
�|d
<n|jd||�}|rNd|krNitd6Stjd�itd6SWn,tk
r�}itd6td|�d
6SXdS(u�
    Given a valid config, create a domain.

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

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.create mydomain \
              {'InstanceType': 't2.micro.elasticsearch', 'InstanceCount': 1, \
              'DedicatedMasterEnabled': false, 'ZoneAwarenessEnabled': false} \
              {'EBSEnabled': true, 'VolumeType': 'gp2', 'VolumeSize': 10, \
              'Iops': 0} \
              {"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "es:*", \
               "Resource": "arn:aws:es:us-east-1:111111111111:domain/mydomain/*", \
               "Condition": {"IpAddress": {"aws:SourceIp": ["127.0.0.1"]}}}]} \
              {"AutomatedSnapshotStartHour": 0} \
              {"rest.action.multi.allow_explicit_index": "true"}
    RRRRuElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptionsuElasticsearchVersionuupdateduError parsing {0}: {1}uerrorRuDomainStatusucreateduDomain was not createduboto3.get_errorN(uElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptionsuElasticsearchVersion(RtlocalsR$t
isinstanceRtstring_typesRR	tjsontloadst
ValueErrorRtformattmessagetdumpst	text_typetcreate_elasticsearch_domainRtlogtwarningRR(RtElasticsearchClusterConfigt
EBSOptionstAccessPoliciestSnapshotOptionstAdvancedOptionsRRRRtElasticsearchVersionRtkwargsR&tvalR!R ((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytcreate�s2!

% 
c	C@ssy@td|d|d|d|�}|jd|�itd6SWn,tk
rn}itd6td|�d6SXd	S(
u
    Given a domain name, delete it.

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

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.delete mydomain

    RRRRRudeleteduboto3.get_erroruerrorN(Rtdelete_elasticsearch_domainRRRR(RRRRRRR!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytdeletes!c
	C@sui}
x�dD]�}t�|dk	r
t�|}t|tj�r�ytjjj|�}Wq�t	k
r�}
it
d6dj||
j�d6SXn||
|<q
q
Wd|
kr�tjjj
|
d�|
d<nyptd	|d
|d|d|	�}|jd
||
�}|sd|kr6tjd�it
d6Sitd6SWn,tk
rp}
it
d6td|
�d6SXdS(u�
    Update the named domain to the configuration.

    Returns {updated: true} if the domain was updated and returns
    {updated: False} if the domain was not updated.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.update mydomain \
              {'InstanceType': 't2.micro.elasticsearch', 'InstanceCount': 1, \
              'DedicatedMasterEnabled': false, 'ZoneAwarenessEnabled': false} \
              {'EBSEnabled': true, 'VolumeType': 'gp2', 'VolumeSize': 10, \
              'Iops': 0} \
              {"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "es:*", \
               "Resource": "arn:aws:es:us-east-1:111111111111:domain/mydomain/*", \
               "Condition": {"IpAddress": {"aws:SourceIp": ["127.0.0.1"]}}}]} \
              {"AutomatedSnapshotStartHour": 0} \
              {"rest.action.multi.allow_explicit_index": "true"}

    uElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptionsuupdateduError parsing {0}: {1}uerrorRRRRRuDomainConfiguDomain was not updateduboto3.get_errorN(uElasticsearchClusterConfigu
EBSOptionsuAccessPoliciesuSnapshotOptionsuAdvancedOptions(R*R$R+RR,RR	R-R.R/RR0R1R2Rt"update_elasticsearch_domain_configR5R6RRR(RR7R8R9R:R;RRRRt	call_argsR&R>R!RR ((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pytupdate"s,

% !
c
K@s�yitd|d|d|d|�}g}xhtj|�D]W\}	}
tj|	�jd�rdq:n|jitj|	�d6tj|
�d6�q:W|dkr,|dkr�td��ntd	|d|d|d|d|�}|s�d
|krt	j
d�itd6S|jd
i�jd
�}n|dk	rGtd��n|j
d|d|�itd6SWn,tk
r�}itd6td|�d6SXdS(u!
    Add tags to a domain

    Returns {tagged: true} if the domain was tagged and returns
    {tagged: False} if the domain was not tagged.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_elasticsearch_domain.add_tags mydomain tag_a=tag_value tag_b=tag_value

    RRRRu__uKeyuValueu6One (but not both) of ARN or domain must be specified.RudomainuDomain tags not updatedutaggeduARNtARNtTagListuboto3.get_erroruerrorN(RRt	iteritemsR3t
startswithtappendR$RR'R5R6RRtadd_tagsRRR(
RRERRRRR=RttagslistR&tvt
domaindataR!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyRJTs.!1	
c
C@s@y
td|d|d|d|�}|dkr�|dkrKtd��ntd|d|d|d|d|�}|s�d|kr�tjd�itd	6S|jdi�jd
�}n|dk	r�td��n|jd|jdi�jd
�d|�it	d	6SWn,t
k
r;}	itd	6td
|	�d6SXdS(u
    Remove tags from a trail

    Returns {tagged: true} if the trail was tagged and returns
    {tagged: False} if the trail was not tagged.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudtrail.remove_tags my_trail tag_a=tag_value tag_b=tag_value

    RRRRu6One (but not both) of ARN or domain must be specified.RudomainuDomain tags not updatedutaggeduARNREtTagKeysuboto3.get_erroruerrorN(RR$RR'R5R6RRtremove_tagsRRR(
RNRRERRRRRRMR!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyROs&!	
$c
C@sryFtd|d|d|d|�}|dkr�|dkrKtd��ntd|d|d|d|d|�}|s�d|kr�tjd�itd	6S|jdi�jd
�}n|dk	r�td��n|jd|�}tj|�|jdg�}	i}
x*|	D]"}|jd
�|
|jd�<qWi|
d6SWn%t	k
rm}it
d|�d6SXdS(u�
    List tags of a trail

    Returns:
        tags:
          - {...}
          - {...}

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudtrail.list_tags my_trail

    RRRRu6One (but not both) of ARN or domain must be specified.RudomainuDomain tags not updatedutaggeduARNREuTagListuValueuKeyutagsuboto3.get_erroruerrorN(RR$RR'R5R6RRt	list_tagsRR(
RRERRRRRRMtretttlistttagdictttagR!((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyRP�s.!	


 ('t__doc__t
__future__RRRtloggingtsalt.extRtsalt.utils.compatRtsalt.utils.jsontsalt.utils.versionstsalt.exceptionsRt	getLoggerRR5tbototboto3tbotocore.exceptionsRtsetLeveltCRITICALRRtImportErrorRRRR$R"R'R)R?RARDRJRORP(((sJ/usr/lib/python2.7/site-packages/salt/modules/boto_elasticsearch_domain.pyt<module>IsH


			3	0*&

Zerion Mini Shell 1.0