コード例 #1
0
ファイル: providers.py プロジェクト: WeAreFormalGroup/smaug
    def checkpoints_index(self, req, provider_id):
        """Returns a list of checkpoints, transformed through view builder."""
        context = req.environ['smaug.context']

        LOG.info(_LI("Show checkpoints list. "
                     "provider_id:%s"), provider_id)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(
            context,
            filters,
            self._get_checkpoint_filter_options())

        utils.check_filters(filters)
        checkpoints = self._checkpoints_get_all(
            context, provider_id, marker, limit,
            sort_keys=sort_keys, sort_dirs=sort_dirs,
            filters=filters, offset=offset)

        retval_checkpoints = self._checkpoint_view_builder.detail_list(
            req, checkpoints)

        LOG.info(_LI("Show checkpoints list request issued successfully."))

        return retval_checkpoints
コード例 #2
0
ファイル: restores.py プロジェクト: Bloomie/smaug
    def index(self, req):
        """Returns a list of restores, transformed through view builder."""
        context = req.environ['smaug.context']

        LOG.info(_LI("Show restore list"), context=context)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(
            context,
            filters,
            self._get_restore_filter_options())

        utils.check_filters(filters)
        restores = self._get_all(context, marker, limit,
                                 sort_keys=sort_keys,
                                 sort_dirs=sort_dirs,
                                 filters=filters,
                                 offset=offset)

        retval_restores = self._view_builder.detail_list(req, restores)

        LOG.info(_LI("Show restore list request issued successfully."))

        return retval_restores
コード例 #3
0
    def checkpoints_index(self, req, provider_id):
        """Returns a list of checkpoints, transformed through view builder."""
        context = req.environ['smaug.context']

        LOG.info(_LI("Show checkpoints list. " "provider_id:%s"), provider_id)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(
            context, filters, self._get_checkpoint_filter_options())

        utils.check_filters(filters)
        checkpoints = self._checkpoints_get_all(context,
                                                provider_id,
                                                marker,
                                                limit,
                                                sort_keys=sort_keys,
                                                sort_dirs=sort_dirs,
                                                filters=filters,
                                                offset=offset)

        retval_checkpoints = self._checkpoint_view_builder.detail_list(
            req, checkpoints)

        LOG.info(_LI("Show checkpoints list request issued successfully."))

        return retval_checkpoints
コード例 #4
0
ファイル: plans.py プロジェクト: smile-luobin/smaug
    def index(self, req):
        """Returns a list of plans, transformed through view builder."""
        context = req.environ['smaug.context']

        LOG.info(_LI("Show plan list"), context=context)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(context, filters,
                                            self._get_plan_filter_options())

        utils.check_filters(filters)
        plans = self._get_all(context,
                              marker,
                              limit,
                              sort_keys=sort_keys,
                              sort_dirs=sort_dirs,
                              filters=filters,
                              offset=offset)

        retval_plans = self._view_builder.detail_list(req, plans)

        LOG.info(_LI("Show plan list request issued successfully."))

        return retval_plans
コード例 #5
0
ファイル: test_common.py プロジェクト: smile-luobin/smaug
 def test_valid_limit_and_marker(self):
     """Test valid limit and marker parameters."""
     marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
     req = webob.Request.blank('/?limit=20&marker=%s' % marker)
     expected = (marker, 20, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #6
0
ファイル: test_common.py プロジェクト: smile-luobin/smaug
 def test_valid_marker(self):
     """Test valid marker param."""
     marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
     req = webob.Request.blank('/?marker=' + marker)
     expected = (marker, CONF.osapi_max_limit, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #7
0
    def index(self, req):
        """Returns a list of triggers, transformed through view builder."""

        context = req.environ['smaug.context']
        check_policy(context, 'list')

        params = req.params.copy()
        LOG.debug('List triggers start, params=%s', params)
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        valid_filters = ["all_tenants", "name", "type", "properties"]
        utils.remove_invalid_filter_options(context, filters, valid_filters)
        utils.check_filters(filters)

        all_tenants = utils.get_bool_param("all_tenants", filters)
        if not (context.is_admin and all_tenants):
            filters["project_id"] = context.project_id

        try:
            triggers = objects.TriggerList.get_by_filters(
                context, filters, limit, marker, sort_keys, sort_dirs)
        except Exception as ex:
            self._raise_unknown_exception(ex)

        return self._view_builder.detail_list(req, triggers)
コード例 #8
0
ファイル: test_common.py プロジェクト: smile-luobin/smaug
 def test_no_params(self, mock_cfg):
     """Test no params."""
     mock_cfg.osapi_max_limit = 100
     req = webob.Request.blank('/')
     expected = (None, 100, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #9
0
ファイル: test_common.py プロジェクト: Bloomie/smaug
 def test_valid_limit_and_marker(self):
     """Test valid limit and marker parameters."""
     marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
     req = webob.Request.blank('/?limit=20&marker=%s' % marker)
     expected = (marker, 20, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #10
0
ファイル: test_common.py プロジェクト: Bloomie/smaug
 def test_valid_marker(self):
     """Test valid marker param."""
     marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
     req = webob.Request.blank('/?marker=' + marker)
     expected = (marker, CONF.osapi_max_limit, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #11
0
ファイル: test_common.py プロジェクト: Bloomie/smaug
 def test_no_params(self, mock_cfg):
     """Test no params."""
     mock_cfg.osapi_max_limit = 100
     req = webob.Request.blank('/')
     expected = (None, 100, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #12
0
ファイル: protectables.py プロジェクト: smile-luobin/smaug
    def instances_index(self, req, protectable_type):
        """Return data about the given protectable_type."""
        context = req.environ['smaug.context']
        LOG.info(_LI("Show the instances of a given"
                     " protectable type: %s"), protectable_type)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(
            context, filters, self._get_instance_filter_options())

        protectable_types = self._get_all(context)

        if protectable_type not in protectable_types:
            msg = _("Invalid protectable type provided.")
            raise exception.InvalidInput(reason=msg)

        utils.check_filters(filters)
        instances = self._instances_get_all(context,
                                            protectable_type,
                                            marker,
                                            limit,
                                            sort_keys=sort_keys,
                                            sort_dirs=sort_dirs,
                                            filters=filters,
                                            offset=offset)

        for instance in instances:
            protectable_id = instance.get("id")
            instance["type"] = protectable_type
            if protectable_id is None:
                raise exception.InvalidProtectableInstance(
                    protectable_id=protectable_id)
            dependents = self.protection_api.\
                list_protectable_dependents(context, protectable_id,
                                            protectable_type)
            instance["dependent_resources"] = dependents

        retval_instances = self._view_builder.detail_list(req, instances)

        return retval_instances
コード例 #13
0
ファイル: protectables.py プロジェクト: Bloomie/smaug
    def instances_index(self, req, protectable_type):
        """Return data about the given protectable_type."""
        context = req.environ['smaug.context']
        LOG.info(_LI("Show the instances of a given"
                     " protectable type: %s"), protectable_type)

        params = req.params.copy()
        marker, limit, offset = common.get_pagination_params(params)
        sort_keys, sort_dirs = common.get_sort_params(params)
        filters = params

        utils.remove_invalid_filter_options(
            context,
            filters,
            self._get_instance_filter_options())

        protectable_types = self._get_all(context)

        if protectable_type not in protectable_types:
            msg = _("Invalid protectable type provided.")
            raise exception.InvalidInput(reason=msg)

        utils.check_filters(filters)
        instances = self._instances_get_all(
            context, protectable_type, marker, limit,
            sort_keys=sort_keys, sort_dirs=sort_dirs,
            filters=filters, offset=offset)

        for instance in instances:
            protectable_id = instance.get("id")
            instance["type"] = protectable_type
            if protectable_id is None:
                raise exception.InvalidProtectableInstance(
                    protectable_id=protectable_id)
            dependents = self.protection_api.\
                list_protectable_dependents(context, protectable_id,
                                            protectable_type)
            instance["dependent_resources"] = dependents

        retval_instances = self._view_builder.detail_list(req, instances)

        return retval_instances
コード例 #14
0
ファイル: test_common.py プロジェクト: smile-luobin/smaug
 def test_valid_limit(self):
     """Test valid limit param."""
     req = webob.Request.blank('/?limit=10')
     expected = (None, 10, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))
コード例 #15
0
ファイル: test_common.py プロジェクト: Bloomie/smaug
 def test_valid_limit(self):
     """Test valid limit param."""
     req = webob.Request.blank('/?limit=10')
     expected = (None, 10, 0)
     self.assertEqual(expected,
                      common.get_pagination_params(req.GET.copy()))