%PDF- %PDF-
| Direktori : /usr/lib/python2.7/site-packages/salt/states/ |
| Current File : //usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyc |
�
���^c @@ se d Z d d l m Z m Z m Z d � Z d d d d � Z d d d d � Z d � Z d � Z
d S(
uk
Manage PagerDuty escalation policies.
Schedules and users can be referenced by pagerduty ID, or by name, or by email address.
For example:
.. code-block:: yaml
ensure test escalation policy:
pagerduty_escalation_policy.present:
- name: bruce test escalation policy
- escalation_rules:
- targets:
- type: schedule
id: 'bruce test schedule level1'
- type: user
id: 'Bruce Sherrod'
escalation_delay_in_minutes: 15
- targets:
- type: schedule
id: 'bruce test schedule level2'
escalation_delay_in_minutes: 15
- targets:
- type: user
id: 'Bruce TestUser1'
- type: user
id: 'Bruce TestUser2'
- type: user
id: 'Bruce TestUser3'
- type: user
id: 'bruce+test4@lyft.com'
escalation_delay_in_minutes: 15
i ( t absolute_importt print_functiont unicode_literalsc C@ s d t k r d St S( uD
Only load if the pygerduty module is available in __salt__
u pagerduty_util.get_resourceu pagerduty_escalation_policy( t __salt__t False( ( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt __virtual__* s u pagerdutyc
K@ sA x| d D]} x� | d D]� } d } | d d k r� t d d | d d d d g d
| d | d | �} | r� | d } q� n\ | d d
k r� t d d | d d d g d
| d | d | �} | r� | d
d } q� n | d k rt d j | � � � n | | d <q Wq Wt d d d d g t | | | | � } | S( u9
Ensure that a pagerduty escalation policy exists. Will create or update as needed.
This method accepts as args everything defined in
https://developer.pagerduty.com/documentation/rest/escalation_policies/create.
In addition, user and schedule id's will be translated from name (or email address)
into PagerDuty unique ids. For example:
.. code-block:: yaml
pagerduty_escalation_policy.present:
- name: bruce test escalation policy
- escalation_rules:
- targets:
- type: schedule
id: 'bruce test schedule level1'
- type: user
id: 'Bruce Sherrod'
In this example, 'Bruce Sherrod' will be looked up and replaced with the
PagerDuty id (usually a 7 digit all-caps string, e.g. PX6GQL7)
u escalation_rulesu targetsu typeu useru pagerduty_util.get_resourceu usersu idu emailu namet profilet subdomaint api_keyu scheduleu schedulesu unidentified target: {0}u pagerduty_util.resource_presentu escalation_policiesN( t NoneR t Exceptiont formatt _diff(
R R R t kwargst escalation_rulet targett target_idt usert schedulet r( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt present1 s@
c K@ s) t d d d d g | | | | � } | S( u
Ensure that a PagerDuty escalation policy does not exist.
Accepts all the arguments that pagerduty_escalation_policy.present accepts;
but ignores all arguments except the name.
Name can be the escalation policy id or the escalation policy name.
u pagerduty_util.resource_absentu escalation_policiesu nameu id( R ( R R R R
R ( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt absentn s
c C@ s� d } x� | j � D]� \ } } | d k rJ t | � } t | | � } n% | | j � k re t } n
| | } | | k r d j | | | � } Pq q W| r� | Si Sd S( u� helper method to compare salt state info with the PagerDuty API json structure,
and determine if we need to update.
returns the dict to pass to the PD API to perform the update, or empty dict if no update.
u escalation_rulesu {0} {1} {2}N( R t itemst _escalation_rules_to_stringt keyst TrueR ( t
state_datat resource_objectt objects_differt kt vt resource_value( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyR s
c C@ se d } xX | D]P } | d j | d � 7} x0 | d D]$ } | d j | d | d � 7} q5 Wq
W| S( u8 convert escalation_rules dict to a string for comparisonu u! escalation_delay_in_minutes: {0} u escalation_delay_in_minutesu targetsu {0}:{1} u typeu id( R ( t escalation_rulest resultt ruleR ( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyR � s
&N( t __doc__t
__future__R R R R R R R R R ( ( ( sK /usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt <module>$ s =