Fix KeyError exception when volume filter file does not exist

Since current code assume that resource key is existed, exception
happens when filter file does not initialized. Return empty list
to avoid KeyError exception.

Closes-Bug: #1857945
Change-Id: I2d3c0f3f8d2c02ffedc4bf5ddc45e21c2d22c3e2
This commit is contained in:
Yang Youseok 2019-11-29 19:18:28 +09:00
parent 06aee2dc22
commit fe7cf6be84

View File

@ -282,7 +282,7 @@ class VolumeController(wsgi.Controller):
def _get_volume_filter_options(self):
"""Return volume search options allowed by non-admin."""
return common.get_enabled_resource_filters('volume')['volume']
return common.get_enabled_resource_filters('volume').get('volume', [])
@validation.schema(volumes.update, mv.V2_BASE_VERSION,
mv.get_prior_version(mv.SUPPORT_VOLUME_SCHEMA_CHANGES))