Ensure url is a string for requests.post

requests.post doesn't support SplitResult object as url

This change ensure that the url passed to requests.port is a string

Change-Id: Ibfdd51f06edffc4ea744ff21cd53591c2db6e251
This commit is contained in:
Mehdi Abaakouk 2013-07-19 08:06:48 +02:00
parent 5bfbaba768
commit 33b691fa57
2 changed files with 4 additions and 6 deletions

View File

@ -48,7 +48,6 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
def notify(self, action, alarm, state, reason):
LOG.info("Notifying alarm %s in state %s with action %s because %s",
alarm, state, action, reason)
body = {'state': state, 'reason': reason}
kwargs = {'data': jsonutils.dumps(body)}
@ -57,4 +56,4 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
if action.scheme == 'https' and cert:
kwargs['cert'] = (cert, key) if key else cert
eventlet.spawn_n(requests.post, action, **kwargs)
eventlet.spawn_n(requests.post, action.geturl(), **kwargs)

View File

@ -23,7 +23,6 @@ from oslo.config import cfg
from ceilometer.alarm import service
from ceilometer.openstack.common import context
from ceilometer.openstack.common import network_utils
from ceilometer.tests import base
@ -69,7 +68,7 @@ class TestAlarmNotifier(base.TestCase):
data_json = '{"state": "ALARM", "reason": "what ?"}'
self.mox.StubOutWithMock(requests, "post")
requests.post(network_utils.urlsplit(action), data=data_json)
requests.post(action, data=data_json)
self.mox.ReplayAll()
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
@ -90,7 +89,7 @@ class TestAlarmNotifier(base.TestCase):
cfg.CONF.set_override("rest_notifier_certificate_file", certificate,
group='alarm')
self.mox.StubOutWithMock(requests, "post")
requests.post(network_utils.urlsplit(action), data=data_json,
requests.post(action, data=data_json,
cert=certificate)
self.mox.ReplayAll()
@ -115,7 +114,7 @@ class TestAlarmNotifier(base.TestCase):
cfg.CONF.set_override("rest_notifier_certificate_key", key,
group='alarm')
self.mox.StubOutWithMock(requests, "post")
requests.post(network_utils.urlsplit(action), data=data_json,
requests.post(action, data=data_json,
cert=(certificate, key))
self.mox.ReplayAll()