def update_project(self, tenant_id, tenant): self.project.check_allow_update() tenant = self._validate_default_domain(tenant) if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) return self._set_default_attributes( self.project.update(tenant_id, tenant))
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) session = self.get_session() with session.begin(): tenant_ref = Project.from_dict(tenant) session.add(tenant_ref) session.flush() return tenant_ref.to_dict()
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) data = tenant.copy() if 'id' not in data or data['id'] is None: data['id'] = str(uuid.uuid4().hex) if 'description' in data and data['description'] in ['', None]: data.pop('description') return self.project.create(data)
def create_project(self, tenant_id, tenant): tenant = self._validate_default_domain(tenant) tenant["name"] = clean.project_name(tenant["name"]) data = tenant.copy() if "id" not in data or data["id"] is None: data["id"] = str(uuid.uuid4().hex) if "description" in data and data["description"] in ["", None]: data.pop("description") return self._set_default_domain(self.project.create(data))
def create_project(self, tenant_id, tenant): self.project.check_allow_create() tenant = self._validate_default_domain(tenant) tenant['name'] = clean.project_name(tenant['name']) data = tenant.copy() if 'id' not in data or data['id'] is None: data['id'] = str(uuid.uuid4().hex) if 'description' in data and data['description'] in ['', None]: data.pop('description') return self._set_default_domain(self.project.create(data))
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) with sql.transaction() as session: tenant_ref = Project.from_dict(tenant) temp_name = '' if tenant['parent_project_id'] is not None: parent_tenant = self._get_project(session, tenant['parent_project_id']) temp_name = parent_tenant['name'] + '.' + tenant['name'] tenant_ref.name = temp_name session.add(tenant_ref) return tenant_ref.to_dict()
def update_project(self, tenant_id, tenant): if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) with sql.transaction() as session: tenant_ref = self._get_project(session, tenant_id) old_project_dict = tenant_ref.to_dict() for k in tenant: old_project_dict[k] = tenant[k] new_project = Project.from_dict(old_project_dict) for attr in Project.attributes: if attr != 'id': setattr(tenant_ref, attr, getattr(new_project, attr)) tenant_ref.extra = new_project.extra return tenant_ref.to_dict(include_extra_dict=True)
def update_project(self, project_id, project): if 'name' in project: project['name'] = clean.project_name(project['name']) with sql.transaction() as session: project_ref = self._get_project(session, project_id) old_project_dict = project_ref.to_dict() for k in project: old_project_dict[k] = project[k] new_project = Project.from_dict(old_project_dict) for attr in Project.attributes: if attr != 'id': setattr(project_ref, attr, getattr(new_project, attr)) project_ref.extra = new_project.extra return project_ref.to_dict()
def update_project(self, tenant_id, tenant): session = self.get_session() if "name" in tenant: tenant["name"] = clean.project_name(tenant["name"]) try: tenant_ref = session.query(Project).filter_by(id=tenant_id).one() except sql.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) with session.begin(): old_project_dict = tenant_ref.to_dict() for k in tenant: old_project_dict[k] = tenant[k] new_project = Project.from_dict(old_project_dict) tenant_ref.name = new_project.name tenant_ref.extra = new_project.extra session.flush() return tenant_ref.to_dict(include_extra_dict=True)
def update_project(self, tenant_id, tenant): session = self.get_session() if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) try: tenant_ref = session.query(Project).filter_by(id=tenant_id).one() except sql.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) # FIXME(henry-nash) Think about how we detect potential name clash # when we move domains with session.begin(): old_project_dict = tenant_ref.to_dict() for k in tenant: old_project_dict[k] = tenant[k] new_project = Project.from_dict(old_project_dict) tenant_ref.name = new_project.name tenant_ref.extra = new_project.extra session.flush() return tenant_ref.to_dict(include_extra_dict=True)
def update_project(self, tenant_id, tenant): session = self.get_session() if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) try: tenant_ref = session.query(Project).filter_by(id=tenant_id).one() except sql.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) with session.begin(): old_project_dict = tenant_ref.to_dict() for k in tenant: old_project_dict[k] = tenant[k] new_project = Project.from_dict(old_project_dict) for attr in Project.attributes: if attr != 'id': setattr(tenant_ref, attr, getattr(new_project, attr)) tenant_ref.extra = new_project.extra session.flush() return tenant_ref.to_dict(include_extra_dict=True)
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) try: self.get_project(tenant_id) except exception.ProjectNotFound: pass else: msg = 'Duplicate ID, %s.' % tenant_id raise exception.Conflict(type='tenant', details=msg) try: self.get_project_by_name(tenant['name'], tenant['domain_id']) except exception.ProjectNotFound: pass else: msg = 'Duplicate name, %s.' % tenant['name'] raise exception.Conflict(type='tenant', details=msg) self.db.set('tenant-%s' % tenant_id, tenant) self.db.set('tenant_name-%s' % tenant['name'], tenant) return tenant
def update_project(self, tenant_id, tenant): if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) try: existing = self.db.get('tenant_name-%s' % tenant['name']) if existing and tenant_id != existing['id']: msg = 'Duplicate name, %s.' % tenant['name'] raise exception.Conflict(type='tenant', details=msg) except exception.NotFound: pass # get the old name and delete it too try: old_project = self.db.get('tenant-%s' % tenant_id) except exception.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) new_project = old_project.copy() new_project.update(tenant) new_project['id'] = tenant_id self.db.delete('tenant_name-%s' % old_project['name']) self.db.set('tenant-%s' % tenant_id, new_project) self.db.set('tenant_name-%s' % new_project['name'], new_project) return new_project
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) with sql.transaction() as session: tenant_ref = Project.from_dict(tenant) session.add(tenant_ref) return tenant_ref.to_dict()
def update_project(self, tenant_id, tenant): if "name" in tenant: tenant["name"] = clean.project_name(tenant["name"]) return self.project.update(tenant_id, tenant)
def update_project(self, tenant_id, tenant): tenant = self._validate_default_domain(tenant) if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) return self._set_default_domain(self.project.update(tenant_id, tenant))
def create_project(self, tenant_id, tenant): tenant['name'] = clean.project_name(tenant['name']) data = tenant.copy() if 'id' not in data or data['id'] is None: data['id'] = str(uuid.uuid4().hex) return self.project.create(tenant)
def update_project(self, tenant_id, tenant): if 'name' in tenant: tenant['name'] = clean.project_name(tenant['name']) return self.project.update(tenant_id, tenant)
def update_project(self, tenant_id, tenant): self.project.check_allow_update() tenant = self._validate_default_domain(tenant) if "name" in tenant: tenant["name"] = clean.project_name(tenant["name"]) return self._set_default_domain(self.project.update(tenant_id, tenant))
def create_project(self, project_id, project): project['name'] = clean.project_name(project['name']) with sql.transaction() as session: project_ref = Project.from_dict(project) session.add(project_ref) return project_ref.to_dict()
def create_project(self, tenant_id, tenant): tenant["name"] = clean.project_name(tenant["name"]) data = tenant.copy() if "id" not in data or data["id"] is None: data["id"] = str(uuid.uuid4().hex) return self.project.create(tenant)