%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_cloudwatch_alarm.pyo

�
���^c@@sudZddlmZmZmZddlZddlmZd�Z	ddddd�Zddddd�ZdS(u�
Manage Cloudwatch alarms

.. versionadded:: 2014.7.0

Create and destroy cloudwatch alarms. 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 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:

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::

    cloudwatch.keyid: GKTADJGHEIQSXMKKRBJ08H
    cloudwatch.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

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

.. code-block:: yaml

    my test alarm:
      boto_cloudwatch_alarm.present:
        - name: my test alarm
        - attributes:
            metric: ApproximateNumberOfMessagesVisible
            namespace: AWS/SQS
            statistic: Average
            comparison: ">="
            threshold: 20000.0
            period: 60
            evaluation_periods: 1
            description: test alarm via salt
            dimensions:
              QueueName:
                - the-sqs-queue-name
            alarm_actions:
              - arn:aws:sns:us-east-1:1111111:myalerting-action
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_cloudwatch.get_alarmuboto_cloudwatch_alarm(t__salt__tFalse(((sE/usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pyt__virtual__Bsc
C@sCi|d6td6dd6id6}td|||||�}xJddd	gD]9}||krNtd
||||||�||<qNqNWg}	|r�xStj|�D]2\}}
||kr�|	jdj||
��q�ntjjj	|
�}
tjjj	||�}|
|krq�nt
|
tj�rB|
|krBq�nt
|
t�ri|
t|�kriq�nt
|
t
�r�|
t
|�kr�q�nt
|
t�r�t|
�t|�kr�q�n|	jdj||
|��q�Wn
|	jd
�i|d6|d6|d6|d6|d6}|j|�|r�t|	�dkrRdj|�|d<|Stdr�dj|�}
|
|d<d|d<|Std|�}|r�|	|dd<q?t|d<dj|�|d<nutdr�dj|�}
|
|d<d|d<|Std|�}|r"||dd<nt|d<dj|�|d<|S(u�
    Ensure the cloudwatch alarm exists.

    name
        Name of the alarm

    attributes
        A dict of key/value cloudwatch alarm 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.
    unameuresultuucommentuchangesuboto_cloudwatch.get_alarmu
alarm_actionsuinsufficient_data_actionsu
ok_actionsuboto_cloudwatch.convert_to_arnu
{0}={1} (new)u{0}='{1}' was: '{2}'u	new alarmuregionukeyukeyiduprofileiualarm {0} present and matchingutestu#alarm {0} is to be created/updated.u&boto_cloudwatch.create_or_update_alarmudiffuFailed to create {0} alarmunewN(tTrueRRt	iteritemstappendtformattsalttutilstdatatdecodet
isinstancetstring_typestfloattinttlisttsortedtupdatetlent__opts__tNoneR(tnamet
attributestregiontkeytkeyidtprofiletrett
alarm_detailstkt
differencetvtv2tcreate_or_update_alarm_argstmsgtresult((sE/usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pytpresentIsz"$!!'#





	



	
cC@s�i|d6td6dd6id6}td|||||�}|r�tdrodj|�|d<d|d<|Std	|||||�}|r�||dd
<d|dd<q�t|d<dj|�|d<nd
j||�|d<|S(ub
    Ensure the named cloudwatch alarm is deleted.

    name
        Name of the alarm.

    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_cloudwatch.get_alarmutestualarm {0} is set to be removed.uboto_cloudwatch.delete_alarmuoldunewuFailed to delete {0} alarm.u{0} does not exist in {1}.N(RRRR
RR(RRRRRRt
is_presenttdeleted((sE/usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pytabsent�s""


(
t__doc__t
__future__RRRtsalt.utils.dataRtsalt.extRRRR(R+(((sE/usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pyt<module>6s	
g

Zerion Mini Shell 1.0