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

Disallow renaming the default tenant. #1099

Merged
merged 2 commits into from
Mar 29, 2017
Merged

Disallow renaming the default tenant. #1099

merged 2 commits into from
Mar 29, 2017

Conversation

govint
Copy link
Contributor

@govint govint commented Mar 28, 2017

Verified as below,
/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vm-group update --name=_DEFAULT --descr
iption="Renaming default tenant to vm-group1" --new-name=new-vm-group1
Vm-group name _DEFAULT is invalid, only rename of vm-groups other than _DEFAULT is allowed

@govint
Copy link
Contributor Author

govint commented Mar 28, 2017

Fixes #1092

Copy link
Contributor

@lipingxue lipingxue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@pshahzeb pshahzeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -347,6 +348,10 @@ def _tenant_create(name, description="", vm_list=None, privileges=None):

def _tenant_update(name, new_name=None, description=None, default_datastore=None):
""" API to update a tenant """
if name == auth_data_const.DEFAULT_TENANT:
error_info = error_code.generate_error_info(ErrorCode.TENANT_NAME_INVALID, name, VALID_TENANT_NAMES)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this code path correctly, this change stops updating description, default datastore etc for the _DEFAULT tenant where as our intention is only to stop renaming _DEFAULT tenant, please correct me otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I think this check should be moved after the if check on line 368

@@ -28,6 +28,7 @@

# regex for valid tenant name
VALID_TENANT_NAME_REGEXP = "[a-zA-Z0-9_][a-zA-Z0-9_.-]*"
VALID_TENANT_NAMES = 'rename of vm-groups other than _DEFAULT'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you please improve the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error msg comes out like this,
Vm-group name _DEFAULT is invalid, only _rename of vm-groups other than DEFAULT is allowed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest something like renaming of _DEFAULT vm-group is not allowed

Copy link
Contributor Author

@govint govint Mar 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the message the highlited parts are fixed for the error string define for TENANT_NAME_INVALID
Vm-group name _DEFAULT is invalid, _only rename of vm-groups other than DEFAULT is allowed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

@govint
Copy link
Contributor Author

govint commented Mar 29, 2017 via email

@shuklanirdesh82
Copy link
Contributor

@govint Proposed changes looks OK to me.

It would be great if you can add unit test to cover proposed change.

Copy link
Contributor

@shuklanirdesh82 shuklanirdesh82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Please add unit test to cover proposed change.

@@ -28,6 +28,7 @@

# regex for valid tenant name
VALID_TENANT_NAME_REGEXP = "[a-zA-Z0-9_][a-zA-Z0-9_.-]*"
VALID_TENANT_NAMES = 'rename of vm-groups other than _DEFAULT'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

@govint govint merged commit aac06cd into master Mar 29, 2017
@govint govint deleted the tenant-rename branch March 29, 2017 05:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants