�
�Udac @` s� d d l m Z m Z m Z e Z d Z d d l Z d d l Z y d d l Z e
Z Wn e k
ro e
Z n Xd d l m Z d d l m Z d d l m Z d e f d � � YZ d S( i ( t absolute_importt divisiont print_functions�
callback: hipchat
callback_type: notification
requirements:
- whitelist in configuration.
- prettytable (python lib)
short_description: post task events to hipchat
description:
- This callback plugin sends status updates to a HipChat channel during playbook execution.
- Before 2.4 only environment variables were available for configuring this plugin.
version_added: "1.6"
options:
token:
description: HipChat API token for v1 or v2 API.
required: True
env:
- name: HIPCHAT_TOKEN
ini:
- section: callback_hipchat
key: token
api_version:
description: HipChat API version, v1 or v2.
required: False
default: v1
env:
- name: HIPCHAT_API_VERSION
ini:
- section: callback_hipchat
key: api_version
room:
description: HipChat room to post in.
default: ansible
env:
- name: HIPCHAT_ROOM
ini:
- section: callback_hipchat
key: room
from:
description: Name to post as
default: ansible
env:
- name: HIPCHAT_FROM
ini:
- section: callback_hipchat
key: from
notify:
description: Add notify flag to important messages
type: bool
default: True
env:
- name: HIPCHAT_NOTIFY
ini:
- section: callback_hipchat
key: notify
N( t CallbackBase( t urlencode( t open_urlt CallbackModulec B` s� e Z d Z d Z d Z d Z e Z d Z d Z d � Z
d d d d � Z d d e
d
� Z d d e
d � Z d � Z d
� Z RS( s} This is an example ansible callback plugin that sends status
updates to a HipChat channel during playbook execution.
g @t notificationt hipchats( https://api.hipchat.com/v1/rooms/messages https://api.hipchat.com/v2/c C` sT t t | � j � t s5 t | _ | j j d � n t | _ d | _ d | _ d S( NsX The `prettytable` python module is not installed. Disabling the HipChat callback plugin.(
t superR t __init__t HAS_PRETTYTABLEt Truet disabledt _displayt warningt Falset printed_playbookt Nonet
playbook_namet play( t self( ( sD /usr/lib/python2.7/site-packages/ansible/plugins/callback/hipchat.pyR
\ s c C` s� t t | � j d | d | d | � | j d � | _ | j d � | _ | j d � | _ | j d � | _ | j d � | _ | j d k r� t
| _ | j j
d � n | j d
k r� | j | _ n | j | _ d S( Nt task_keyst var_optionst directt tokent api_versiont fromt notifyt roomst HipChat token could not be loaded. The HipChat token can be provided using the `HIPCHAT_TOKEN` environment variable.t v2( R R t set_optionst
get_optionR R t from_namet allow_notifyR R R R
R R t send_msg_v2t send_msgt send_msg_v1( R R R R ( ( sD /usr/lib/python2.7/site-packages/ansible/plugins/callback/hipchat.pyR h s % t textt yellowc C` s� i d | j d 6d d 6} i } | j | d <| j d | d <| | d <| | d <| | d
<| j oi | | d <t j | � } | j d j d | j � } y, t | d
| d | d d �} | j � SWn, t
k
r� }
| j j d j |
� � n Xd S( s'