Beispiel #1
0
    def index(self, req):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
            'project': 'mixed',
            'parent': 'mixed',
            'user': '******',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
            'show_nested': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_SHOW_NESTED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        if not filters:
            filters = None

        clusters = self.rpc_client.cluster_list(req.context,
                                                filters=filters,
                                                project_safe=True,
                                                **params)
        return {'clusters': clusters}
Beispiel #2
0
 def test_parse_bool(self):
     name = 'param'
     for value in ('True', 'true', 'TRUE', True):
         self.assertTrue(utils.parse_bool_param(name, value))
     for value in ('False', 'false', 'FALSE', False):
         self.assertFalse(utils.parse_bool_param(name, value))
     for value in ('foo', 't', 'f', 'yes', 'no', 'y', 'n', '1', '0', None):
         self.assertRaises(exception.InvalidParameter,
                           utils.parse_bool_param, name, value)
Beispiel #3
0
 def test_parse_bool(self):
     name = 'param'
     for value in ('True', 'true', 'TRUE', True):
         self.assertTrue(utils.parse_bool_param(name, value))
     for value in ('False', 'false', 'FALSE', False):
         self.assertFalse(utils.parse_bool_param(name, value))
     for value in ('foo', 't', 'f', 'yes', 'no', 'y', 'n', '1', '0', None):
         self.assertRaises(exception.InvalidParameter,
                           utils.parse_bool_param, name, value)
Beispiel #4
0
    def index(self, req):
        filter_whitelist = {
            consts.TRIGGER_NAME: 'mixed',
            consts.TRIGGER_TYPE: 'mixed',
            consts.TRIGGER_STATE: 'mixed',
            consts.TRIGGER_ENABLED: 'mixed',
            consts.TRIGGER_SEVERITY: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT_DIR: 'single',
            consts.PARAM_SORT_KEYS: 'multi',
            consts.PARAM_SHOW_DELETED: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SORT_DIR
        if key in params:
            sort_dir = params[key].lower()
            if sort_dir not in ('asc', 'desc'):
                raise exc.HTTPBadRequest(
                    _("Sorting direction (sort_dir) must "
                      "be either 'asc' or 'desc'."))

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        triggers = self.rpc_client.trigger_list(req.context,
                                                filters=filters,
                                                **params)

        return {'triggers': triggers}
Beispiel #5
0
    def index(self, req):
        filter_whitelist = {
            consts.TRIGGER_NAME: 'mixed',
            consts.TRIGGER_TYPE: 'mixed',
            consts.TRIGGER_STATE: 'mixed',
            consts.TRIGGER_ENABLED: 'mixed',
            consts.TRIGGER_SEVERITY: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT_DIR: 'single',
            consts.PARAM_SORT_KEYS: 'multi',
            consts.PARAM_SHOW_DELETED: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SORT_DIR
        if key in params:
            sort_dir = params[key].lower()
            if sort_dir not in ('asc', 'desc'):
                raise exc.HTTPBadRequest(_("Sorting direction (sort_dir) must "
                                           "be either 'asc' or 'desc'."))

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        triggers = self.rpc_client.trigger_list(req.context,
                                                filters=filters,
                                                **params)

        return {'triggers': triggers}
Beispiel #6
0
    def index(self, req):
        filter_whitelist = {
            'name': 'mixed',
            'target': 'mixed',
            'action': 'mixed',
            'created_time': 'single',
            'updated_time': 'single',
            'deleted_time': 'single',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        if not filters:
            filters = None

        actions = self.rpc_client.action_list(req.context,
                                              filters=filters,
                                              **params)

        return {'actions': actions}
Beispiel #7
0
    def index(self, req):
        filter_whitelist = {
            consts.CLUSTER_NAME: 'mixed',
            consts.CLUSTER_STATUS: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys() and key not in
                    filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        clusters = self.rpc_client.cluster_list(req.context, filters=filters,
                                                **params)
        return {'clusters': clusters}
Beispiel #8
0
    def index(self, req, cluster_id):
        filter_whitelist = {
            consts.CP_ENABLED: 'single',
        }
        param_whitelist = {
            consts.PARAM_SORT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys() and key not in
                    filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)

        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)
        key = consts.CP_ENABLED
        if key in filters:
            filters[key] = utils.parse_bool_param(key, filters[key])

        if not filters:
            filters = None
        policies = self.rpc_client.cluster_policy_list(req.context,
                                                       cluster_id=cluster_id,
                                                       filters=filters,
                                                       **params)

        return {'cluster_policies': policies}
Beispiel #9
0
    def _sanitize_policy(self, data):
        """Validate dict body of policy attach or update.

        :param dict data: A dictionary containing the properties of the policy
                          to be attached/updated including the policy ID.
        :returns: A sanitized dict containing the policy properties.
        :raises: :class:`~webob.exception.HTTPBadRequest` if the policy dict
                 contains invalid property values.
        """
        if not isinstance(data, dict):
            msg = _("The data provided is not a map.")
            raise exc.HTTPBadRequest(msg)

        if consts.CP_POLICY_ID not in data:
            msg = _("The 'policy_id' field is missing in the request.")
            raise exc.HTTPBadRequest(msg)

        if consts.CP_ENABLED in data:
            enabled = data.get(consts.CP_ENABLED)
            try:
                enabled = utils.parse_bool_param(consts.CP_ENABLED, enabled)
            except senlin_exc.InvalidParameter as ex:
                raise exc.HTTPBadRequest(six.text_type(ex))
            data[consts.CP_ENABLED] = enabled

        return data
Beispiel #10
0
    def index(self, req):
        filter_whitelist = {
            'name': 'mixed',
            'target': 'mixed',
            'action': 'mixed',
            'created_time': 'single',
            'updated_time': 'single',
            'deleted_time': 'single',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        if not filters:
            filters = None

        actions = self.rpc_client.action_list(req.context,
                                              filters=filters,
                                              **params)

        return {'actions': actions}
Beispiel #11
0
    def index(self, req, cluster_id):
        filter_whitelist = {
            consts.CP_ENABLED: 'single',
        }
        param_whitelist = {
            consts.PARAM_SORT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys()
                    and key not in filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)

        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)
        key = consts.CP_ENABLED
        if key in filters:
            filters[key] = utils.parse_bool_param(key, filters[key])

        if not filters:
            filters = None
        policies = self.rpc_client.cluster_policy_list(req.context,
                                                       cluster_id=cluster_id,
                                                       filters=filters,
                                                       **params)

        return {'cluster_policies': policies}
Beispiel #12
0
    def index(self, req):
        filter_whitelist = {
            "name": "mixed",
            "target": "mixed",
            "action": "mixed",
            "created_time": "single",
            "updated_time": "single",
            "deleted_time": "single",
        }
        param_whitelist = {
            "limit": "single",
            "marker": "single",
            "sort_dir": "single",
            "sort_keys": "multi",
            "show_deleted": "single",
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        if not filters:
            filters = None

        actions = self.rpc_client.action_list(req.context, filters=filters, **params)

        return {"actions": actions}
Beispiel #13
0
    def _sanitize_policy(self, data):
        """Validate dict body of policy attach or update.

        :param dict data: A dictionary containing the properties of the policy
                          to be attached/updated including the policy ID.
        :returns: A sanitized dict containing the policy properties.
        :raises: :class:`~webob.exception.HTTPBadRequest` if the policy dict
                 contains invalid property values.
        """
        if not isinstance(data, dict):
            msg = _("The data provided is not a map.")
            raise exc.HTTPBadRequest(msg)

        if consts.CP_POLICY_ID not in data:
            msg = _("The 'policy_id' field is missing in the request.")
            raise exc.HTTPBadRequest(msg)

        if consts.CP_ENABLED in data:
            enabled = data.get(consts.CP_ENABLED)
            try:
                enabled = utils.parse_bool_param(consts.CP_ENABLED, enabled)
            except senlin_exc.InvalidParameter as ex:
                raise exc.HTTPBadRequest(six.text_type(ex))
            data[consts.CP_ENABLED] = enabled

        return data
Beispiel #14
0
    def index(self, req):
        filter_whitelist = {
            consts.CLUSTER_NAME: 'mixed',
            consts.CLUSTER_STATUS: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys()
                    and key not in filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        clusters = self.rpc_client.cluster_list(req.context,
                                                filters=filters,
                                                **params)
        return {'clusters': clusters}
Beispiel #15
0
    def get(self, req, node_id):
        key = consts.PARAM_SHOW_DETAILS
        show_details = False
        if key in req.params:
            show_details = utils.parse_bool_param(key, req.params[key])

        node = self.rpc_client.node_get(req.context, node_id,
                                        show_details=show_details)
        return {'node': node}
Beispiel #16
0
    def validate(self):
        if self.name is None:
            raise exc.HTTPBadRequest(_("No trigger name specified."))

        if self.spec is None:
            raise exc.HTTPBadRequest(_("No trigger spec provided."))

        if self.enabled is not None:
            self.enabled = utils.parse_bool_param(consts.TRIGGER_ENABLED,
                                                  self.enabled)
Beispiel #17
0
    def get(self, req, node_id):
        key = consts.PARAM_SHOW_DETAILS
        show_details = False
        if key in req.params:
            show_details = utils.parse_bool_param(key, req.params[key])

        node = self.rpc_client.node_get(req.context,
                                        node_id,
                                        show_details=show_details)
        return {'node': node}
Beispiel #18
0
    def validate(self):
        if self.name is None:
            raise exc.HTTPBadRequest(_("No trigger name specified."))

        if self.spec is None:
            raise exc.HTTPBadRequest(_("No trigger spec provided."))

        if self.enabled is not None:
            self.enabled = utils.parse_bool_param(consts.TRIGGER_ENABLED,
                                                  self.enabled)
Beispiel #19
0
    def index(self, req):
        filter_whitelist = {
            'name': 'mixed',
            'user': '******',
            'obj_id': 'mixed',
            'obj_type': 'mixed',
            'action': 'mixed',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_keys': 'multi',
            'sort_dir': 'single',
            'show_deleted': 'single',
            'global_project': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        webhooks = self.rpc_client.webhook_list(req.context,
                                                filters=filters,
                                                **params)

        return {'webhooks': webhooks}
Beispiel #20
0
    def index(self, req):
        filter_whitelist = {
            'obj_name': 'mixed',
            'obj_type': 'mixed',
            'obj_id': 'mixed',
            'cluster_id': 'mixed',
            'action': 'mixed',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'global_tenant': 'single',
            'show_deleted': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_GLOBAL_TENANT
        if key in params:
            global_tenant = utils.parse_bool_param(key, params[key])
            params.pop(key)
            params['tenant_safe'] = not global_tenant

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        if not filters:
            filters = None

        events = self.rpc_client.event_list(req.context,
                                            filters=filters,
                                            **params)

        return {'events': events}
Beispiel #21
0
    def index(self, req):
        filter_whitelist = {
            'obj_name': 'mixed',
            'obj_type': 'mixed',
            'obj_id': 'mixed',
            'cluster_id': 'mixed',
            'action': 'mixed',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'global_project': 'single',
            'show_deleted': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            global_project = utils.parse_bool_param(key, params[key])
            params.pop(key)
            params['project_safe'] = not global_project

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        if not filters:
            filters = None

        events = self.rpc_client.event_list(req.context,
                                            filters=filters,
                                            **params)

        return {'events': events}
Beispiel #22
0
    def _do_resize(self, req, cluster_id, this_action, body):
        data = body.get(this_action)
        adj_type = data.get(consts.ADJUSTMENT_TYPE)
        number = data.get(consts.ADJUSTMENT_NUMBER)
        min_size = data.get(consts.ADJUSTMENT_MIN_SIZE)
        max_size = data.get(consts.ADJUSTMENT_MAX_SIZE)
        min_step = data.get(consts.ADJUSTMENT_MIN_STEP)
        strict = data.get(consts.ADJUSTMENT_STRICT)
        if adj_type is not None:
            if adj_type not in consts.ADJUSTMENT_TYPES:
                raise senlin_exc.InvalidParameter(name='adjustment_type',
                                                  value=adj_type)
            if number is None:
                msg = _("Missing number value for resize operation.")
                raise exc.HTTPBadRequest(msg)

        if number is not None:
            if adj_type is None:
                msg = _("Missing adjustment_type value for resize "
                        "operation.")
                raise exc.HTTPBadRequest(msg)
            number = utils.parse_int_param(consts.ADJUSTMENT_NUMBER,
                                           number,
                                           allow_negative=True)

        if min_size is not None:
            min_size = utils.parse_int_param(consts.ADJUSTMENT_MIN_SIZE,
                                             min_size)
        if max_size is not None:
            max_size = utils.parse_int_param(consts.ADJUSTMENT_MAX_SIZE,
                                             max_size,
                                             allow_negative=True)
        if (min_size is not None and max_size is not None and max_size > 0
                and min_size > max_size):
            msg = _("The specified min_size (%(n)s) is greater than the "
                    "specified max_size (%(m)s).") % {
                        'm': max_size,
                        'n': min_size
                    }
            raise exc.HTTPBadRequest(msg)

        if min_step is not None:
            min_step = utils.parse_int_param(consts.ADJUSTMENT_MIN_STEP,
                                             min_step)
        if strict is not None:
            strict = utils.parse_bool_param(consts.ADJUSTMENT_STRICT, strict)

        result = self.rpc_client.cluster_resize(req.context, cluster_id,
                                                adj_type, number, min_size,
                                                max_size, min_step, strict)
        location = {'location': '/actions/%s' % result['action']}
        result.update(location)
        return result
Beispiel #23
0
    def index(self, req):
        filter_whitelist = {
            'name': 'mixed',
            'user': '******',
            'obj_id': 'mixed',
            'obj_type': 'mixed',
            'action': 'mixed',
        }
        param_whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_keys': 'multi',
            'sort_dir': 'single',
            'show_deleted': 'single',
            'global_project': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            project_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = project_safe

        if not filters:
            filters = None

        webhooks = self.rpc_client.webhook_list(req.context, filters=filters,
                                                **params)

        return {'webhooks': webhooks}
Beispiel #24
0
    def _do_resize(self, req, cluster_id, this_action, body):
        data = body.get(this_action)
        adj_type = data.get(consts.ADJUSTMENT_TYPE)
        number = data.get(consts.ADJUSTMENT_NUMBER)
        min_size = data.get(consts.ADJUSTMENT_MIN_SIZE)
        max_size = data.get(consts.ADJUSTMENT_MAX_SIZE)
        min_step = data.get(consts.ADJUSTMENT_MIN_STEP)
        strict = data.get(consts.ADJUSTMENT_STRICT)
        if adj_type is not None:
            if adj_type not in consts.ADJUSTMENT_TYPES:
                raise senlin_exc.InvalidParameter(name='adjustment_type',
                                                  value=adj_type)
            if number is None:
                msg = _("Missing number value for resize operation.")
                raise exc.HTTPBadRequest(msg)

        if number is not None:
            if adj_type is None:
                msg = _("Missing adjustment_type value for resize "
                        "operation.")
                raise exc.HTTPBadRequest(msg)
            number = utils.parse_int_param(consts.ADJUSTMENT_NUMBER, number,
                                           allow_negative=True)

        if min_size is not None:
            min_size = utils.parse_int_param(consts.ADJUSTMENT_MIN_SIZE,
                                             min_size)
        if max_size is not None:
            max_size = utils.parse_int_param(consts.ADJUSTMENT_MAX_SIZE,
                                             max_size, allow_negative=True)
        if (min_size is not None and max_size is not None and
                max_size > 0 and min_size > max_size):
            msg = _("The specified min_size (%(n)s) is greater than the "
                    "specified max_size (%(m)s).") % {'m': max_size,
                                                      'n': min_size}
            raise exc.HTTPBadRequest(msg)

        if min_step is not None:
            min_step = utils.parse_int_param(consts.ADJUSTMENT_MIN_STEP,
                                             min_step)
        if strict is not None:
            strict = utils.parse_bool_param(consts.ADJUSTMENT_STRICT, strict)
        else:
            strict = True

        result = self.rpc_client.cluster_resize(req.context, cluster_id,
                                                adj_type, number, min_size,
                                                max_size, min_step, strict)
        location = {'location': '/actions/%s' % result['action']}
        result.update(location)
        return result
Beispiel #25
0
    def index(self, req):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
        }
        param_whitelist = {
            'cluster_id': 'single',
            'show_deleted': 'single',
            'limit': 'single',
            'marker': 'single',
            'sort_keys': 'multi',
            'sort_dir': 'single',
            'global_tenant': 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_SHOW_DELETED
        if key in params:
            params[key] = utils.parse_bool_param(key, params[key])

        key = consts.PARAM_GLOBAL_TENANT
        if key in params:
            tenant_safe = not utils.parse_bool_param(key, params[key])
            del params[key]
            params['tenant_safe'] = tenant_safe

        if not filters:
            filters = None

        nodes = self.rpc_client.node_list(req.context, filters=filters,
                                          **params)

        return {'nodes': nodes}
Beispiel #26
0
    def index(self, req, cluster_id):
        filter_whitelist = {
            consts.CP_ENABLED: 'single',
        }
        param_whitelist = {
            consts.PARAM_SORT: 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)
        key = consts.CP_ENABLED
        if key in filters:
            filters[key] = utils.parse_bool_param(key, filters[key])

        if not filters:
            filters = None
        policies = self.rpc_client.cluster_policy_list(req.context,
                                                       cluster_id=cluster_id,
                                                       filters=filters,
                                                       **params)

        return {'cluster_policies': policies}
Beispiel #27
0
    def index(self, req, cluster_id):
        filter_whitelist = {
            consts.CP_ENABLED: 'single',
        }
        param_whitelist = {
            consts.PARAM_SORT: 'single',
        }
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)
        key = consts.CP_ENABLED
        if key in filters:
            filters[key] = utils.parse_bool_param(key, filters[key])

        if not filters:
            filters = None
        policies = self.rpc_client.cluster_policy_list(req.context,
                                                       cluster_id=cluster_id,
                                                       filters=filters,
                                                       **params)

        return {'cluster_policies': policies}
Beispiel #28
0
    def index(self, req):
        filter_whitelist = {
            consts.EVENT_OBJ_NAME: 'mixed',
            consts.EVENT_OBJ_TYPE: 'mixed',
            consts.EVENT_OBJ_ID: 'mixed',
            consts.EVENT_CLUSTER_ID: 'mixed',
            consts.EVENT_ACTION: 'mixed',
            consts.EVENT_LEVEL: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys() and key not in
                    filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            global_project = utils.parse_bool_param(key, params[key])
            params.pop(key)
            params['project_safe'] = not global_project

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        if not filters:
            filters = None

        events = self.rpc_client.event_list(req.context, filters=filters,
                                            **params)

        return {'events': events}
Beispiel #29
0
    def index(self, req):
        filter_whitelist = {
            consts.ACTION_NAME: 'mixed',
            consts.ACTION_TARGET: 'mixed',
            consts.ACTION_ACTION: 'mixed',
            consts.ACTION_STATUS: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys()
                    and key not in filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            global_project = utils.parse_bool_param(key, params[key])
            params.pop(key)
            params['project_safe'] = not global_project

        if not filters:
            filters = None

        actions = self.rpc_client.action_list(req.context,
                                              filters=filters,
                                              **params)

        return {'actions': actions}
Beispiel #30
0
    def index(self, req):
        filter_whitelist = {
            consts.RECEIVER_NAME: 'mixed',
            consts.RECEIVER_TYPE: 'mixed',
            consts.RECEIVER_CLUSTER_ID: 'mixed',
            consts.RECEIVER_ACTION: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys()
                    and key not in filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            show_global = utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = not show_global

        if not filters:
            filters = None

        receivers = self.rpc_client.receiver_list(req.context,
                                                  filters=filters,
                                                  **params)

        return {'receivers': receivers}
Beispiel #31
0
    def index(self, req):
        filter_whitelist = {
            consts.ACTION_NAME: 'mixed',
            consts.ACTION_TARGET: 'mixed',
            consts.ACTION_ACTION: 'mixed',
            consts.ACTION_STATUS: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys() and key not in
                    filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            global_project = utils.parse_bool_param(key, params[key])
            params.pop(key)
            params['project_safe'] = not global_project

        if not filters:
            filters = None

        actions = self.rpc_client.action_list(req.context, filters=filters,
                                              **params)

        return {'actions': actions}
Beispiel #32
0
    def index(self, req):
        filter_whitelist = {
            consts.RECEIVER_NAME: 'mixed',
            consts.RECEIVER_TYPE: 'mixed',
            consts.RECEIVER_CLUSTER_ID: 'mixed',
            consts.RECEIVER_ACTION: 'mixed',
        }
        param_whitelist = {
            consts.PARAM_LIMIT: 'single',
            consts.PARAM_MARKER: 'single',
            consts.PARAM_SORT: 'single',
            consts.PARAM_GLOBAL_PROJECT: 'single',
        }
        for key in req.params.keys():
            if (key not in param_whitelist.keys() and key not in
                    filter_whitelist.keys()):
                raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
        params = util.get_allowed_params(req.params, param_whitelist)
        filters = util.get_allowed_params(req.params, filter_whitelist)

        key = consts.PARAM_LIMIT
        if key in params:
            params[key] = utils.parse_int_param(key, params[key])

        key = consts.PARAM_GLOBAL_PROJECT
        if key in params:
            show_global = utils.parse_bool_param(key, params[key])
            del params[key]
            params['project_safe'] = not show_global

        if not filters:
            filters = None

        receivers = self.rpc_client.receiver_list(req.context, filters=filters,
                                                  **params)

        return {'receivers': receivers}