Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Tenancy: tenant name need to be unique #711

Closed
lipingxue opened this issue Nov 7, 2016 · 7 comments
Closed

Tenancy: tenant name need to be unique #711

lipingxue opened this issue Nov 7, 2016 · 7 comments
Assignees
Milestone

Comments

@lipingxue
Copy link
Contributor

Tenant name in "tenant table" need to be unique.

@lipingxue lipingxue self-assigned this Nov 7, 2016
@pdhamdhere
Copy link
Contributor

If we make tenant name unique then we won't need tenant-uuid right?

@lipingxue
Copy link
Contributor Author

Yes. the "tenant_uuid" will not need if we make the "tenant_name" unique. Is there any use cases that require "tenant_name" not unique? I cannot think of any. @msterin

@lipingxue
Copy link
Contributor Author

Currently, the quick fix I made is to mark both "tenant_uuid" and "name" as primary key in "tenants" table. I also add some code in "create_tenant" function to check whether a tenant with the given name already exists or not. If the tenant already exists, return with error.

The complete fix should be remove "tenant_uuid" from "tenants" table and also change corresponding SQL statements.

@lipingxue
Copy link
Contributor Author

Manually unit test:

  1. create a tenant "tenant1"
[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant ls
Uuid                                  Name     Description  Default_datastore  VM_list    
------------------------------------  -------  -----------  -----------------  ---------  
b00870a1-e652-4b9e-93f3-7434476a43b2  tenant1               default_ds         photon-v1  
  1. try to create another tenant with the same name "tenant1", which should fail
[root@localhost:~]  /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant create --name tenant1 --vm-list photon-v1
WARNING:root:Tenant tenant1 already exists
Tenant tenant1 already exists

@msterin
Copy link
Contributor

msterin commented Nov 7, 2016

As long as tenant rename is supported, we can stick with the name as a unique key

@lipingxue
Copy link
Contributor Author

lipingxue commented Nov 7, 2016

In auth_data.py, we do have API "set_name" to change the name of a tenant. In AdminCLI, we do not have code to rename a tenant.
I think we should still keep "tenant_uuid" as the key in "tenants" table, but we should mark the colum "name" as UNIQUE.

@lipingxue
Copy link
Contributor Author

#715 is filed to track the AdminCLI work to rename a tenant.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants