Esempio n. 1
0
    def post(self, function_id, body):
        """Create a new version for the function.

        Only allow to create version for package type function.

        The supported boy params:
            - description: Optional. The description of the new version.
        """
        ctx = context.get_ctx()
        acl.enforce('function_version:create', ctx)

        params = body.to_dict()
        values = {
            'description': params.get('description'),
        }

        # Try to create a new function version within lock and db transaction
        try:
            version = self._create_function_version(ctx.project_id,
                                                    function_id, **values)
        except exc.EtcdLockException as e:
            LOG.exception(str(e))
            # Reraise a generic exception as the end users should not know
            # the underlying details.
            raise exc.QinlingException('Internal server error.')

        return resources.FunctionVersion.from_db_obj(version)
Esempio n. 2
0
def _wrap_exception_and_reraise(exception):
    message = "%s: %s" % (exception.__class__.__name__, exception.args[0])

    raise exc.QinlingException(message)