Пример #1
0
 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))
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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))
Пример #7
0
 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))
Пример #8
0
 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()
Пример #10
0
 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()
Пример #11
0
    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)
Пример #12
0
    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()
Пример #13
0
    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)
Пример #14
0
    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)
Пример #15
0
    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)
Пример #16
0
    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)
Пример #17
0
    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)
Пример #18
0
    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
Пример #19
0
    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
Пример #20
0
 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
Пример #21
0
 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
Пример #22
0
 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()
Пример #23
0
 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)
Пример #24
0
 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))
Пример #25
0
 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)
Пример #26
0
 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))
Пример #27
0
 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)
Пример #28
0
 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)
Пример #29
0
 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))
Пример #30
0
 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()
Пример #31
0
 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()
Пример #32
0
 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)