summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgordon chung <gord@live.ca>2015-09-08 11:09:38 -0400
committergordon chung <gord@live.ca>2015-09-15 09:57:11 -0400
commit2861e81ea83363d2327f8d67e12531f45883e423 (patch)
tree07c9cc8bbbb6edaa6369279d124510063bb3282b
parentbe785125d3f70500a871980a032be03c700155fa (diff)
downloadpython-ceilometerclient-2861e81ea83363d2327f8d67e12531f45883e423.tar.gz
do not generate meter links on resource-list1.1.1
meter links are not accessible via resource_list and add significant overhead to query. we shouldn't generate these anymore. this patch is slightly different from master as this does not disable meter_links by default to maintain existing functionality. Change-Id: Ib20f410a70171aa09e4ebbbb748a5ce495fc6a43 Closes-Bug: #1493400
-rw-r--r--ceilometerclient/tests/v2/test_resources.py8
-rw-r--r--ceilometerclient/v2/resources.py5
2 files changed, 7 insertions, 6 deletions
diff --git a/ceilometerclient/tests/v2/test_resources.py b/ceilometerclient/tests/v2/test_resources.py
index 090ce8c..7d4066a 100644
--- a/ceilometerclient/tests/v2/test_resources.py
+++ b/ceilometerclient/tests/v2/test_resources.py
@@ -19,7 +19,7 @@ import ceilometerclient.v2.resources
fixtures = {
- '/v2/resources': {
+ '/v2/resources?meter_links=1': {
'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=1':
{
'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=1'
]
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=1'
]
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..9bfd25b 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=True):
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