Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
351aea4c
Commit
351aea4c
authored
Mar 28, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6626 from brentley/devel
Allow custom hipchat urls
parents
8e279923
ca14df47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
library/notification/hipchat
+14
-5
No files found.
library/notification/hipchat
View file @
351aea4c
...
@@ -54,6 +54,13 @@ options:
...
@@ -54,6 +54,13 @@ options:
default: 'yes'
default: 'yes'
choices: ['yes', 'no']
choices: ['yes', 'no']
version_added: 1.5.1
version_added: 1.5.1
api:
description:
- API url if using a self-hosted hipchat server
required: false
default: 'https://api.hipchat.com/v1/rooms/message'
version_added: 1.6.0
# informational: requirements for nodes
# informational: requirements for nodes
requirements: [ urllib, urllib2 ]
requirements: [ urllib, urllib2 ]
...
@@ -68,11 +75,10 @@ EXAMPLES = '''
...
@@ -68,11 +75,10 @@ EXAMPLES = '''
# HipChat module specific support methods.
# HipChat module specific support methods.
#
#
MSG_URI
=
"https://api.hipchat.com/v1/rooms/message?"
MSG_URI
=
"https://api.hipchat.com/v1/rooms/message"
def
send_msg
(
module
,
token
,
room
,
msg_from
,
msg
,
msg_format
=
'text'
,
def
send_msg
(
module
,
token
,
room
,
msg_from
,
msg
,
msg_format
=
'text'
,
color
=
'yellow'
,
notify
=
False
):
color
=
'yellow'
,
notify
=
False
,
api
=
MSG_URI
):
'''sending message to hipchat'''
'''sending message to hipchat'''
params
=
{}
params
=
{}
...
@@ -81,13 +87,14 @@ def send_msg(module, token, room, msg_from, msg, msg_format='text',
...
@@ -81,13 +87,14 @@ def send_msg(module, token, room, msg_from, msg, msg_format='text',
params
[
'message'
]
=
msg
params
[
'message'
]
=
msg
params
[
'message_format'
]
=
msg_format
params
[
'message_format'
]
=
msg_format
params
[
'color'
]
=
color
params
[
'color'
]
=
color
params
[
'api'
]
=
api
if
notify
:
if
notify
:
params
[
'notify'
]
=
1
params
[
'notify'
]
=
1
else
:
else
:
params
[
'notify'
]
=
0
params
[
'notify'
]
=
0
url
=
MSG_URI
+
"
auth_token=
%
s"
%
(
token
)
url
=
api
+
"?
auth_token=
%
s"
%
(
token
)
data
=
urllib
.
urlencode
(
params
)
data
=
urllib
.
urlencode
(
params
)
response
,
info
=
fetch_url
(
module
,
url
,
data
=
data
)
response
,
info
=
fetch_url
(
module
,
url
,
data
=
data
)
if
info
[
'status'
]
==
200
:
if
info
[
'status'
]
==
200
:
...
@@ -113,6 +120,7 @@ def main():
...
@@ -113,6 +120,7 @@ def main():
msg_format
=
dict
(
default
=
"text"
,
choices
=
[
"text"
,
"html"
]),
msg_format
=
dict
(
default
=
"text"
,
choices
=
[
"text"
,
"html"
]),
notify
=
dict
(
default
=
True
,
type
=
'bool'
),
notify
=
dict
(
default
=
True
,
type
=
'bool'
),
validate_certs
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
validate_certs
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
api
=
dict
(
default
=
MSG_URI
),
),
),
supports_check_mode
=
True
supports_check_mode
=
True
)
)
...
@@ -124,9 +132,10 @@ def main():
...
@@ -124,9 +132,10 @@ def main():
color
=
module
.
params
[
"color"
]
color
=
module
.
params
[
"color"
]
msg_format
=
module
.
params
[
"msg_format"
]
msg_format
=
module
.
params
[
"msg_format"
]
notify
=
module
.
params
[
"notify"
]
notify
=
module
.
params
[
"notify"
]
api
=
module
.
params
[
"api"
]
try
:
try
:
send_msg
(
module
,
token
,
room
,
msg_from
,
msg
,
msg_format
,
color
,
notify
)
send_msg
(
module
,
token
,
room
,
msg_from
,
msg
,
msg_format
,
color
,
notify
,
api
)
except
Exception
,
e
:
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"unable to sent msg:
%
s"
%
e
)
module
.
fail_json
(
msg
=
"unable to sent msg:
%
s"
%
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment