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
1c996085
Commit
1c996085
authored
Apr 23, 2014
by
Ben Whaley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to use fetch_url
parent
6c10297b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
library/notification/stackdriver
+13
-12
No files found.
library/notification/stackdriver
View file @
1c996085
...
...
@@ -70,9 +70,9 @@ options:
'''
EXAMPLES
=
'''
- stackdriver: key=AAAAAA event=deploy deployed_to=production deployed_by=leroyjenkins repository=MyWebApp revision_id=abcd123
- stackdriver: key=AAAAAA event=deploy deployed_to=production deployed_by=le
e
royjenkins repository=MyWebApp revision_id=abcd123
- stackdriver: key=AAAAAA event=annotation msg="Greetings from Ansible" annotated_by=leroyjenkins level=WARN instance_id=i-abcd1234
- stackdriver: key=AAAAAA event=annotation msg="Greetings from Ansible" annotated_by=le
e
royjenkins level=WARN instance_id=i-abcd1234
'''
# ===========================================
...
...
@@ -96,12 +96,7 @@ def send_deploy_event(module, key, revision_id, deployed_by='Ansible', deployed_
if
repository
:
params
[
'repository'
]
=
repository
data
=
json
.
dumps
(
params
)
req
=
urllib2
.
Request
(
deploy_api
,
data
)
req
.
add_header
(
'content-type'
,
'application/json'
)
req
.
add_header
(
'x-stackdriver-apikey'
,
key
)
return
urllib2
.
urlopen
(
req
)
return
do_send_request
(
module
,
deploy_api
,
params
,
key
)
def
send_annotation_event
(
module
,
key
,
msg
,
annotated_by
=
'Ansible'
,
level
=
None
,
instance_id
=
None
,
event_epoch
=
None
):
"""Send an annotation event to Stackdriver"""
...
...
@@ -118,12 +113,18 @@ def send_annotation_event(module, key, msg, annotated_by='Ansible', level=None,
if
event_epoch
:
params
[
'event_epoch'
]
=
event_epoch
return
do_send_request
(
module
,
annotation_api
,
params
,
key
)
def
do_send_request
(
module
,
url
,
params
,
key
):
data
=
json
.
dumps
(
params
)
headers
=
{
'Content-Type'
:
'application/json'
,
'x-stackdriver-apikey'
:
key
}
response
,
info
=
fetch_url
(
module
,
url
,
headers
=
headers
,
data
=
data
,
method
=
'POST'
)
if
info
[
'status'
]
!=
200
:
module
.
fail_json
(
msg
=
"Unable to send msg:
%
s"
%
info
[
'msg'
])
req
=
urllib2
.
Request
(
annotation_api
,
data
)
req
.
add_header
(
'content-type'
,
'application/json'
)
req
.
add_header
(
'x-stackdriver-apikey'
,
key
)
return
urllib2
.
urlopen
(
req
)
# ===========================================
# Module execution.
...
...
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