Exemplo n.º 1
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if req.params.get('with_count'):
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe)
            except AttributeError as exc:
                logger.warning("Old Engine Version: %s" % str(exc))

        return stacks_view.collection(req, stacks=stacks, count=count,
                                      tenant_safe=tenant_safe)
Exemplo n.º 2
0
    def index(self, req, identity, resource_name=None):
        """
        Lists summary information for all events
        """
        whitelist = {"limit": "single", "marker": "single", "sort_dir": "single", "sort_keys": "multi"}
        filter_whitelist = {
            "resource_status": "mixed",
            "resource_action": "mixed",
            "resource_name": "mixed",
            "resource_type": "mixed",
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)
        key = rpc_api.PARAM_LIMIT
        if key in params:
            try:
                limit = param_utils.extract_int(key, params[key], allow_zero=True)
            except ValueError as e:
                raise exc.HTTPBadRequest(six.text_type(e))
            params[key] = limit

        if resource_name is None:
            if not filter_params:
                filter_params = None
        else:
            filter_params["resource_name"] = resource_name

        events = self._event_list(req, identity, filters=filter_params, **params)

        if not events and resource_name is not None:
            msg = _("No events found for resource %s") % resource_name
            raise exc.HTTPNotFound(msg)

        return {"events": events}
Exemplo n.º 3
0
    def index(self, req, identity, resource_name=None):
        """
        Lists summary information for all events
        """
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        filter_whitelist = {
            'resource_status': 'mixed',
            'resource_action': 'mixed',
            'resource_name': 'mixed',
            'resource_type': 'mixed',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)
        if not filter_params:
            filter_params = None

        if resource_name is None:
            events = self._event_list(req, identity,
                                      filters=filter_params, **params)
        else:
            res_match = lambda e: e[rpc_api.EVENT_RES_NAME] == resource_name

            events = self._event_list(req, identity, res_match,
                                      filters=filter_params, **params)
            if not events:
                msg = _('No events found for resource %s') % resource_name
                raise exc.HTTPNotFound(msg)

        return {'events': events}
Exemplo n.º 4
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'tenant': 'mixed',
            'username': '******',
            'owner_id': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
            'show_nested': 'single',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        show_deleted = False
        if rpc_api.PARAM_SHOW_DELETED in params:
            params[rpc_api.PARAM_SHOW_DELETED] = param_utils.extract_bool(
                params[rpc_api.PARAM_SHOW_DELETED])
            show_deleted = params[rpc_api.PARAM_SHOW_DELETED]
        show_nested = False
        if rpc_api.PARAM_SHOW_NESTED in params:
            params[rpc_api.PARAM_SHOW_NESTED] = param_utils.extract_bool(
                params[rpc_api.PARAM_SHOW_NESTED])
            show_nested = params[rpc_api.PARAM_SHOW_NESTED]
        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get('with_count'):
            with_count = param_utils.extract_bool(req.params.get('with_count'))

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe,
                                                     show_deleted=show_deleted,
                                                     show_nested=show_nested)
            except AttributeError as exc:
                LOG.warn(_LW("Old Engine Version: %s") % exc)

        return stacks_view.collection(req,
                                      stacks=stacks,
                                      count=count,
                                      tenant_safe=tenant_safe)
Exemplo n.º 5
0
    def index(self, req):
        """
        Lists summary information for all stacks
        """
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        stacks = self.engine.list_stacks(req.context,
                                         filters=filter_params,
                                         **params)

        count = None
        if req.params.get('with_count'):
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.engine.count_stacks(req.context,
                                                 filters=filter_params)
            except AttributeError as exc:
                logger.warning("Old Engine Version: %s" % str(exc))

        return stacks_view.collection(req, stacks=stacks, count=count)
Exemplo n.º 6
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if req.params.get('with_count'):
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe)
            except AttributeError as exc:
                logger.warning("Old Engine Version: %s" % str(exc))

        return stacks_view.collection(req, stacks=stacks, count=count,
                                      tenant_safe=tenant_safe)
Exemplo n.º 7
0
    def index(self, req):
        """
        Lists summary information for all stacks
        """
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        stacks = self.engine.list_stacks(req.context,
                                         filters=filter_params,
                                         **params)

        count = None
        if req.params.get('with_count'):
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.engine.count_stacks(req.context,
                                                 filters=filter_params)
            except AttributeError as exc:
                logger.warning("Old Engine Version: %s" % str(exc))

        return stacks_view.collection(req, stacks=stacks, count=count)
Exemplo n.º 8
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'tenant': 'mixed',
            'username': '******',
            'owner_id': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
            'show_nested': 'single',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        show_deleted = False
        if engine_api.PARAM_SHOW_DELETED in params:
            params[engine_api.PARAM_SHOW_DELETED] = param_utils.extract_bool(
                params[engine_api.PARAM_SHOW_DELETED])
            show_deleted = params[engine_api.PARAM_SHOW_DELETED]
        show_nested = False
        if engine_api.PARAM_SHOW_NESTED in params:
            params[engine_api.PARAM_SHOW_NESTED] = param_utils.extract_bool(
                params[engine_api.PARAM_SHOW_NESTED])
            show_nested = params[engine_api.PARAM_SHOW_NESTED]
        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get('with_count'):
            with_count = param_utils.extract_bool(
                req.params.get('with_count'))

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe,
                                                     show_deleted=show_deleted,
                                                     show_nested=show_nested)
            except AttributeError as exc:
                LOG.warn(_LW("Old Engine Version: %s") % exc)

        return stacks_view.collection(req, stacks=stacks, count=count,
                                      tenant_safe=tenant_safe)
Exemplo n.º 9
0
Arquivo: events.py Projeto: srz01/heat
    def index(self, req, identity, resource_name=None):
        """
        Lists summary information for all events
        """
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        filter_whitelist = {
            'resource_status': 'mixed',
            'resource_action': 'mixed',
            'resource_name': 'mixed',
            'resource_type': 'mixed',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)
        if not filter_params:
            filter_params = None

        key = rpc_api.PARAM_LIMIT
        if key in params:
            try:
                limit = param_utils.extract_int(key,
                                                params[key],
                                                allow_zero=True)
            except ValueError as e:
                raise exc.HTTPBadRequest(six.text_type(e))
            params[key] = limit

        if resource_name is None:
            events = self._event_list(req,
                                      identity,
                                      filters=filter_params,
                                      **params)
        else:
            res_match = lambda e: e[rpc_api.EVENT_RES_NAME] == resource_name

            events = self._event_list(req,
                                      identity,
                                      res_match,
                                      filters=filter_params,
                                      **params)
            if not events:
                msg = _('No events found for resource %s') % resource_name
                raise exc.HTTPNotFound(msg)

        return {'events': events}
Exemplo n.º 10
0
    def _param_show_nested(self, req):
        whitelist = {'show_nested': 'single'}
        params = util.get_allowed_params(req.params, whitelist)

        p_name = 'show_nested'
        if p_name in params:
            return self._extract_bool_param(p_name, params[p_name])
Exemplo n.º 11
0
    def validate_template(self, req, body):
        """
        Implements the ValidateTemplate API action
        Validates the specified template
        """

        data = InstantiationData(body)

        whitelist = {'show_nested': 'single'}
        params = util.get_allowed_params(req.params, whitelist)

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        result = self.rpc_client.validate_template(req.context,
                                                   data.template(),
                                                   data.environment(),
                                                   files=data.files(),
                                                   show_nested=show_nested)

        if 'Error' in result:
            raise exc.HTTPBadRequest(result['Error'])

        return result
Exemplo n.º 12
0
    def _param_show_nested(self, req):
        param_types = {'show_nested': util.PARAM_TYPE_SINGLE}
        params = util.get_allowed_params(req.params, param_types)

        p_name = 'show_nested'
        if p_name in params:
            return self._extract_bool_param(p_name, params[p_name])
Exemplo n.º 13
0
    def _param_show_nested(self, req):
        whitelist = {'show_nested': 'single'}
        params = util.get_allowed_params(req.params, whitelist)

        p_name = 'show_nested'
        if p_name in params:
            return self._extract_bool_param(p_name, params[p_name])
Exemplo n.º 14
0
    def index(self, req, identity):
        """Lists information for all resources."""

        whitelist = {
            'type': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'id': 'mixed',
            'physical_resource_id': 'mixed'
        }

        nested_depth = self._extract_to_param(req,
                                              rpc_api.PARAM_NESTED_DEPTH,
                                              param_utils.extract_int,
                                              default=0)
        with_detail = self._extract_to_param(req,
                                             rpc_api.PARAM_WITH_DETAIL,
                                             param_utils.extract_bool,
                                             default=False)

        params = util.get_allowed_params(req.params, whitelist)

        res_list = self.rpc_client.list_stack_resources(req.context,
                                                        identity,
                                                        nested_depth,
                                                        with_detail,
                                                        filters=params)

        return {'resources': [format_resource(req, res) for res in res_list]}
Exemplo n.º 15
0
 def _index(self, req, tenant_safe=True):
     whitelist = {'limit': 'single', 'marker': 'single'}
     params = util.get_allowed_params(req.params, whitelist)
     scs = self.rpc_client.list_software_configs(req.context,
                                                 tenant_safe=tenant_safe,
                                                 **params)
     return {'software_configs': scs}
Exemplo n.º 16
0
    def index(self, req, identity):
        """Lists information for all resources."""

        whitelist = {
            'type': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'id': 'mixed',
            'physical_resource_id': 'mixed'
        }

        nested_depth = self._extract_to_param(req,
                                              rpc_api.PARAM_NESTED_DEPTH,
                                              param_utils.extract_int,
                                              default=0)
        with_detail = self._extract_to_param(req,
                                             rpc_api.PARAM_WITH_DETAIL,
                                             param_utils.extract_bool,
                                             default=False)

        params = util.get_allowed_params(req.params, whitelist)

        res_list = self.rpc_client.list_stack_resources(req.context,
                                                        identity,
                                                        nested_depth,
                                                        with_detail,
                                                        filters=params)

        return {'resources': [format_resource(req, res) for res in res_list]}
Exemplo n.º 17
0
    def validate_template(self, req, body):
        """Implements the ValidateTemplate API action.

        Validates the specified template.
        """

        data = InstantiationData(body)

        whitelist = {'show_nested': 'single'}
        params = util.get_allowed_params(req.params, whitelist)

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        result = self.rpc_client.validate_template(req.context,
                                                   data.template(),
                                                   data.environment(),
                                                   files=data.files(),
                                                   show_nested=show_nested)

        if 'Error' in result:
            raise exc.HTTPBadRequest(result['Error'])

        return result
Exemplo n.º 18
0
def data_list_from_db(req):
    filter_whitelist = {
         'create_time_first': 'single',
         'create_time_end': 'single',
         'app_name': 'single',
         'stack_apps_style': 'single',
         'stack_status': 'single'
        }
    whitelist = {
         'limit': 'single',
         'offset': 'single',
         'sort_dir': 'single',
         'sort_keys': 'multi',
    }
    params = util.get_allowed_params(req.params, whitelist)
    filter_params = util.get_allowed_params(req.params, filter_whitelist)
    return db_api.data_get_all_for_g_cloud(req.context, filters=validate_and_translate(filter_params), **params)
Exemplo n.º 19
0
    def test_handles_mixed_value_param_with_multiple_entries(self):
        self.whitelist = {'foo': 'mixed'}
        self.params.add('foo', 'foo value 2')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual(2, len(result['foo']))
        self.assertIn('foo value', result['foo'])
        self.assertIn('foo value 2', result['foo'])
Exemplo n.º 20
0
    def test_handles_mixed_value_param_with_multiple_entries(self):
        self.param_types = {'foo': util.PARAM_TYPE_MIXED}
        self.params.add('foo', 'foo value 2')

        result = util.get_allowed_params(self.params, self.param_types)
        self.assertEqual(2, len(result['foo']))
        self.assertIn('foo value', result['foo'])
        self.assertIn('foo value 2', result['foo'])
Exemplo n.º 21
0
    def test_handles_multiple_value_params(self):
        self.whitelist = {'foo': util.PARAM_TYPE_MULTI}
        self.params.add('foo', 'foo value 2')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual(2, len(result['foo']))
        self.assertIn('foo value', result['foo'])
        self.assertIn('foo value 2', result['foo'])
Exemplo n.º 22
0
    def test_handles_mixed_value_param_with_multiple_entries(self):
        self.whitelist = {'foo': util.PARAM_TYPE_MIXED}
        self.params.add('foo', 'foo value 2')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual(2, len(result['foo']))
        self.assertIn('foo value', result['foo'])
        self.assertIn('foo value 2', result['foo'])
 def index(self, req):
     """List software deployments."""
     whitelist = {
         'server_id': 'single',
     }
     params = util.get_allowed_params(req.params, whitelist)
     sds = self.rpc_client.list_software_deployments(req.context, **params)
     return {'software_deployments': sds}
Exemplo n.º 24
0
    def test_handles_multiple_value_params(self):
        self.whitelist = {'foo': 'multi'}
        self.params.add('foo', 'foo value 2')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual(2, len(result['foo']))
        self.assertIn('foo value', result['foo'])
        self.assertIn('foo value 2', result['foo'])
Exemplo n.º 25
0
 def index(self, req):
     """List software deployments."""
     whitelist = {
         'server_id': util.PARAM_TYPE_SINGLE,
     }
     params = util.get_allowed_params(req.params, whitelist)
     sds = self.rpc_client.list_software_deployments(req.context, **params)
     return {'software_deployments': sds}
Exemplo n.º 26
0
    def index(self, req, identity, resource_name=None):
        """
        Lists summary information for all events
        """
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
        }
        filter_whitelist = {
            'resource_status': 'mixed',
            'resource_action': 'mixed',
            'resource_name': 'mixed',
            'resource_type': 'mixed',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)
        if not filter_params:
            filter_params = None

        key = rpc_api.PARAM_LIMIT
        if key in params:
            try:
                limit = param_utils.extract_int(key, params[key],
                                                allow_zero=True)
            except ValueError as e:
                raise exc.HTTPBadRequest(six.text_type(e))
            params[key] = limit

        if resource_name is None:
            events = self._event_list(req, identity,
                                      filters=filter_params, **params)
        else:

            def res_match(e):
                return e[rpc_api.EVENT_RES_NAME] == resource_name

            events = self._event_list(req, identity, res_match,
                                      filters=filter_params, **params)
            if not events:
                msg = _('No events found for resource %s') % resource_name
                raise exc.HTTPNotFound(msg)

        return {'events': events}
    def show(self, req, identity, resource_name):
        """Gets detailed information for a resource."""

        whitelist = {'with_attr': 'multi'}
        params = util.get_allowed_params(req.params, whitelist)
        res = self.rpc_client.describe_stack_resource(req.context, identity,
                                                      resource_name, **params)

        return {'resource': format_resource(req, res)}
Exemplo n.º 28
0
        def index(self, req):

            filter_whitelist = {
                'name': 'single',
                'type': 'single',
                'user': '******',
            }
            whitelist = {
                'limit': 'single',
                'offset': 'single',
                'sort_dir': 'single',
                'sort_keys': 'multi',
            }
            params = util.get_allowed_params(req.params, whitelist)
            filter_params = util.get_allowed_params(req.params, filter_whitelist)
            templates = db_api.template_get_all(req.context, filters=translate_filters(filter_params), **params)

            return get_index_template_response_info(templates)
Exemplo n.º 29
0
    def index(self, req, identity, resource_name=None):
        """Lists summary information for all events."""
        param_types = {
            'limit': util.PARAM_TYPE_SINGLE,
            'marker': util.PARAM_TYPE_SINGLE,
            'sort_dir': util.PARAM_TYPE_SINGLE,
            'sort_keys': util.PARAM_TYPE_MULTI,
            'nested_depth': util.PARAM_TYPE_SINGLE,
        }
        filter_param_types = {
            'resource_status': util.PARAM_TYPE_MIXED,
            'resource_action': util.PARAM_TYPE_MIXED,
            'resource_name': util.PARAM_TYPE_MIXED,
            'resource_type': util.PARAM_TYPE_MIXED,
        }
        params = util.get_allowed_params(req.params, param_types)
        filter_params = util.get_allowed_params(req.params, filter_param_types)

        int_params = (rpc_api.PARAM_LIMIT, rpc_api.PARAM_NESTED_DEPTH)
        try:
            for key in int_params:
                if key in params:
                    params[key] = param_utils.extract_int(key,
                                                          params[key],
                                                          allow_zero=True)
        except ValueError as e:
            raise exc.HTTPBadRequest(str(e))

        if resource_name is None:
            if not filter_params:
                filter_params = None
        else:
            filter_params['resource_name'] = resource_name

        events = self._event_list(req,
                                  identity,
                                  filters=filter_params,
                                  **params)

        if not events and resource_name is not None:
            msg = _('No events found for resource %s') % resource_name
            raise exc.HTTPNotFound(msg)

        return {'events': events}
Exemplo n.º 30
0
    def show(self, req, identity, resource_name):
        """Gets detailed information for a resource."""

        whitelist = {"with_attr": util.PARAM_TYPE_MULTI}
        params = util.get_allowed_params(req.params, whitelist)
        if "with_attr" not in params:
            params["with_attr"] = None
        res = self.rpc_client.describe_stack_resource(req.context, identity, resource_name, **params)

        return {"resource": format_resource(req, res)}
Exemplo n.º 31
0
 def _index(self, req, tenant_safe=True):
     whitelist = {
         'limit': 'single',
         'marker': 'single'
     }
     params = util.get_allowed_params(req.params, whitelist)
     scs = self.rpc_client.list_software_configs(req.context,
                                                 tenant_safe=tenant_safe,
                                                 **params)
     return {'software_configs': scs}
Exemplo n.º 32
0
    def show(self, req, identity, resource_name):
        """
        Gets detailed information for a resource
        """

        whitelist = {"with_attr": "multi"}
        params = util.get_allowed_params(req.params, whitelist)
        res = self.rpc_client.describe_stack_resource(req.context, identity, resource_name, **params)

        return {"resource": format_resource(req, res)}
Exemplo n.º 33
0
 def index(self, req):
     """
     List software deployments.
     """
     whitelist = {
         'server_id': 'single',
     }
     params = util.get_allowed_params(req.params, whitelist)
     sds = self.engine.list_software_deployments(req.context, **params)
     return {'software_deployments': sds}
Exemplo n.º 34
0
    def show(self, req, identity, resource_name):
        """Gets detailed information for a resource."""

        whitelist = {'with_attr': util.PARAM_TYPE_MULTI}
        params = util.get_allowed_params(req.params, whitelist)
        if 'with_attr' not in params:
            params['with_attr'] = None
        res = self.rpc_client.describe_stack_resource(req.context, identity,
                                                      resource_name, **params)

        return {'resource': format_resource(req, res)}
Exemplo n.º 35
0
    def index(self, req, identity, resource_name=None):
        """Lists summary information for all events."""
        whitelist = {
            'limit': util.PARAM_TYPE_SINGLE,
            'marker': util.PARAM_TYPE_SINGLE,
            'sort_dir': util.PARAM_TYPE_SINGLE,
            'sort_keys': util.PARAM_TYPE_MULTI,
            'nested_depth': util.PARAM_TYPE_SINGLE,
        }
        filter_whitelist = {
            'resource_status': util.PARAM_TYPE_MIXED,
            'resource_action': util.PARAM_TYPE_MIXED,
            'resource_name': util.PARAM_TYPE_MIXED,
            'resource_type': util.PARAM_TYPE_MIXED,
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        int_params = (rpc_api.PARAM_LIMIT, rpc_api.PARAM_NESTED_DEPTH)
        try:
            for key in int_params:
                if key in params:
                    params[key] = param_utils.extract_int(
                        key, params[key], allow_zero=True)
        except ValueError as e:
            raise exc.HTTPBadRequest(six.text_type(e))

        if resource_name is None:
            if not filter_params:
                filter_params = None
        else:
            filter_params['resource_name'] = resource_name

        events = self._event_list(
            req, identity, filters=filter_params, **params)

        if not events and resource_name is not None:
            msg = _('No events found for resource %s') % resource_name
            raise exc.HTTPNotFound(msg)

        return {'events': events}
Exemplo n.º 36
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {"status": "mixed", "name": "mixed"}
        whitelist = {"limit": "single", "marker": "single", "sort_dir": "single", "sort_keys": "multi"}
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context, filters=filter_params, tenant_safe=tenant_safe, **params)

        count = None
        if req.params.get("with_count"):
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context, filters=filter_params, tenant_safe=tenant_safe)
            except AttributeError as exc:
                logger.warning(_("Old Engine Version: %s") % exc)

        return stacks_view.collection(req, stacks=stacks, count=count, tenant_safe=tenant_safe)
Exemplo n.º 37
0
    def _index(self, req, use_admin_cnxt=False):
        param_types = {
            'limit': util.PARAM_TYPE_SINGLE,
            'marker': util.PARAM_TYPE_SINGLE
        }
        params = util.get_allowed_params(req.params, param_types)

        if use_admin_cnxt:
            cnxt = context.get_admin_context()
        else:
            cnxt = req.context
        scs = self.rpc_client.list_software_configs(cnxt, **params)
        return {'software_configs': scs}
Exemplo n.º 38
0
Arquivo: stacks.py Projeto: rmery/heat
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {"status": "mixed", "name": "mixed", "action": "mixed"}
        whitelist = {
            "limit": "single",
            "marker": "single",
            "sort_dir": "single",
            "sort_keys": "multi",
            "show_deleted": "single",
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        show_deleted = False
        if engine_api.PARAM_SHOW_DELETED in params:
            params[engine_api.PARAM_SHOW_DELETED] = param_utils.extract_bool(params[engine_api.PARAM_SHOW_DELETED])
            show_deleted = params[engine_api.PARAM_SHOW_DELETED]
        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get("with_count"):
            with_count = param_utils.extract_bool(req.params.get("with_count"))

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context, filters=filter_params, tenant_safe=tenant_safe, **params)

        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(
                    req.context, filters=filter_params, tenant_safe=tenant_safe, show_deleted=show_deleted
                )
            except AttributeError as exc:
                LOG.warning(_("Old Engine Version: %s") % exc)

        return stacks_view.collection(req, stacks=stacks, count=count, tenant_safe=tenant_safe)
Exemplo n.º 39
0
    def _index(self, req, use_admin_cnxt=False):
        whitelist = {
            'limit': util.PARAM_TYPE_SINGLE,
            'marker': util.PARAM_TYPE_SINGLE
        }
        params = util.get_allowed_params(req.params, whitelist)

        if use_admin_cnxt:
            cnxt = context.get_admin_context()
        else:
            cnxt = req.context
        scs = self.rpc_client.list_software_configs(cnxt,
                                                    **params)
        return {'software_configs': scs}
Exemplo n.º 40
0
    def validate_template(self, req, body):
        """Implements the ValidateTemplate API action.

        Validates the specified template.
        """

        data = InstantiationData(body)

        param_types = {
            'show_nested': util.PARAM_TYPE_SINGLE,
            'ignore_errors': util.PARAM_TYPE_SINGLE
        }
        params = util.get_allowed_params(req.params, param_types)

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        if rpc_api.PARAM_IGNORE_ERRORS in params:
            ignorable_errors = params[rpc_api.PARAM_IGNORE_ERRORS].split(',')
        else:
            ignorable_errors = None

        result = self.rpc_client.validate_template(
            req.context,
            data.template(),
            data.environment(),
            files=data.files(),
            environment_files=data.environment_files(),
            files_container=data.files_container(),
            show_nested=show_nested,
            ignorable_errors=ignorable_errors)

        if 'Error' in result:
            raise exc.HTTPBadRequest(result['Error'])

        return result
Exemplo n.º 41
0
    def index(self, req, identity):
        """Lists information for all resources."""

        whitelist = {
            'type': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'id': 'mixed',
            'physical_resource_id': 'mixed'
        }

        invalid_keys = (set(req.params.keys()) - set(
            list(whitelist) +
            [rpc_api.PARAM_NESTED_DEPTH, rpc_api.PARAM_WITH_DETAIL]))
        if invalid_keys:
            raise exc.HTTPBadRequest(
                _('Invalid filter parameters %s') %
                six.text_type(list(invalid_keys)))

        nested_depth = self._extract_to_param(req,
                                              rpc_api.PARAM_NESTED_DEPTH,
                                              param_utils.extract_int,
                                              default=0)
        with_detail = self._extract_to_param(req,
                                             rpc_api.PARAM_WITH_DETAIL,
                                             param_utils.extract_bool,
                                             default=False)

        params = util.get_allowed_params(req.params, whitelist)

        res_list = self.rpc_client.list_stack_resources(req.context,
                                                        identity,
                                                        nested_depth,
                                                        with_detail,
                                                        filters=params)

        return {'resources': [format_resource(req, res) for res in res_list]}
Exemplo n.º 42
0
    def index(self, req, identity):
        """Lists information for all resources."""

        whitelist = {
            'type': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'id': 'mixed',
            'physical_resource_id': 'mixed'
        }

        invalid_keys = (set(req.params.keys()) -
                        set(list(whitelist) + [rpc_api.PARAM_NESTED_DEPTH,
                                               rpc_api.PARAM_WITH_DETAIL]))
        if invalid_keys:
            raise exc.HTTPBadRequest(_('Invalid filter parameters %s') %
                                     six.text_type(list(invalid_keys)))

        nested_depth = self._extract_to_param(req,
                                              rpc_api.PARAM_NESTED_DEPTH,
                                              param_utils.extract_int,
                                              default=0)
        with_detail = self._extract_to_param(req,
                                             rpc_api.PARAM_WITH_DETAIL,
                                             param_utils.extract_bool,
                                             default=False)

        params = util.get_allowed_params(req.params, whitelist)

        res_list = self.rpc_client.list_stack_resources(req.context,
                                                        identity,
                                                        nested_depth,
                                                        with_detail,
                                                        filters=params)

        return {'resources': [format_resource(req, res) for res in res_list]}
Exemplo n.º 43
0
    def validate_template(self, req, body):
        """Implements the ValidateTemplate API action.

        Validates the specified template.
        """

        data = InstantiationData(body)

        whitelist = {'show_nested': util.PARAM_TYPE_SINGLE,
                     'ignore_errors': util.PARAM_TYPE_SINGLE}
        params = util.get_allowed_params(req.params, whitelist)

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        if rpc_api.PARAM_IGNORE_ERRORS in params:
            ignorable_errors = params[rpc_api.PARAM_IGNORE_ERRORS].split(',')
        else:
            ignorable_errors = None

        result = self.rpc_client.validate_template(
            req.context,
            data.template(),
            data.environment(),
            files=data.files(),
            environment_files=data.environment_files(),
            files_container=data.files_container(),
            show_nested=show_nested,
            ignorable_errors=ignorable_errors)

        if 'Error' in result:
            raise exc.HTTPBadRequest(result['Error'])

        return result
Exemplo n.º 44
0
    def _index(self, req, use_admin_cnxt=False):
        filter_whitelist = {
            # usage of keys in this list are not encouraged, please use
            # rpc_api.STACK_KEYS instead
            'id': util.PARAM_TYPE_MIXED,
            'status': util.PARAM_TYPE_MIXED,
            'name': util.PARAM_TYPE_MIXED,
            'action': util.PARAM_TYPE_MIXED,
            'tenant': util.PARAM_TYPE_MIXED,
            'username': util.PARAM_TYPE_MIXED,
            'owner_id': util.PARAM_TYPE_MIXED,
        }
        whitelist = {
            'limit': util.PARAM_TYPE_SINGLE,
            'marker': util.PARAM_TYPE_SINGLE,
            'sort_dir': util.PARAM_TYPE_SINGLE,
            'sort_keys': util.PARAM_TYPE_MULTI,
            'show_deleted': util.PARAM_TYPE_SINGLE,
            'show_nested': util.PARAM_TYPE_SINGLE,
            'show_hidden': util.PARAM_TYPE_SINGLE,
            'tags': util.PARAM_TYPE_SINGLE,
            'tags_any': util.PARAM_TYPE_SINGLE,
            'not_tags': util.PARAM_TYPE_SINGLE,
            'not_tags_any': util.PARAM_TYPE_SINGLE,
        }
        params = util.get_allowed_params(req.params, whitelist)
        stack_keys = dict.fromkeys(rpc_api.STACK_KEYS, util.PARAM_TYPE_MIXED)
        unsupported = (
            rpc_api.STACK_ID,  # not user visible
            rpc_api.STACK_CAPABILITIES,  # not supported
            rpc_api.STACK_CREATION_TIME,  # don't support timestamp
            rpc_api.STACK_DELETION_TIME,  # don't support timestamp
            rpc_api.STACK_DESCRIPTION,  # not supported
            rpc_api.STACK_NOTIFICATION_TOPICS,  # not supported
            rpc_api.STACK_OUTPUTS,  # not in database
            rpc_api.STACK_PARAMETERS,  # not in this table
            rpc_api.STACK_TAGS,  # tags query following a specific guideline
            rpc_api.STACK_TMPL_DESCRIPTION,  # not supported
            rpc_api.STACK_UPDATED_TIME,  # don't support timestamp
        )
        for key in unsupported:
            stack_keys.pop(key)
        # downward compatibility
        stack_keys.update(filter_whitelist)
        filter_params = util.get_allowed_params(req.params, stack_keys)

        show_deleted = False
        p_name = rpc_api.PARAM_SHOW_DELETED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_deleted = params[p_name]

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        key = rpc_api.PARAM_LIMIT
        if key in params:
            params[key] = self._extract_int_param(key, params[key])

        show_hidden = False
        p_name = rpc_api.PARAM_SHOW_HIDDEN
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_hidden = params[p_name]

        tags = None
        if rpc_api.PARAM_TAGS in params:
            params[rpc_api.PARAM_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS])
            tags = params[rpc_api.PARAM_TAGS]

        tags_any = None
        if rpc_api.PARAM_TAGS_ANY in params:
            params[rpc_api.PARAM_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS_ANY])
            tags_any = params[rpc_api.PARAM_TAGS_ANY]

        not_tags = None
        if rpc_api.PARAM_NOT_TAGS in params:
            params[rpc_api.PARAM_NOT_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS])
            not_tags = params[rpc_api.PARAM_NOT_TAGS]

        not_tags_any = None
        if rpc_api.PARAM_NOT_TAGS_ANY in params:
            params[rpc_api.PARAM_NOT_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS_ANY])
            not_tags_any = params[rpc_api.PARAM_NOT_TAGS_ANY]

        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get('with_count'):
            with_count = self._extract_bool_param('with_count',
                                                  req.params.get('with_count'))

        if not filter_params:
            filter_params = None

        if use_admin_cnxt:
            cnxt = context.get_admin_context()
        else:
            cnxt = req.context

        stacks = self.rpc_client.list_stacks(cnxt,
                                             filters=filter_params,
                                             **params)
        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(cnxt,
                                                     filters=filter_params,
                                                     show_deleted=show_deleted,
                                                     show_nested=show_nested,
                                                     show_hidden=show_hidden,
                                                     tags=tags,
                                                     tags_any=tags_any,
                                                     not_tags=not_tags,
                                                     not_tags_any=not_tags_any)
            except AttributeError as ex:
                LOG.warning("Old Engine Version: %s", ex)

        return stacks_view.collection(req,
                                      stacks=stacks,
                                      count=count,
                                      include_project=cnxt.is_admin)
Exemplo n.º 45
0
    def test_returns_only_whitelisted_params(self):
        self.params.add('bar', 'bar value')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertIn('foo', result)
        self.assertNotIn('bar', result)
Exemplo n.º 46
0
 def test_handles_single_value_params(self):
     result = util.get_allowed_params(self.params, self.whitelist)
     self.assertEqual('foo value', result['foo'])
Exemplo n.º 47
0
    def test_returns_empty_dict(self):
        self.whitelist = {}

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual({}, result)
Exemplo n.º 48
0
    def test_only_adds_whitelisted_params_if_param_exists(self):
        self.whitelist = {'foo': 'single'}
        self.params.clear()

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertNotIn('foo', result)
Exemplo n.º 49
0
    def test_handles_mixed_value_param_with_single_entry(self):
        self.param_types = {'foo': util.PARAM_TYPE_MIXED}

        result = util.get_allowed_params(self.params, self.param_types)
        self.assertEqual('foo value', result['foo'])
Exemplo n.º 50
0
 def test_ignores_bogus_whitelist_items(self):
     self.whitelist = {'foo': 'blah'}
     result = util.get_allowed_params(self.params, self.whitelist)
     self.assertNotIn('foo', result)
Exemplo n.º 51
0
    def test_returns_empty_dict(self):
        self.whitelist = {}

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual({}, result)
Exemplo n.º 52
0
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            # usage of keys in this list are not encouraged, please use
            # rpc_api.STACK_KEYS instead
            'id': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'tenant': 'mixed',
            'username': '******',
            'owner_id': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
            'show_nested': 'single',
            'show_hidden': 'single',
            'tags': 'single',
            'tags_any': 'single',
            'not_tags': 'single',
            'not_tags_any': 'single',
        }
        params = util.get_allowed_params(req.params, whitelist)
        stack_keys = dict.fromkeys(rpc_api.STACK_KEYS, 'mixed')
        unsupported = (
            rpc_api.STACK_ID,  # not user visible
            rpc_api.STACK_CAPABILITIES,  # not supported
            rpc_api.STACK_CREATION_TIME,  # don't support timestamp
            rpc_api.STACK_DELETION_TIME,  # don't support timestamp
            rpc_api.STACK_DESCRIPTION,  # not supported
            rpc_api.STACK_NOTIFICATION_TOPICS,  # not supported
            rpc_api.STACK_OUTPUTS,  # not in database
            rpc_api.STACK_PARAMETERS,  # not in this table
            rpc_api.STACK_TAGS,  # tags query following a specific guideline
            rpc_api.STACK_TMPL_DESCRIPTION,  # not supported
            rpc_api.STACK_UPDATED_TIME,  # don't support timestamp
        )
        for key in unsupported:
            stack_keys.pop(key)
        # downward compatibility
        stack_keys.update(filter_whitelist)
        filter_params = util.get_allowed_params(req.params, stack_keys)

        show_deleted = False
        p_name = rpc_api.PARAM_SHOW_DELETED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_deleted = params[p_name]

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        key = rpc_api.PARAM_LIMIT
        if key in params:
            params[key] = self._extract_int_param(key, params[key])

        show_hidden = False
        p_name = rpc_api.PARAM_SHOW_HIDDEN
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_hidden = params[p_name]

        tags = None
        if rpc_api.PARAM_TAGS in params:
            params[rpc_api.PARAM_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS])
            tags = params[rpc_api.PARAM_TAGS]

        tags_any = None
        if rpc_api.PARAM_TAGS_ANY in params:
            params[rpc_api.PARAM_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS_ANY])
            tags_any = params[rpc_api.PARAM_TAGS_ANY]

        not_tags = None
        if rpc_api.PARAM_NOT_TAGS in params:
            params[rpc_api.PARAM_NOT_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS])
            not_tags = params[rpc_api.PARAM_NOT_TAGS]

        not_tags_any = None
        if rpc_api.PARAM_NOT_TAGS_ANY in params:
            params[rpc_api.PARAM_NOT_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS_ANY])
            not_tags_any = params[rpc_api.PARAM_NOT_TAGS_ANY]

        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get('with_count'):
            with_count = self._extract_bool_param(
                'with_count',
                req.params.get('with_count'))

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe,
                                                     show_deleted=show_deleted,
                                                     show_nested=show_nested,
                                                     show_hidden=show_hidden,
                                                     tags=tags,
                                                     tags_any=tags_any,
                                                     not_tags=not_tags,
                                                     not_tags_any=not_tags_any)
            except AttributeError as ex:
                LOG.warn(_LW("Old Engine Version: %s"), ex)

        return stacks_view.collection(req, stacks=stacks, count=count,
                                      tenant_safe=tenant_safe)
Exemplo n.º 53
0
    def test_only_adds_whitelisted_params_if_param_exists(self):
        self.whitelist = {'foo': util.PARAM_TYPE_SINGLE}
        self.params.clear()

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertNotIn('foo', result)
Exemplo n.º 54
0
    def test_returns_only_whitelisted_params(self):
        self.params.add('bar', 'bar value')

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertIn('foo', result)
        self.assertNotIn('bar', result)
Exemplo n.º 55
0
    def test_handles_mixed_value_param_with_single_entry(self):
        self.whitelist = {'foo': 'mixed'}

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual('foo value', result['foo'])
Exemplo n.º 56
0
    def test_handles_mixed_value_param_with_single_entry(self):
        self.whitelist = {'foo': util.PARAM_TYPE_MIXED}

        result = util.get_allowed_params(self.params, self.whitelist)
        self.assertEqual('foo value', result['foo'])
Exemplo n.º 57
0
 def test_handles_single_value_params(self):
     result = util.get_allowed_params(self.params, self.whitelist)
     self.assertEqual('foo value', result['foo'])
Exemplo n.º 58
0
 def test_ignores_bogus_whitelist_items(self):
     self.whitelist = {'foo': 'blah'}
     result = util.get_allowed_params(self.params, self.whitelist)
     self.assertNotIn('foo', result)
Exemplo n.º 59
0
Arquivo: stacks.py Projeto: srz01/heat
    def _index(self, req, tenant_safe=True):
        filter_whitelist = {
            'id': 'mixed',
            'status': 'mixed',
            'name': 'mixed',
            'action': 'mixed',
            'tenant': 'mixed',
            'username': '******',
            'owner_id': 'mixed',
        }
        whitelist = {
            'limit': 'single',
            'marker': 'single',
            'sort_dir': 'single',
            'sort_keys': 'multi',
            'show_deleted': 'single',
            'show_nested': 'single',
            'show_hidden': 'single',
            'tags': 'single',
            'tags_any': 'single',
            'not_tags': 'single',
            'not_tags_any': 'single',
        }
        params = util.get_allowed_params(req.params, whitelist)
        filter_params = util.get_allowed_params(req.params, filter_whitelist)

        show_deleted = False
        p_name = rpc_api.PARAM_SHOW_DELETED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_deleted = params[p_name]

        show_nested = False
        p_name = rpc_api.PARAM_SHOW_NESTED
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_nested = params[p_name]

        key = rpc_api.PARAM_LIMIT
        if key in params:
            params[key] = self._extract_int_param(key, params[key])

        show_hidden = False
        p_name = rpc_api.PARAM_SHOW_HIDDEN
        if p_name in params:
            params[p_name] = self._extract_bool_param(p_name, params[p_name])
            show_hidden = params[p_name]

        tags = None
        if rpc_api.PARAM_TAGS in params:
            params[rpc_api.PARAM_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS])
            tags = params[rpc_api.PARAM_TAGS]

        tags_any = None
        if rpc_api.PARAM_TAGS_ANY in params:
            params[rpc_api.PARAM_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_TAGS_ANY])
            tags_any = params[rpc_api.PARAM_TAGS_ANY]

        not_tags = None
        if rpc_api.PARAM_NOT_TAGS in params:
            params[rpc_api.PARAM_NOT_TAGS] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS])
            not_tags = params[rpc_api.PARAM_NOT_TAGS]

        not_tags_any = None
        if rpc_api.PARAM_NOT_TAGS_ANY in params:
            params[rpc_api.PARAM_NOT_TAGS_ANY] = self._extract_tags_param(
                params[rpc_api.PARAM_NOT_TAGS_ANY])
            not_tags_any = params[rpc_api.PARAM_NOT_TAGS_ANY]

        # get the with_count value, if invalid, raise ValueError
        with_count = False
        if req.params.get('with_count'):
            with_count = self._extract_bool_param(
                'with_count',
                req.params.get('with_count'))

        if not filter_params:
            filter_params = None

        stacks = self.rpc_client.list_stacks(req.context,
                                             filters=filter_params,
                                             tenant_safe=tenant_safe,
                                             **params)

        count = None
        if with_count:
            try:
                # Check if engine has been updated to a version with
                # support to count_stacks before trying to use it.
                count = self.rpc_client.count_stacks(req.context,
                                                     filters=filter_params,
                                                     tenant_safe=tenant_safe,
                                                     show_deleted=show_deleted,
                                                     show_nested=show_nested,
                                                     show_hidden=show_hidden,
                                                     tags=tags,
                                                     tags_any=tags_any,
                                                     not_tags=not_tags,
                                                     not_tags_any=not_tags_any)
            except AttributeError as ex:
                LOG.warn(_LW("Old Engine Version: %s"), ex)

        return stacks_view.collection(req, stacks=stacks, count=count,
                                      tenant_safe=tenant_safe)