Ejemplo n.º 1
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['agent']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except TypeError as e:
            raise webob.exc.HTTPBadRequest()
        except KeyError as e:
            raise webob.exc.HTTPBadRequest(explanation=_(
                "Could not find %s parameter in the request") % e.args[0])

        try:
            utils.check_string_length(url, 'url', max_length=255)
            utils.check_string_length(md5hash, 'md5hash', max_length=255)
            utils.check_string_length(version, 'version', max_length=255)
        except exception.InvalidInput as exc:
            raise webob.exc.HTTPBadRequest(explanation=exc.format_message())

        try:
            db.agent_build_update(context, id,
                                {'version': version,
                                 'url': url,
                                 'md5hash': md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        return {"agent": {'agent_id': id, 'version': version,
                'url': url, 'md5hash': md5hash}}
Ejemplo n.º 2
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['agent']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except TypeError as e:
            raise webob.exc.HTTPBadRequest()
        except KeyError as e:
            raise webob.exc.HTTPBadRequest(
                explanation=_("Could not find %s parameter in the request") %
                e.args[0])

        try:
            db.agent_build_update(context, id, {
                'version': version,
                'url': url,
                'md5hash': md5hash
            })
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        return {
            "agent": {
                'agent_id': id,
                'version': version,
                'url': url,
                'md5hash': md5hash
            }
        }
Ejemplo n.º 3
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        para = body['agent']
        url = para['url']
        md5hash = para['md5hash']
        version = para['version']

        try:
            db.agent_build_update(context, id, {
                'version': version,
                'url': url,
                'md5hash': md5hash
            })
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        return {
            "agent": {
                'agent_id': id,
                'version': version,
                'url': url,
                'md5hash': md5hash
            }
        }
Ejemplo n.º 4
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['para']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except (TypeError, KeyError):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            db.agent_build_update(context, id, {
                'version': version,
                'url': url,
                'md5hash': md5hash
            })
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=str(ex))

        return {
            "agent": {
                'agent_id': id,
                'version': version,
                'url': url,
                'md5hash': md5hash
            }
        }
Ejemplo n.º 5
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['para']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except (TypeError, KeyError):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            utils.check_string_length(url, 'url', max_length=255)
            utils.check_string_length(md5hash, 'md5hash', max_length=255)
            utils.check_string_length(version, 'version', max_length=255)
        except exception.InvalidInput as exc:
            raise webob.exc.HTTPBadRequest(explanation=exc.format_message())

        try:
            db.agent_build_update(context, id,
                                {'version': version,
                                 'url': url,
                                 'md5hash': md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        # NOTE(alex_xu): The agent_id should be integer that consistent with
        # create/index actions. But parameter 'id' is string type that parsed
        # from url. This is a bug, but because back-compatibility, it can't be
        # fixed for v2 API. This will be fixed after v3 API feature exposed by
        # micro-version in the future. lp bug #1333494
        return {"agent": {'agent_id': id, 'version': version,
                'url': url, 'md5hash': md5hash}}
Ejemplo n.º 6
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['para']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except (TypeError, KeyError):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            utils.check_string_length(url, 'url', max_length=255)
            utils.check_string_length(md5hash, 'md5hash', max_length=255)
            utils.check_string_length(version, 'version', max_length=255)
        except exception.InvalidInput as exc:
            raise webob.exc.HTTPBadRequest(explanation=exc.format_message())

        try:
            db.agent_build_update(context, id,
                                {'version': version,
                                 'url': url,
                                 'md5hash': md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        return {"agent": {'agent_id': id, 'version': version,
                'url': url, 'md5hash': md5hash}}
Ejemplo n.º 7
0
 def modify(self, os, architecture, version, url, md5hash,
            hypervisor='xen'):
     """Update an existing agent build."""
     ctxt = context.get_admin_context()
     agent_build_ref = db.agent_build_get_by_triple(ctxt,
                               hypervisor, os, architecture)
     db.agent_build_update(ctxt, agent_build_ref['id'],
                           {'version': version,
                            'url': url,
                            'md5hash': md5hash})
Ejemplo n.º 8
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ["nova.context"]
        authorize(context)

        try:
            para = body["para"]
            url = para["url"]
            md5hash = para["md5hash"]
            version = para["version"]
        except (TypeError, KeyError):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            db.agent_build_update(context, id, {"version": version, "url": url, "md5hash": md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=str(ex))

        return {"agent": {"agent_id": id, "version": version, "url": url, "md5hash": md5hash}}
Ejemplo n.º 9
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        para = body['agent']
        url = para['url']
        md5hash = para['md5hash']
        version = para['version']

        try:
            db.agent_build_update(context, id,
                                {'version': version,
                                 'url': url,
                                 'md5hash': md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=ex.format_message())

        return {"agent": {'agent_id': id, 'version': version,
                'url': url, 'md5hash': md5hash}}
Ejemplo n.º 10
0
    def update(self, req, id, body):
        """Update an existing agent build."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            para = body['para']
            url = para['url']
            md5hash = para['md5hash']
            version = para['version']
        except (TypeError, KeyError):
            raise webob.exc.HTTPUnprocessableEntity()

        try:
            db.agent_build_update(context, id,
                                {'version': version,
                                 'url': url,
                                 'md5hash': md5hash})
        except exception.AgentBuildNotFound as ex:
            raise webob.exc.HTTPNotFound(explanation=str(ex))

        return {"agent": {'agent_id': id, 'version': version,
                'url': url, 'md5hash': md5hash}}
Ejemplo n.º 11
0
 def save(self):
     updates = self.obj_get_changes()
     db.agent_build_update(self._context, self.id, updates)
     self.obj_reset_changes()
Ejemplo n.º 12
0
 def save(self, context):
     updates = self.obj_get_changes()
     db.agent_build_update(context, self.id, updates)
     self.obj_reset_changes()
Ejemplo n.º 13
0
 def modify(self, os, architecture, version, url, md5hash, hypervisor="xen"):
     """Update an existing agent build."""
     ctxt = context.get_admin_context()
     agent_build_ref = db.agent_build_get_by_triple(ctxt, hypervisor, os, architecture)
     db.agent_build_update(ctxt, agent_build_ref["id"], {"version": version, "url": url, "md5hash": md5hash})