Example #1
0
    def show(self, req, id):
        """Return a single group type item."""
        context = req.environ['cinder.context']

        # get default group type
        if id is not None and id == 'default':
            grp_type = group_types.get_default_group_type()
            if not grp_type:
                msg = _("Default group type can not be found.")
                raise exc.HTTPNotFound(explanation=msg)
            req.cache_resource(grp_type, name='group_types')
        else:
            try:
                grp_type = group_types.get_group_type(context, id)
                req.cache_resource(grp_type, name='group_types')
            except exception.GroupTypeNotFound as error:
                raise exc.HTTPNotFound(explanation=error.msg)

        return self._view_builder.show(req, grp_type)
Example #2
0
    def show(self, req, id):
        """Return a single group type item."""
        context = req.environ['cinder.context']

        # get default group type
        if id is not None and id == 'default':
            grp_type = group_types.get_default_group_type()
            if not grp_type:
                msg = _("Default group type can not be found.")
                raise exc.HTTPNotFound(explanation=msg)
            req.cache_resource(grp_type, name='group_types')
        else:
            try:
                grp_type = group_types.get_group_type(context, id)
                req.cache_resource(grp_type, name='group_types')
            except exception.GroupTypeNotFound as error:
                raise exc.HTTPNotFound(explanation=error.msg)

        return self._view_builder.show(req, grp_type)