From 2b550c096e38983792817fd84ee77c91924080c8 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Wed, 23 Oct 2013 12:41:55 +0200 Subject: [PATCH] Add source to Resource API object This change add the source the resource API object Fixes bug #1243651 Change-Id: I4489d34c83d3af7818d3f94afaa31b493df7549d --- ceilometer/api/controllers/v2.py | 4 ++++ tests/api/v2/test_list_resources_scenarios.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index 67867d63b..368d94449 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -897,6 +897,9 @@ class Resource(_Base): links = [Link] "A list containing a self link and associated meter links" + source = wtypes.text + "The source where the resource come from" + def __init__(self, metadata={}, **kwds): metadata = _flatten_metadata(metadata) super(Resource, self).__init__(metadata=metadata, **kwds) @@ -907,6 +910,7 @@ class Resource(_Base): project_id='35b17138-b364-4e6a-a131-8f3099c5be68', user_id='efd87807-12d2-4b38-9c70-5f5c2ac427ff', timestamp=datetime.datetime.utcnow(), + source="openstack", metadata={'name1': 'value1', 'name2': 'value2'}, links=[Link(href=('http://localhost:8777/v2/resources/' diff --git a/tests/api/v2/test_list_resources_scenarios.py b/tests/api/v2/test_list_resources_scenarios.py index 7c869dda3..06d1015dc 100644 --- a/tests/api/v2/test_list_resources_scenarios.py +++ b/tests/api/v2/test_list_resources_scenarios.py @@ -201,6 +201,8 @@ class TestListResources(FunctionalTest, }]) ids = [r['resource_id'] for r in data] self.assertEqual(['resource-id'], ids) + sources = [r['source'] for r in data] + self.assertEqual(['test_list_resources'], sources) def test_with_invalid_resource_id(self): sample1 = sample.Sample(