Beispiel #1
0
 def test_remove_invalid_options_admin(self):
     ctx = context.RequestContext('fakeuser', 'fakeproject', is_admin=True)
     search_opts = {'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd'}
     expected_opts = {'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd'}
     allowed_opts = ['a', 'c']
     self.mox.ReplayAll()
     shares.remove_invalid_options(ctx, search_opts, allowed_opts)
     self.assertEqual(search_opts, expected_opts)
Beispiel #2
0
    def _get_snapshots(self, req, is_detail):
        """Returns a list of snapshots."""
        context = req.environ['manila.context']

        search_opts = {}
        search_opts.update(req.GET)

        # NOTE(rushiagr): v2 API allows name instead of display_name
        if 'name' in search_opts:
            search_opts['display_name'] = search_opts['name']
            del search_opts['name']

        shares.remove_invalid_options(context, search_opts,
                                      self._get_snapshots_search_options())

        snapshots = self.share_api.get_all_snapshots(context,
                                                     search_opts=search_opts)
        limited_list = common.limited(snapshots, req)
        if is_detail:
            snapshots = self._view_builder.detail_list(req, limited_list)
        else:
            snapshots = self._view_builder.summary_list(req, limited_list)
        return snapshots