Merge "Fix 'KeyError' when 'with_count' is not specified"

This commit is contained in:
Zuul 2017-11-28 02:42:33 +00:00 committed by Gerrit Code Review
commit 5b5034a4e2
3 changed files with 6 additions and 3 deletions

View File

@ -103,7 +103,8 @@ class BackupsController(wsgi.Controller):
sort_keys, sort_dirs = common.get_sort_params(filters)
show_count = False
if req_version.matches(mv.SUPPORT_COUNT_INFO):
if req_version.matches(
mv.SUPPORT_COUNT_INFO) and 'with_count' in filters:
show_count = utils.get_bool_param('with_count', filters)
filters.pop('with_count')
self._convert_sort_name(req_version, sort_keys)

View File

@ -80,7 +80,8 @@ class SnapshotsController(snapshots_v2.SnapshotsController):
req_version = req.api_version_request
show_count = False
if req_version.matches(mv.SUPPORT_COUNT_INFO):
if req_version.matches(
mv.SUPPORT_COUNT_INFO) and 'with_count' in search_opts:
show_count = utils.get_bool_param('with_count', search_opts)
search_opts.pop('with_count')

View File

@ -99,7 +99,8 @@ class VolumeController(volumes_v2.VolumeController):
filters = params
show_count = False
if req_version.matches(mv.SUPPORT_COUNT_INFO):
if req_version.matches(
mv.SUPPORT_COUNT_INFO) and 'with_count' in filters:
show_count = utils.get_bool_param('with_count', filters)
filters.pop('with_count')