%PDF- %PDF-
| Direktori : /proc/thread-self/root/usr/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pyo |
�
���^c @@ su d Z d d l m Z m Z m Z d d l Z d d l m Z d � Z d d d d d � Z d d d d d � Z d S( 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 ( t absolute_importt print_functiont unicode_literalsN( t sixc C@ s d t k r d St S( u)
Only load if boto is available.
u boto_cloudwatch.get_alarmu boto_cloudwatch_alarm( t __salt__t False( ( ( sE /usr/lib/python2.7/site-packages/salt/states/boto_cloudwatch_alarm.pyt __virtual__B s c
C@ sC i | d 6t d 6d d 6i d 6} t d | | | | | � } xJ d d d g D]9 } | | k rN t d
| | | | | | � | | <qN qN Wg } | r�xSt j | � D]2\ } }
| | k r� | j d j | |
� � q� n t j j j |
� }
t j j j | | � } |
| k rq� n t
|
t j � rB|
| k rBq� n t
|
t � ri|
t | � k riq� n t
|
t
� r�|
t
| � k r�q� n t
|
t � r�t |
� t | � k r�q� n | j d j | |
| � � q� Wn
| j d
� i | d 6| d 6| d 6| d 6| d 6} | j | � | r�t | � d k rRd j | � | d <| St d r�d j | � }
|
| d <d | d <| St d | � } | r�| | d d <q?t | d <d j | � | d <nu t d r�d j | � }
|
| d <d | d <| St d | � } | r"| | d d <n t | d <d j | � | 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.
u nameu resultu u commentu changesu boto_cloudwatch.get_alarmu
alarm_actionsu insufficient_data_actionsu
ok_actionsu boto_cloudwatch.convert_to_arnu
{0}={1} (new)u {0}='{1}' was: '{2}'u new alarmu regionu keyu keyidu profilei u alarm {0} present and matchingu testu# alarm {0} is to be created/updated.u&