%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_sqs.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
eje�Z
d�Zdddddd�Zddddd�ZdS(u�
Manage SQS Queues

.. versionadded:: 2014.7.0

Create and destroy SQS queues. Be aware that this interacts with Amazon's
services, and so may incur charges.

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

This module accepts explicit SQS 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

    sqs.keyid: GKTADJGHEIQSXMKKRBJ08H
    sqs.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

    myqueue:
        boto_sqs.present:
            - region: us-east-1
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            - attributes:
                ReceiveMessageWaitTimeSeconds: 20

    # Using a profile from pillars
    myqueue:
        boto_sqs.present:
            - region: us-east-1
            - profile: mysqsprofile

    # Passing in a profile
    myqueue:
        boto_sqs.present:
            - region: us-east-1
            - profile:
                keyid: GKTADJGHEIQSXMKKRBJ08H
                key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_sqs.existsuboto_sqs(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_sqs.pyt__virtual__KscC@s�i|d6td6gd6id6}td|d|d|d|d	|�}d
|kryt|d<|dj|d
�|S|dr�|djdj|��n�tdr�d$|d<|djd
j|��id$d6|d6|d<|Std|d|d|d|d|d	|�}d
|krSt|d<|djdj||d
��|S|djdj|��d$|dd<||dd<|S|s�|Std|d|d|d|d	|�}d
|kr�t|d<|djdj|d
��|S|d}i}	xtj|�D]\}
}|j	|
d$�}|
dkr�t
|tj�rktj
jj|�}nt
|tj�r�tj
jj|�}n||krtjd||�tj
jj|dt�|	|
<qqtj|�tj|�krtjd||�||	|
<qqWdj|	�}
|	sE|djd�|S|j�}|j|	�d�}djtj||�jt�||�jt���}tdr�d$|d<|djdj|
|��ii|d6d 6|d<|Std!||	d|d|d|d	|�}d
|krPt|d<|djd"j|d
��|S|djd#j|
��i|d6|dd <|S(%u�
    Ensure the SQS queue exists.

    name
        Name of the SQS queue.

    attributes
        A dict of key/value SQS attributes.

    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.
    unameuresultucommentuchangesuboto_sqs.existstregiontkeytkeyidtprofileuerroruSQS queue {0} present.utestu#SQS queue {0} is set to be created.uoldunewuboto_sqs.createt
attributesu#Failed to create SQS queue {0}: {1}uSQS queue {0} created.uboto_sqs.get_attributesu#Failed to get queue attributes: {0}uPolicyuPolicies differ:
%s
%st	sort_keysuAttributes differ:
%s
%su, u'Queue attributes already set correctly.cS@s*tdd�}td|dtd|�S(u>
        Safely dump YAML using a readable flow style
        uyaml.get_dumperuIndentedSafeOrderedDumperu	yaml.dumptdefault_flow_styletDumper(t	__utils__R(tattrstdumper((s8/usr/lib/python2.7/site-packages/salt/states/boto_sqs.pyt_yaml_safe_dump�s
uu'Attribute(s) {0} set to be updated:
{1}udiffu
attributesuboto_sqs.set_attributesu#Failed to set queue attributes: {0}u#Updated SQS queue attribute(s) {0}.N(tTrueRRtappendtformatt__opts__tNoneRt	iteritemstgett
isinstancetstring_typestsalttutilstjsontloadstlogtdebugtdumpst	text_typetjointcopytupdatetdifflibtunified_difft
splitlines(tnameRRRR	R
trettrtcurrent_attributestattrs_to_settattrtvalt_valt
attr_namestfinal_attributesRtattributes_diff((s8/usr/lib/python2.7/site-packages/salt/states/boto_sqs.pytpresentRs�
	




	

	


%
	




	


c
C@sni|d6td6dd6id6}td|d|d|d	|d
|�}d|kr{t|d<tj|d�|d<|S|ds�dj||�|d<|Std
r�d|d<dj|�|d<i|d6dd6|d<|Std|d|d|d	|d
|�}d|kr;t|d<tj|d�|d<|Sdj|�|d<||dd<d|dd<|S(u_
    Ensure the named sqs queue is deleted.

    name
        Name of the SQS queue.

    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_sqs.existsRRR	R
uerroru$SQS queue {0} does not exist in {1}.utestu#SQS queue {0} is set to be removed.uoldunewuboto_sqs.deleteuSQS queue {0} was deleted.N(RRRRR#RRR(R*RRR	R
R+R,((s8/usr/lib/python2.7/site-packages/salt/states/boto_sqs.pytabsent�sF"	




	
(t__doc__t
__future__RRRR'tloggingtsalt.utils.jsonRtsalt.extRt	getLoggert__name__R RRR5R6(((s8/usr/lib/python2.7/site-packages/salt/states/boto_sqs.pyt<module>;s 		�

Zerion Mini Shell 1.0