%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/telemetry_alert.pyo

�
���^c@@smdZddlmZmZmZddlmZddlmZd�Z	d	dd�Zd	dd�Zd	S(
u"
Manage Telemetry alert configurations
=====================================

.. versionadded:: 2016.3.0

Create, Update and destroy Mongo Telemetry alert configurations.

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

This module accepts explicit credential (telemetry api key)
or can also read api key credentials from a pillar.
Example:

.. code-block:: yaml

    ensure telemetry alert X is defined on deployment Y:
        telemetry_alert.present:
            - deployment_id: "rs-XXXXXX"
            - metric_name: "testMetric"
            - alert_config:
               max: 1
               filter:  SERVER_ROLE_MONGOD_PRIMARY
               escalate_to: "example@pagerduty.com"
            - name: "**MANAGED BY ORCA DO NOT EDIT BY HAND** manages alarm on testMetric"
i(tabsolute_importtunicode_literalstprint_function(tstring_types(tsixcC@sdtkrdStS(Nutelemetry.get_alert_configutelemetry_alert(t__salt__tFalse(((s?/usr/lib/python2.7/site-packages/salt/states/telemetry_alert.pyt__virtual__#su	telemetryc	C@si|d6td6dd6id6}td||||�}i|d6|jd�d6td	|jd
��j�d6i|d6|jd
�d
6|jd�d6d6}g}	|r�x|j�D]�\}
}|
|kr�|	jdj|
|��q�n||
}||krq�nt|t�rEt	j
|�t	j
|�krEq�nt|t�rl|t|�krlq�nt|t�r�|t|�kr�q�n|	jdj|
||��q�Wn
|	jd�|||||f}
|r�t
|	�dkrdj|�|d<|StdrAdj|�}||d<dj|	�|d<|Std|
�\}}|rx|	|dd<d|d<qt|d<dj||�|d<n~tdr�dj|�}||d<d |d<|Std|
�\}}|r�||dd<n t|d<dj||�|d<|S(!u�
    Ensure the telemetry alert exists.

    name
        An optional description of the alarm (not currently supported by telemetry API)

    deployment_id
        Specifies the ID of the root deployment resource
        (replica set cluster or sharded cluster) to which this alert definition is attached

    metric_name
        Specifies the unique ID of the metric to whose values these thresholds will be applied

    alert_config: Is a list of dictionaries where each dict contains the following fields:
        filter
            By default the alert will apply to the deployment and all its constituent resources.
            If the alert only applies to a subset of those resources, a filter may be specified to narrow this scope.

        min
            the smallest "ok" value the metric may take on; if missing or null, no minimum is enforced.

        max
            the largest "ok" value the metric may take on; if missing or null, no maximum is enforced.

        notify_all
            Used to indicate if you want to alert both onCallEngineer and apiNotifications

    api_key
        Telemetry api key for the user

    profile
        A dict of telemetry config information.  If present, will be used instead of
        api_key.

    unameuresultuucommentuchangesutelemetry.get_alert_configu
deploymentufilteru%telemetry.get_notification_channel_iduescalate_tounotificationChannelumetricumaxuminu	conditionu
{0}={1} (new)u{0}='{1}' was: '{2}'unew alert configiu%alert config {0} present and matchingutestu"alert config {0} is to be updated.u
utelemetry.update_alarmudiffuAlert updated.u&Failed to update {0} alert config: {1}u"alert config {0} is to be created.utelemetry.create_alarmunewu&Failed to create {0} alert config: {1}N(tTrueRtgettsplittitemstappendtformatt
isinstanceRRt	text_typetfloattinttlent__opts__tjoinRtNone(tnamet
deployment_idtmetric_nametalert_configtapi_keytprofiletrettsaved_alert_configt	post_bodyt
differencetktvtv2tcreate_or_update_argstmsgtresult((s?/usr/lib/python2.7/site-packages/salt/states/telemetry_alert.pytpresent(sv%" 
-!!#
	







c
C@si|d6td6dd6id6}td||||�}|r�|jd�}tdr~d	j||�|d<d|d<|Std
|||jdi�jd�||�\}}	|r�||dd
<d|dd<qt|d<dj||	�|d<ndj||�|d<|S(uR
    Ensure the telemetry alert config is deleted

    name
        An optional description of the alarms (not currently supported by telemetry API)

    deployment_id
        Specifies the ID of the root deployment resource
        (replica set cluster or sharded cluster) to which this alert definition is attached

    metric_name
        Specifies the unique ID of the metric to whose values these thresholds will be applied

    api_key
        Telemetry api key for the user

    profile
        A dict with telemetry config data. If present, will be used instead of
        api_key.
    unameuresultuucommentuchangesutelemetry.get_alert_configu_idutestu4alert {0} is set to be removed from deployment: {1}.utelemetry.delete_alarmsu	conditionumetricuoldunewu/Failed to delete alert {0} from deployment: {1}u'alarm on {0} does not exist within {1}.N(RRR	RR
RR(
RRRRRRt
is_presenttalert_idtdeletedR$((s?/usr/lib/python2.7/site-packages/salt/states/telemetry_alert.pytabsent�s$"

0
N(
t__doc__t
__future__RRRtsalt._compatRtsalt.extRRRR&R*(((s?/usr/lib/python2.7/site-packages/salt/states/telemetry_alert.pyt<module>s	v

Zerion Mini Shell 1.0