From c5d7f96914c1ef0dbd490fbe7899c7633d16d070 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Wed, 10 Sep 2014 20:58:55 +0100 Subject: [PATCH] Fix sample-create in v2 api calls A dict embedded in a list is the expected input. In 47934c777c50897b649793e0960eebdaad322c45 the list was lost, this puts it back. Note that the _exact_ date of this failure was identified by existing Rally jobs which started failing in early August. That made searching the commit logs straightforward. Change-Id: I37e794de7a23b8ce8e67a086732af5a19f182409 Closes-Bug: #1367867 --- ceilometerclient/tests/v2/test_samples.py | 2 +- ceilometerclient/v2/samples.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ceilometerclient/tests/v2/test_samples.py b/ceilometerclient/tests/v2/test_samples.py index 5804c7e3..dfbdf39d 100644 --- a/ceilometerclient/tests/v2/test_samples.py +++ b/ceilometerclient/tests/v2/test_samples.py @@ -103,7 +103,7 @@ class SampleManagerTest(utils.BaseTestCase): expect = [ 'POST', '/v2/meters/instance' ] - self.http_client.assert_called(*expect, body=CREATE_SAMPLE) + self.http_client.assert_called(*expect, body=[CREATE_SAMPLE]) self.assertIsNotNone(sample) def test_limit(self): diff --git a/ceilometerclient/v2/samples.py b/ceilometerclient/v2/samples.py index b0ff3b54..8081efc9 100644 --- a/ceilometerclient/v2/samples.py +++ b/ceilometerclient/v2/samples.py @@ -47,6 +47,6 @@ class SampleManager(base.Manager): new = dict((key, value) for (key, value) in kwargs.items() if key in CREATION_ATTRIBUTES) url = self._path(counter_name=kwargs['counter_name']) - body = self.api.post(url, json=new).json() + body = self.api.post(url, json=[new]).json() if body: return [Sample(self, b) for b in body]