def _items(self, req, entity_maker): """Returns a list of snapshots, transformed through entity_maker.""" context = req.environ['cinder.context'] #pop out limit and offset , they are not search_opts search_opts = req.GET.copy() search_opts.pop('limit', None) search_opts.pop('offset', None) #filter out invalid option allowed_search_options = ('status', 'volume_id', 'name') volumes.remove_invalid_options(context, search_opts, allowed_search_options) # NOTE(thingee): v2 API allows name instead of display_name if 'name' in search_opts: search_opts['display_name'] = search_opts['name'] del search_opts['name'] snapshots = self.volume_api.get_all_snapshots(context, search_opts=search_opts) limited_list = common.limited(snapshots, req) req.cache_resource(limited_list) res = [entity_maker(context, snapshot) for snapshot in limited_list] return {'snapshots': res}
def _items(self, req, entity_maker): """Returns a list of snapshots, transformed through entity_maker.""" context = req.environ['cinder.context'] search_opts = {} search_opts.update(req.GET) allowed_search_options = ('status', 'volume_id', 'display_name') volumes.remove_invalid_options(context, search_opts, allowed_search_options) snapshots = self.volume_api.get_all_snapshots(context, search_opts=search_opts) limited_list = common.limited(snapshots, req) res = [entity_maker(context, snapshot) for snapshot in limited_list] return {'snapshots': res}