def env_rename(session, uuid, old_name, new_name): try: return bool(session.query(models.Env) .filter_by(uuid=uuid, name=old_name) .update({"name": new_name})) except db_exc.DBDuplicateEntry: raise exceptions.DBRecordExists( field="name", value=new_name, table="envs")
def deployment_create(self, values): deployment = models.Deployment() try: deployment.update(values) deployment.save() except db_exc.DBDuplicateEntry: raise exceptions.DBRecordExists(field="name", value=values["name"], table="deployments") return deployment
def env_create(name, status, description, extras, config, spec, platforms): try: env_uuid = models.UUID() for p in platforms: p["env_uuid"] = env_uuid env = models.Env(name=name, uuid=env_uuid, status=status, description=description, extras=extras, config=config, spec=spec) get_session().bulk_save_objects( [env] + [models.Platform(**p) for p in platforms]) except db_exc.DBDuplicateEntry: raise exceptions.DBRecordExists(field="name", value=name, table="envs") return env_get(env_uuid)