From 4f1b09f7687d59c313af59358b3a309fe1b90d7d Mon Sep 17 00:00:00 2001 From: gordon chung Date: Tue, 8 Sep 2015 11:00:20 -0400 Subject: do not generate meter links on resource-list meter links are not accessible via resource_list and add significant overhead to query. we shouldn't generate these anymore. Change-Id: Ib20f410a70171aa09e4ebbbb748a5ce495fc6a43 Closes-Bug: #1493400 --- ceilometerclient/tests/unit/v2/test_resources.py | 8 ++++---- ceilometerclient/v2/resources.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ceilometerclient/tests/unit/v2/test_resources.py b/ceilometerclient/tests/unit/v2/test_resources.py index 4aa9131..3368b77 100644 --- a/ceilometerclient/tests/unit/v2/test_resources.py +++ b/ceilometerclient/tests/unit/v2/test_resources.py @@ -19,7 +19,7 @@ import ceilometerclient.v2.resources fixtures = { - '/v2/resources': { + '/v2/resources?meter_links=0': { 'GET': ( {}, [ @@ -38,7 +38,7 @@ fixtures = { ] ), }, - '/v2/resources?q.field=resource_id&q.op=&q.type=&q.value=a': + '/v2/resources?q.field=resource_id&q.op=&q.type=&q.value=a&meter_links=0': { 'GET': ( {}, @@ -78,7 +78,7 @@ class ResourceManagerTest(utils.BaseTestCase): def test_list_all(self): resources = list(self.mgr.list()) expect = [ - 'GET', '/v2/resources' + 'GET', '/v2/resources?meter_links=0' ] self.http_client.assert_called(*expect) self.assertEqual(len(resources), 2) @@ -100,7 +100,7 @@ class ResourceManagerTest(utils.BaseTestCase): ])) expect = [ 'GET', '/v2/resources?q.field=resource_id&q.op=' - '&q.type=&q.value=a' + '&q.type=&q.value=a&meter_links=0' ] self.http_client.assert_called(*expect) self.assertEqual(len(resources), 1) diff --git a/ceilometerclient/v2/resources.py b/ceilometerclient/v2/resources.py index 99e6fd5..aa80664 100644 --- a/ceilometerclient/v2/resources.py +++ b/ceilometerclient/v2/resources.py @@ -30,9 +30,10 @@ class Resource(base.Resource): class ResourceManager(base.Manager): resource_class = Resource - def list(self, q=None): + def list(self, q=None, links=None): path = '/v2/resources' - return self._list(options.build_url(path, q)) + params = ['meter_links=%d' % (1 if links else 0)] + return self._list(options.build_url(path, q, params)) def get(self, resource_id): path = '/v2/resources/%s' % resource_id -- cgit v1.2.1