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
aecc954a
Commit
aecc954a
authored
May 21, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2965 from bpennypacker/devel
newrelic_deployment bug fix to support both python 2.4 and 2.6
parents
753ebea1
d4429fcb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
library/monitoring/newrelic_deployment
+13
-2
No files found.
library/monitoring/newrelic_deployment
View file @
aecc954a
...
...
@@ -134,13 +134,24 @@ def main():
try
:
req
=
urllib2
.
Request
(
"https://rpm.newrelic.com/deployments.xml"
,
urllib
.
urlencode
(
params
))
req
.
add_header
(
'x-api-key'
,
module
.
params
[
"token"
])
urllib2
.
urlopen
(
req
)
result
=
urllib2
.
urlopen
(
req
)
# urlopen behaves differently in python 2.4 and 2.6 so we handle
# both cases here. In python 2.4 it throws an exception if the
# return code is anything other than a 200. In python 2.6 it
# doesn't throw an exception for any 2xx return codes. In both
# cases we expect newrelic should return a 201 on success. So
# to handle both cases, both the except & else cases below are
# effectively identical.
except
Exception
,
e
:
# 201 is an ok response from this service
if
e
.
code
==
201
:
module
.
exit_json
(
changed
=
True
)
else
:
module
.
fail_json
(
msg
=
"unable to update newrelic:
%
s"
%
e
)
else
:
if
result
.
code
==
201
:
module
.
exit_json
(
changed
=
True
)
else
:
module
.
fail_json
(
msg
=
"result code:
%
d"
%
result
.
code
)
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
...
...
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