def create(self, os, architecture, version, url, md5hash, hypervisor='xen'): """Creates a new agent build.""" ctxt = context.get_admin_context() db.agent_build_create(ctxt, {'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash})
def create(self): updates = self.obj_get_changes() if 'id' in updates: raise exception.ObjectActionError(action='create', reason='Already Created') db_agent = db.agent_build_create(self._context, updates) self._from_db_object(self._context, self, db_agent)
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] try: agent_build_ref = db.agent_build_create( context, { 'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash }) agent['agent_id'] = agent_build_ref.id except exception.AgentBuildExists as ex: raise webob.exc.HTTPConflict(explanation=ex.format_message()) return {'agent': agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] 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: agent_build_ref = db.agent_build_create(context, {'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash}) agent['agent_id'] = agent_build_ref.id except exception.AgentBuildExists as ex: raise webob.exc.HTTPConflict(explanation=ex.format_message()) return {'agent': agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() try: agent_build_ref = db.agent_build_create(context, {'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash}) agent['agent_id'] = agent_build_ref.id except Exception as ex: raise webob.exc.HTTPServerError(str(ex)) return {'agent': agent}
def create(self, context): updates = self.obj_get_changes() if 'id' in updates: raise exception.ObjectActionError(action='create', reason='Already Created') db_agent = db.agent_build_create(context, updates) self._from_db_object(context, self, db_agent)
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() try: agent_build_ref = db.agent_build_create( context, { 'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash }) agent['agent_id'] = agent_build_ref.id except Exception as ex: raise webob.exc.HTTPServerError(str(ex)) return {'agent': agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] try: agent_build_ref = db.agent_build_create(context, {'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash}) agent['agent_id'] = agent_build_ref.id except exception.AgentBuildExists as ex: raise webob.exc.HTTPConflict(explanation=ex.format_message()) return {'agent': agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ["nova.context"] authorize(context) try: agent = body["agent"] hypervisor = agent["hypervisor"] os = agent["os"] architecture = agent["architecture"] version = agent["version"] url = agent["url"] md5hash = agent["md5hash"] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() try: agent_build_ref = db.agent_build_create( context, { "hypervisor": hypervisor, "os": os, "architecture": architecture, "version": version, "url": url, "md5hash": md5hash, }, ) agent["agent_id"] = agent_build_ref.id except Exception as ex: raise webob.exc.HTTPServerError(str(ex)) return {"agent": agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] 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: agent_build_ref = db.agent_build_create( context, { 'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash }) agent['agent_id'] = agent_build_ref.id except exception.AgentBuildExists as ex: raise webob.exc.HTTPConflict(explanation=ex.format_message()) return {'agent': agent}
def create(self, os, architecture, version, url, md5hash, hypervisor='xen'): """Creates a new agent build.""" ctxt = context.get_admin_context() db.agent_build_create( ctxt, { 'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash })
def create(self, os, architecture, version, url, md5hash, hypervisor="xen"): """Creates a new agent build.""" ctxt = context.get_admin_context() agent_build = db.agent_build_create( ctxt, { "hypervisor": hypervisor, "os": os, "architecture": architecture, "version": version, "url": url, "md5hash": md5hash, }, )
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() try: utils.check_string_length(hypervisor, 'hypervisor', max_length=255) utils.check_string_length(os, 'os', max_length=255) utils.check_string_length(architecture, 'architecture', max_length=255) utils.check_string_length(version, 'version', max_length=255) utils.check_string_length(url, 'url', max_length=255) utils.check_string_length(md5hash, 'md5hash', max_length=255) except exception.InvalidInput as exc: raise webob.exc.HTTPBadRequest(explanation=exc.format_message()) try: agent_build_ref = db.agent_build_create( context, { 'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash }) agent['agent_id'] = agent_build_ref.id except Exception as ex: raise webob.exc.HTTPServerError(str(ex)) return {'agent': agent}
def create(self, req, body): """Creates a new agent build.""" context = req.environ['nova.context'] authorize(context) try: agent = body['agent'] hypervisor = agent['hypervisor'] os = agent['os'] architecture = agent['architecture'] version = agent['version'] url = agent['url'] md5hash = agent['md5hash'] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() try: utils.check_string_length(hypervisor, 'hypervisor', max_length=255) utils.check_string_length(os, 'os', max_length=255) utils.check_string_length(architecture, 'architecture', max_length=255) utils.check_string_length(version, 'version', max_length=255) utils.check_string_length(url, 'url', max_length=255) utils.check_string_length(md5hash, 'md5hash', max_length=255) except exception.InvalidInput as exc: raise webob.exc.HTTPBadRequest(explanation=exc.format_message()) try: agent_build_ref = db.agent_build_create(context, {'hypervisor': hypervisor, 'os': os, 'architecture': architecture, 'version': version, 'url': url, 'md5hash': md5hash}) agent['agent_id'] = agent_build_ref.id except Exception as ex: raise webob.exc.HTTPServerError(str(ex)) return {'agent': agent}
def create(self, context): updates = self.obj_get_changes() if "id" in updates: raise exception.ObjectActionError(action="create", reason="Already Created") db_agent = db.agent_build_create(context, updates) self._from_db_object(context, self, db_agent)