summaryrefslogtreecommitdiff
path: root/novaclient/base.py
diff options
context:
space:
mode:
authorYikun Jiang <yikunkero@gmail.com>2017-10-27 15:28:15 +0800
committerYikun Jiang <yikunkero@gmail.com>2017-11-22 13:35:27 +0000
commit50460bddfc943ad3bd4ad3c23c0cf05d013b85b3 (patch)
tree2f64c6a6b1bb8c83f8556300fa2020d0fe4810dd /novaclient/base.py
parentc9e7a64ca83302bdeab2044c09f9063646cc59a3 (diff)
downloadpython-novaclient-50460bddfc943ad3bd4ad3c23c0cf05d013b85b3.tar.gz
Use utils.prepare_query_string instead of duplicated code
There are some duplicated code in nova client for generating query string. The 'prepare_query_string' method can convert dict params to query string(it transforms the dict to a sequence of two-element tuples in fixed order, then the encoded string will be consistent in Python 2&3.) This patch use utils.prepare_query_string instead of these and plus some notes in the 'prepare_query_string' method. Change-Id: Idb3c5e97f8bbcd5ec5446f776c10fa8c84b54d5d Closes-Bug: 1727968
Diffstat (limited to 'novaclient/base.py')
-rw-r--r--novaclient/base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/novaclient/base.py b/novaclient/base.py
index 6bcb527c..328b2512 100644
--- a/novaclient/base.py
+++ b/novaclient/base.py
@@ -247,7 +247,10 @@ class Manager(HookableMixin):
def api_version(self):
return self.api.api_version
- def _list(self, url, response_key, obj_class=None, body=None):
+ def _list(self, url, response_key, obj_class=None, body=None,
+ filters=None):
+ if filters:
+ url = utils.get_url_with_filter(url, filters)
if body:
resp, body = self.api.client.post(url, body=body)
else:
@@ -347,7 +350,9 @@ class Manager(HookableMixin):
if cache:
cache.write("%s\n" % val)
- def _get(self, url, response_key):
+ def _get(self, url, response_key, filters=None):
+ if filters:
+ url = utils.get_url_with_filter(url, filters)
resp, body = self.api.client.get(url)
if response_key is not None:
content = body[response_key]