Merge "Fix the Domain context for Projects panel"
This commit is contained in:
commit
d45413e9bf
@ -213,6 +213,28 @@ def tenant_create(request, name, description=None, enabled=None, domain=None):
|
|||||||
enabled=enabled)
|
enabled=enabled)
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_domain(request):
|
||||||
|
"""
|
||||||
|
Gets the default domain object to use when creating Identity object.
|
||||||
|
Returns the domain context if is set, otherwise return the domain
|
||||||
|
of the logon user.
|
||||||
|
"""
|
||||||
|
domain_id = request.session.get("domain_context", None)
|
||||||
|
domain_name = request.session.get("domain_context_name", None)
|
||||||
|
# if running in Keystone V3 or later
|
||||||
|
if VERSIONS.active >= 3 and not domain_id:
|
||||||
|
# if no domain context set, default to users' domain
|
||||||
|
domain_id = request.user.user_domain_id
|
||||||
|
try:
|
||||||
|
domain = domain_get(request, domain_id)
|
||||||
|
domain_name = domain.name
|
||||||
|
except Exception:
|
||||||
|
LOG.warning("Unable to retrieve Domain: %s" % domain_id)
|
||||||
|
domain = base.APIDictWrapper({"id": domain_id,
|
||||||
|
"name": domain_name})
|
||||||
|
return domain
|
||||||
|
|
||||||
|
|
||||||
# TODO(gabriel): Is there ever a valid case for admin to be false here?
|
# TODO(gabriel): Is there ever a valid case for admin to be false here?
|
||||||
# A quick search through the codebase reveals that it's always called with
|
# A quick search through the codebase reveals that it's always called with
|
||||||
# admin=true so I suspect we could eliminate it entirely as with the other
|
# admin=true so I suspect we could eliminate it entirely as with the other
|
||||||
|
@ -70,15 +70,18 @@ class TenantsViewTests(test.BaseAdminViewTests):
|
|||||||
|
|
||||||
class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||||
def _get_project_info(self, project):
|
def _get_project_info(self, project):
|
||||||
domain_id = self.request.session.get('domain_context', None)
|
domain = self._get_default_domain()
|
||||||
project_info = {"name": project.name,
|
project_info = {"name": project.name,
|
||||||
"description": project.description,
|
"description": project.description,
|
||||||
"enabled": project.enabled,
|
"enabled": project.enabled,
|
||||||
"domain": domain_id}
|
"domain": domain.id}
|
||||||
return project_info
|
return project_info
|
||||||
|
|
||||||
def _get_workflow_fields(self, project):
|
def _get_workflow_fields(self, project):
|
||||||
project_info = {"name": project.name,
|
domain = self._get_default_domain()
|
||||||
|
project_info = {"domain_id": domain.id,
|
||||||
|
"domain_name": domain.name,
|
||||||
|
"name": project.name,
|
||||||
"description": project.description,
|
"description": project.description,
|
||||||
"enabled": project.enabled}
|
"enabled": project.enabled}
|
||||||
return project_info
|
return project_info
|
||||||
@ -101,8 +104,13 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project_info.update(quota_data)
|
project_info.update(quota_data)
|
||||||
return project_info
|
return project_info
|
||||||
|
|
||||||
def _get_domain_id(self):
|
def _get_default_domain(self):
|
||||||
return self.request.session.get('domain_context', None)
|
default_domain = self.domain
|
||||||
|
domain = {"id": self.request.session.get('domain_context',
|
||||||
|
default_domain.id),
|
||||||
|
"name": self.request.session.get('domain_context_name',
|
||||||
|
default_domain.name)}
|
||||||
|
return api.base.APIDictWrapper(domain)
|
||||||
|
|
||||||
def _get_all_users(self, domain_id):
|
def _get_all_users(self, domain_id):
|
||||||
if not domain_id:
|
if not domain_id:
|
||||||
@ -120,7 +128,8 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
if group.domain_id == domain_id]
|
if group.domain_id == domain_id]
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('get_default_role',
|
@test.create_stubs({api.keystone: ('get_default_domain',
|
||||||
|
'get_default_role',
|
||||||
'user_list',
|
'user_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
'role_list'),
|
'role_list'),
|
||||||
@ -128,14 +137,17 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
def test_add_project_get(self):
|
def test_add_project_get(self):
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||||
|
|
||||||
# init
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
.MultipleTimes().AndReturn(default_role)
|
.MultipleTimes().AndReturn(default_role)
|
||||||
api.keystone.user_list(IsA(http.HttpRequest), domain=domain_id) \
|
api.keystone.user_list(IsA(http.HttpRequest), domain=domain_id) \
|
||||||
@ -233,7 +245,8 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
@ -320,16 +333,20 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
@test.create_stubs({api.keystone: ('user_list',
|
@test.create_stubs({api.keystone: ('user_list',
|
||||||
'role_list',
|
'role_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
|
'get_default_domain',
|
||||||
'get_default_role'),
|
'get_default_role'),
|
||||||
quotas: ('get_default_quota_data',)})
|
quotas: ('get_default_quota_data',)})
|
||||||
def test_add_project_quota_defaults_error(self):
|
def test_add_project_quota_defaults_error(self):
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
# init
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)) \
|
quotas.get_default_quota_data(IsA(http.HttpRequest)) \
|
||||||
.AndRaise(self.exceptions.nova)
|
.AndRaise(self.exceptions.nova)
|
||||||
|
|
||||||
@ -360,18 +377,22 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
'user_list',
|
'user_list',
|
||||||
'role_list',
|
'role_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
|
'get_default_domain',
|
||||||
'get_default_role'),
|
'get_default_role'),
|
||||||
quotas: ('get_default_quota_data',)})
|
quotas: ('get_default_quota_data',)})
|
||||||
def test_add_project_tenant_create_error(self):
|
def test_add_project_tenant_create_error(self):
|
||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
# init
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||||
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
@ -409,6 +430,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
'user_list',
|
'user_list',
|
||||||
'role_list',
|
'role_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
|
'get_default_domain',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'add_tenant_user_role'),
|
'add_tenant_user_role'),
|
||||||
quotas: ('get_default_quota_data',),
|
quotas: ('get_default_quota_data',),
|
||||||
@ -417,12 +439,15 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
# init
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||||
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
@ -486,6 +511,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
'user_list',
|
'user_list',
|
||||||
'role_list',
|
'role_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
|
'get_default_domain',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'add_tenant_user_role'),
|
'add_tenant_user_role'),
|
||||||
quotas: ('get_default_quota_data',),
|
quotas: ('get_default_quota_data',),
|
||||||
@ -495,12 +521,15 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
# init
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||||
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
@ -563,18 +592,22 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
@test.create_stubs({api.keystone: ('user_list',
|
@test.create_stubs({api.keystone: ('user_list',
|
||||||
'role_list',
|
'role_list',
|
||||||
'group_list',
|
'group_list',
|
||||||
|
'get_default_domain',
|
||||||
'get_default_role'),
|
'get_default_role'),
|
||||||
quotas: ('get_default_quota_data',)})
|
quotas: ('get_default_quota_data',)})
|
||||||
def test_add_project_missing_field_error(self):
|
def test_add_project_missing_field_error(self):
|
||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
default_domain = self._get_default_domain()
|
||||||
|
domain_id = default_domain.id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
|
|
||||||
# init
|
# init
|
||||||
|
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||||
|
.AndReturn(default_domain)
|
||||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||||
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
@ -616,9 +649,6 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
quota_data[field] = int(neutron_quota.get(field).limit)
|
quota_data[field] = int(neutron_quota.get(field).limit)
|
||||||
return quota_data
|
return quota_data
|
||||||
|
|
||||||
def _get_domain_id(self):
|
|
||||||
return self.request.session.get('domain_context', None)
|
|
||||||
|
|
||||||
def _get_all_users(self, domain_id):
|
def _get_all_users(self, domain_id):
|
||||||
if not domain_id:
|
if not domain_id:
|
||||||
users = self.users.list()
|
users = self.users.list()
|
||||||
@ -646,6 +676,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
@test.create_stubs({api.keystone: ('get_default_role',
|
@test.create_stubs({api.keystone: ('get_default_role',
|
||||||
'roles_for_user',
|
'roles_for_user',
|
||||||
'tenant_get',
|
'tenant_get',
|
||||||
|
'domain_get',
|
||||||
'user_list',
|
'user_list',
|
||||||
'roles_for_group',
|
'roles_for_group',
|
||||||
'group_list',
|
'group_list',
|
||||||
@ -655,7 +686,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
domain_id = project.domain_id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
@ -663,6 +694,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest),
|
api.keystone.tenant_get(IsA(http.HttpRequest),
|
||||||
self.tenant.id, admin=True) \
|
self.tenant.id, admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
@ -712,13 +745,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
'<UpdateProjectGroups: update_group_members>',
|
'<UpdateProjectGroups: update_group_members>',
|
||||||
'<UpdateProjectQuota: update_quotas>'])
|
'<UpdateProjectQuota: update_quotas>'])
|
||||||
|
|
||||||
def test_update_project_get_domain(self):
|
|
||||||
domain = self.domains.get(id="1")
|
|
||||||
self.setSessionValues(domain_context=domain.id,
|
|
||||||
domain_context_name=domain.name)
|
|
||||||
self.test_update_project_get()
|
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('tenant_get',
|
@test.create_stubs({api.keystone: ('tenant_get',
|
||||||
|
'domain_get',
|
||||||
'tenant_update',
|
'tenant_update',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'roles_for_user',
|
'roles_for_user',
|
||||||
@ -737,7 +765,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
domain_id = project.domain_id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
proj_users = self._get_proj_users(project.id)
|
proj_users = self._get_proj_users(project.id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
@ -748,6 +776,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest),
|
api.keystone.tenant_get(IsA(http.HttpRequest),
|
||||||
self.tenant.id, admin=True) \
|
self.tenant.id, admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
@ -779,6 +809,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['2'] # member role
|
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['2'] # member role
|
||||||
|
|
||||||
# update some fields
|
# update some fields
|
||||||
|
project._info["domain_id"] = domain_id
|
||||||
project._info["name"] = "updated name"
|
project._info["name"] = "updated name"
|
||||||
project._info["description"] = "updated description"
|
project._info["description"] = "updated description"
|
||||||
quota.metadata_items = 444
|
quota.metadata_items = 444
|
||||||
@ -895,7 +926,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# submit form data
|
# submit form data
|
||||||
project_data = {"name": project._info["name"],
|
project_data = {"domain_id": project._info["domain_id"],
|
||||||
|
"name": project._info["name"],
|
||||||
"id": project.id,
|
"id": project.id,
|
||||||
"description": project._info["description"],
|
"description": project._info["description"],
|
||||||
"enabled": project.enabled}
|
"enabled": project.enabled}
|
||||||
@ -909,12 +941,6 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.assertMessageCount(error=0, warning=1)
|
self.assertMessageCount(error=0, warning=1)
|
||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
def test_update_project_save_domain(self):
|
|
||||||
domain = self.domains.get(id="1")
|
|
||||||
self.setSessionValues(domain_context=domain.id,
|
|
||||||
domain_context_name=domain.name)
|
|
||||||
self.test_update_project_save()
|
|
||||||
|
|
||||||
@test.create_stubs({api.neutron: ('is_extension_supported',
|
@test.create_stubs({api.neutron: ('is_extension_supported',
|
||||||
'tenant_quota_get',
|
'tenant_quota_get',
|
||||||
'tenant_quota_update')})
|
'tenant_quota_update')})
|
||||||
@ -950,6 +976,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('tenant_get',
|
@test.create_stubs({api.keystone: ('tenant_get',
|
||||||
|
'domain_get',
|
||||||
'tenant_update',
|
'tenant_update',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'roles_for_user',
|
'roles_for_user',
|
||||||
@ -967,7 +994,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
domain_id = project.domain_id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
roles = self.roles.list()
|
roles = self.roles.list()
|
||||||
@ -976,6 +1003,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
||||||
admin=True) \
|
admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
@ -1010,6 +1039,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
.append(group.id)
|
.append(group.id)
|
||||||
|
|
||||||
# update some fields
|
# update some fields
|
||||||
|
project._info["domain_id"] = domain_id
|
||||||
project._info["name"] = "updated name"
|
project._info["name"] = "updated name"
|
||||||
project._info["description"] = "updated description"
|
project._info["description"] = "updated description"
|
||||||
quota.metadata_items = 444
|
quota.metadata_items = 444
|
||||||
@ -1029,7 +1059,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# submit form data
|
# submit form data
|
||||||
project_data = {"name": project._info["name"],
|
project_data = {"domain_id": project._info["domain_id"],
|
||||||
|
"name": project._info["name"],
|
||||||
"id": project.id,
|
"id": project.id,
|
||||||
"description": project._info["description"],
|
"description": project._info["description"],
|
||||||
"enabled": project.enabled}
|
"enabled": project.enabled}
|
||||||
@ -1042,13 +1073,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
def test_update_project_tenant_update_error_domain(self):
|
|
||||||
domain = self.domains.get(id="1")
|
|
||||||
self.setSessionValues(domain_context=domain.id,
|
|
||||||
domain_context_name=domain.name)
|
|
||||||
self.test_update_project_tenant_update_error()
|
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('tenant_get',
|
@test.create_stubs({api.keystone: ('tenant_get',
|
||||||
|
'domain_get',
|
||||||
'tenant_update',
|
'tenant_update',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'roles_for_user',
|
'roles_for_user',
|
||||||
@ -1066,7 +1092,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
domain_id = project.domain_id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
proj_users = self._get_proj_users(project.id)
|
proj_users = self._get_proj_users(project.id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
@ -1077,6 +1103,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
||||||
admin=True) \
|
admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
@ -1110,6 +1138,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['1', '2', '3'] # member role
|
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['1', '2', '3'] # member role
|
||||||
|
|
||||||
# update some fields
|
# update some fields
|
||||||
|
project._info["domain_id"] = domain_id
|
||||||
project._info["name"] = "updated name"
|
project._info["name"] = "updated name"
|
||||||
project._info["description"] = "updated description"
|
project._info["description"] = "updated description"
|
||||||
quota[0].limit = 444
|
quota[0].limit = 444
|
||||||
@ -1188,10 +1217,11 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# submit form data
|
# submit form data
|
||||||
project_data = {"name": project._info["name"],
|
project_data = {"domain_id": project._info["domain_id"],
|
||||||
"id": project.id,
|
"name": project._info["name"],
|
||||||
"description": project._info["description"],
|
"id": project.id,
|
||||||
"enabled": project.enabled}
|
"description": project._info["description"],
|
||||||
|
"enabled": project.enabled}
|
||||||
workflow_data.update(project_data)
|
workflow_data.update(project_data)
|
||||||
workflow_data.update(updated_quota)
|
workflow_data.update(updated_quota)
|
||||||
url = reverse('horizon:admin:projects:update',
|
url = reverse('horizon:admin:projects:update',
|
||||||
@ -1202,13 +1232,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.assertMessageCount(error=1, warning=0)
|
self.assertMessageCount(error=1, warning=0)
|
||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
def test_update_project_quota_update_error_domain(self):
|
|
||||||
domain = self.domains.get(id="1")
|
|
||||||
self.setSessionValues(domain_context=domain.id,
|
|
||||||
domain_context_name=domain.name)
|
|
||||||
self.test_update_project_quota_update_error()
|
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('tenant_get',
|
@test.create_stubs({api.keystone: ('tenant_get',
|
||||||
|
'domain_get',
|
||||||
'tenant_update',
|
'tenant_update',
|
||||||
'get_default_role',
|
'get_default_role',
|
||||||
'roles_for_user',
|
'roles_for_user',
|
||||||
@ -1225,7 +1250,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
default_role = self.roles.first()
|
default_role = self.roles.first()
|
||||||
domain_id = self._get_domain_id()
|
domain_id = project.domain_id
|
||||||
users = self._get_all_users(domain_id)
|
users = self._get_all_users(domain_id)
|
||||||
proj_users = self._get_proj_users(project.id)
|
proj_users = self._get_proj_users(project.id)
|
||||||
groups = self._get_all_groups(domain_id)
|
groups = self._get_all_groups(domain_id)
|
||||||
@ -1235,6 +1260,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
||||||
admin=True) \
|
admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
@ -1265,6 +1292,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
workflow_data[GROUP_ROLE_PREFIX + "1"] = ['1', '3'] # admin role
|
workflow_data[GROUP_ROLE_PREFIX + "1"] = ['1', '3'] # admin role
|
||||||
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['1', '2', '3'] # member role
|
workflow_data[GROUP_ROLE_PREFIX + "2"] = ['1', '2', '3'] # member role
|
||||||
# update some fields
|
# update some fields
|
||||||
|
project._info["domain_id"] = domain_id
|
||||||
project._info["name"] = "updated name"
|
project._info["name"] = "updated name"
|
||||||
project._info["description"] = "updated description"
|
project._info["description"] = "updated description"
|
||||||
quota.metadata_items = 444
|
quota.metadata_items = 444
|
||||||
@ -1305,7 +1333,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# submit form data
|
# submit form data
|
||||||
project_data = {"name": project._info["name"],
|
project_data = {"domain_id": project._info["domain_id"],
|
||||||
|
"name": project._info["name"],
|
||||||
"id": project.id,
|
"id": project.id,
|
||||||
"description": project._info["description"],
|
"description": project._info["description"],
|
||||||
"enabled": project.enabled}
|
"enabled": project.enabled}
|
||||||
@ -1319,16 +1348,13 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
self.assertMessageCount(error=1, warning=0)
|
self.assertMessageCount(error=1, warning=0)
|
||||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
|
||||||
def test_update_project_member_update_error_domain(self):
|
@test.create_stubs({api.keystone: ('get_default_role',
|
||||||
domain = self.domains.get(id="1")
|
'tenant_get',
|
||||||
self.setSessionValues(domain_context=domain.id,
|
'domain_get'),
|
||||||
domain_context_name=domain.name)
|
|
||||||
self.test_update_project_member_update_error()
|
|
||||||
|
|
||||||
@test.create_stubs({api.keystone: ('get_default_role', 'tenant_get'),
|
|
||||||
quotas: ('get_tenant_quota_data',)})
|
quotas: ('get_tenant_quota_data',)})
|
||||||
def test_update_project_when_default_role_does_not_exist(self):
|
def test_update_project_when_default_role_does_not_exist(self):
|
||||||
project = self.tenants.first()
|
project = self.tenants.first()
|
||||||
|
domain_id = project.domain_id
|
||||||
quota = self.quotas.first()
|
quota = self.quotas.first()
|
||||||
|
|
||||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||||
@ -1336,6 +1362,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
|||||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
|
||||||
admin=True) \
|
admin=True) \
|
||||||
.AndReturn(project)
|
.AndReturn(project)
|
||||||
|
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||||
|
.AndReturn(self.domain)
|
||||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||||
tenant_id=self.tenant.id) \
|
tenant_id=self.tenant.id) \
|
||||||
.AndReturn(quota)
|
.AndReturn(quota)
|
||||||
|
@ -28,6 +28,7 @@ from horizon import tables
|
|||||||
from horizon import workflows
|
from horizon import workflows
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from openstack_dashboard.api import keystone
|
||||||
from openstack_dashboard import usage
|
from openstack_dashboard import usage
|
||||||
from openstack_dashboard.usage import quotas
|
from openstack_dashboard.usage import quotas
|
||||||
|
|
||||||
@ -38,7 +39,9 @@ from openstack_dashboard.dashboards.admin.projects \
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
PROJECT_INFO_FIELDS = ("name",
|
PROJECT_INFO_FIELDS = ("domain_id",
|
||||||
|
"domain_name",
|
||||||
|
"name",
|
||||||
"description",
|
"description",
|
||||||
"enabled")
|
"enabled")
|
||||||
|
|
||||||
@ -106,6 +109,11 @@ class CreateProjectView(workflows.WorkflowView):
|
|||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(CreateProjectView, self).get_initial()
|
initial = super(CreateProjectView, self).get_initial()
|
||||||
|
|
||||||
|
# Set the domain of the project
|
||||||
|
domain = api.keystone.get_default_domain(self.request)
|
||||||
|
initial["domain_id"] = domain.id
|
||||||
|
initial["domain_name"] = domain.name
|
||||||
|
|
||||||
# get initial quota defaults
|
# get initial quota defaults
|
||||||
try:
|
try:
|
||||||
quota_defaults = quotas.get_default_quota_data(self.request)
|
quota_defaults = quotas.get_default_quota_data(self.request)
|
||||||
@ -151,6 +159,17 @@ class UpdateProjectView(workflows.WorkflowView):
|
|||||||
for field in PROJECT_INFO_FIELDS:
|
for field in PROJECT_INFO_FIELDS:
|
||||||
initial[field] = getattr(project_info, field, None)
|
initial[field] = getattr(project_info, field, None)
|
||||||
|
|
||||||
|
# Retrieve the domain name where the project belong
|
||||||
|
if keystone.VERSIONS.active >= 3:
|
||||||
|
try:
|
||||||
|
domain = api.keystone.domain_get(self.request,
|
||||||
|
initial["domain_id"])
|
||||||
|
initial["domain_name"] = domain.name
|
||||||
|
except Exception:
|
||||||
|
exceptions.handle(self.request,
|
||||||
|
_('Unable to retrieve project domain.'),
|
||||||
|
redirect=reverse(INDEX_URL))
|
||||||
|
|
||||||
# get initial project quota
|
# get initial project quota
|
||||||
quota_data = quotas.get_tenant_quota_data(self.request,
|
quota_data = quotas.get_tenant_quota_data(self.request,
|
||||||
tenant_id=project_id)
|
tenant_id=project_id)
|
||||||
|
@ -94,6 +94,13 @@ class UpdateProjectQuota(workflows.Step):
|
|||||||
|
|
||||||
|
|
||||||
class CreateProjectInfoAction(workflows.Action):
|
class CreateProjectInfoAction(workflows.Action):
|
||||||
|
# Hide the domain_id and domain_name by default
|
||||||
|
domain_id = forms.CharField(label=_("Domain ID"),
|
||||||
|
required=False,
|
||||||
|
widget=forms.HiddenInput())
|
||||||
|
domain_name = forms.CharField(label=_("Domain Name"),
|
||||||
|
required=False,
|
||||||
|
widget=forms.HiddenInput())
|
||||||
name = forms.CharField(label=_("Name"))
|
name = forms.CharField(label=_("Name"))
|
||||||
description = forms.CharField(widget=forms.widgets.Textarea(),
|
description = forms.CharField(widget=forms.widgets.Textarea(),
|
||||||
label=_("Description"),
|
label=_("Description"),
|
||||||
@ -102,6 +109,16 @@ class CreateProjectInfoAction(workflows.Action):
|
|||||||
required=False,
|
required=False,
|
||||||
initial=True)
|
initial=True)
|
||||||
|
|
||||||
|
def __init__(self, request, *args, **kwargs):
|
||||||
|
super(CreateProjectInfoAction, self).__init__(request,
|
||||||
|
*args,
|
||||||
|
**kwargs)
|
||||||
|
# For keystone V3, display the two fields in read-only
|
||||||
|
if keystone.VERSIONS.active >= 3:
|
||||||
|
readonlyInput = forms.TextInput(attrs={'readonly': 'readonly'})
|
||||||
|
self.fields["domain_id"].widget = readonlyInput
|
||||||
|
self.fields["domain_name"].widget = readonlyInput
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = _("Project Info")
|
name = _("Project Info")
|
||||||
help_text = _("From here you can create a new "
|
help_text = _("From here you can create a new "
|
||||||
@ -110,7 +127,9 @@ class CreateProjectInfoAction(workflows.Action):
|
|||||||
|
|
||||||
class CreateProjectInfo(workflows.Step):
|
class CreateProjectInfo(workflows.Step):
|
||||||
action_class = CreateProjectInfoAction
|
action_class = CreateProjectInfoAction
|
||||||
contributes = ("project_id",
|
contributes = ("domain_id",
|
||||||
|
"domain_name",
|
||||||
|
"project_id",
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
"enabled")
|
"enabled")
|
||||||
@ -122,9 +141,11 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
|
|||||||
*args,
|
*args,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
err_msg = _('Unable to retrieve user list. Please try again later.')
|
err_msg = _('Unable to retrieve user list. Please try again later.')
|
||||||
|
# Use the domain_id from the project
|
||||||
|
domain_id = self.initial.get("domain_id", None)
|
||||||
project_id = ''
|
project_id = ''
|
||||||
if 'project_id' in args[0]:
|
if 'project_id' in self.initial:
|
||||||
project_id = args[0]['project_id']
|
project_id = self.initial['project_id']
|
||||||
|
|
||||||
# Get the default role
|
# Get the default role
|
||||||
try:
|
try:
|
||||||
@ -146,10 +167,9 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
|
|||||||
|
|
||||||
# Get list of available users
|
# Get list of available users
|
||||||
all_users = []
|
all_users = []
|
||||||
domain_context = request.session.get('domain_context', None)
|
|
||||||
try:
|
try:
|
||||||
all_users = api.keystone.user_list(request,
|
all_users = api.keystone.user_list(request,
|
||||||
domain=domain_context)
|
domain=domain_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, err_msg)
|
exceptions.handle(request, err_msg)
|
||||||
users_list = [(user.id, user.name) for user in all_users]
|
users_list = [(user.id, user.name) for user in all_users]
|
||||||
@ -218,9 +238,11 @@ class UpdateProjectGroupsAction(workflows.MembershipAction):
|
|||||||
*args,
|
*args,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
err_msg = _('Unable to retrieve group list. Please try again later.')
|
err_msg = _('Unable to retrieve group list. Please try again later.')
|
||||||
|
# Use the domain_id from the project
|
||||||
|
domain_id = self.initial.get("domain_id", None)
|
||||||
project_id = ''
|
project_id = ''
|
||||||
if 'project_id' in args[0]:
|
if 'project_id' in self.initial:
|
||||||
project_id = args[0]['project_id']
|
project_id = self.initial['project_id']
|
||||||
|
|
||||||
# Get the default role
|
# Get the default role
|
||||||
try:
|
try:
|
||||||
@ -242,10 +264,9 @@ class UpdateProjectGroupsAction(workflows.MembershipAction):
|
|||||||
|
|
||||||
# Get list of available groups
|
# Get list of available groups
|
||||||
all_groups = []
|
all_groups = []
|
||||||
domain_context = request.session.get('domain_context', None)
|
|
||||||
try:
|
try:
|
||||||
all_groups = api.keystone.group_list(request,
|
all_groups = api.keystone.group_list(request,
|
||||||
domain=domain_context)
|
domain=domain_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, err_msg)
|
exceptions.handle(request, err_msg)
|
||||||
groups_list = [(group.id, group.name) for group in all_groups]
|
groups_list = [(group.id, group.name) for group in all_groups]
|
||||||
@ -337,14 +358,14 @@ class CreateProject(workflows.Workflow):
|
|||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
# create the project
|
# create the project
|
||||||
domain_context = self.request.session.get('domain_context', None)
|
domain_id = data['domain_id']
|
||||||
try:
|
try:
|
||||||
desc = data['description']
|
desc = data['description']
|
||||||
self.object = api.keystone.tenant_create(request,
|
self.object = api.keystone.tenant_create(request,
|
||||||
name=data['name'],
|
name=data['name'],
|
||||||
description=desc,
|
description=desc,
|
||||||
enabled=data['enabled'],
|
enabled=data['enabled'],
|
||||||
domain=domain_context)
|
domain=domain_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, ignore=True)
|
exceptions.handle(request, ignore=True)
|
||||||
return False
|
return False
|
||||||
@ -450,7 +471,9 @@ class UpdateProjectInfoAction(CreateProjectInfoAction):
|
|||||||
class UpdateProjectInfo(workflows.Step):
|
class UpdateProjectInfo(workflows.Step):
|
||||||
action_class = UpdateProjectInfoAction
|
action_class = UpdateProjectInfoAction
|
||||||
depends_on = ("project_id",)
|
depends_on = ("project_id",)
|
||||||
contributes = ("name",
|
contributes = ("domain_id",
|
||||||
|
"domain_name",
|
||||||
|
"name",
|
||||||
"description",
|
"description",
|
||||||
"enabled")
|
"enabled")
|
||||||
|
|
||||||
@ -488,15 +511,18 @@ class UpdateProject(workflows.Workflow):
|
|||||||
# sets and do this all in a single "roles to add" and "roles to remove"
|
# sets and do this all in a single "roles to add" and "roles to remove"
|
||||||
# pass instead of the multi-pass thing happening now.
|
# pass instead of the multi-pass thing happening now.
|
||||||
|
|
||||||
domain_context = request.session.get('domain_context', None)
|
|
||||||
project_id = data['project_id']
|
project_id = data['project_id']
|
||||||
|
domain_id = ''
|
||||||
# update project info
|
# update project info
|
||||||
try:
|
try:
|
||||||
api.keystone.tenant_update(request,
|
project = api.keystone.tenant_update(
|
||||||
project_id,
|
request,
|
||||||
name=data['name'],
|
project_id,
|
||||||
description=data['description'],
|
name=data['name'],
|
||||||
enabled=data['enabled'])
|
description=data['description'],
|
||||||
|
enabled=data['enabled'])
|
||||||
|
# Use the domain_id from the project if available
|
||||||
|
domain_id = getattr(project, "domain_id", None)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, ignore=True)
|
exceptions.handle(request, ignore=True)
|
||||||
return False
|
return False
|
||||||
@ -605,7 +631,7 @@ class UpdateProject(workflows.Workflow):
|
|||||||
# Get the groups currently associated with this project so we
|
# Get the groups currently associated with this project so we
|
||||||
# can diff against it.
|
# can diff against it.
|
||||||
project_groups = api.keystone.group_list(request,
|
project_groups = api.keystone.group_list(request,
|
||||||
domain=domain_context,
|
domain=domain_id,
|
||||||
project=project_id)
|
project=project_id)
|
||||||
groups_to_modify = len(project_groups)
|
groups_to_modify = len(project_groups)
|
||||||
for group in project_groups:
|
for group in project_groups:
|
||||||
|
@ -220,17 +220,20 @@ def data(TEST):
|
|||||||
'name': 'test_tenant',
|
'name': 'test_tenant',
|
||||||
'description': "a test tenant.",
|
'description': "a test tenant.",
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'domain_id': '1'}
|
'domain_id': '1',
|
||||||
|
'domain_name': 'test_domain'}
|
||||||
tenant_dict_2 = {'id': "2",
|
tenant_dict_2 = {'id': "2",
|
||||||
'name': 'disabled_tenant',
|
'name': 'disabled_tenant',
|
||||||
'description': "a disabled test tenant.",
|
'description': "a disabled test tenant.",
|
||||||
'enabled': False,
|
'enabled': False,
|
||||||
'domain_id': '2'}
|
'domain_id': '2',
|
||||||
|
'domain_name': 'disabled_domain'}
|
||||||
tenant_dict_3 = {'id': "3",
|
tenant_dict_3 = {'id': "3",
|
||||||
'name': u'\u4e91\u89c4\u5219',
|
'name': u'\u4e91\u89c4\u5219',
|
||||||
'description': "an unicode-named tenant.",
|
'description': "an unicode-named tenant.",
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'domain_id': '2'}
|
'domain_id': '2',
|
||||||
|
'domain_name': 'disabled_domain'}
|
||||||
tenant = tenants.Tenant(tenants.TenantManager, tenant_dict)
|
tenant = tenants.Tenant(tenants.TenantManager, tenant_dict)
|
||||||
disabled_tenant = tenants.Tenant(tenants.TenantManager, tenant_dict_2)
|
disabled_tenant = tenants.Tenant(tenants.TenantManager, tenant_dict_2)
|
||||||
tenant_unicode = tenants.Tenant(tenants.TenantManager, tenant_dict_3)
|
tenant_unicode = tenants.Tenant(tenants.TenantManager, tenant_dict_3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user