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

Tenancy bug fixes #706

Merged
merged 8 commits into from
Nov 8, 2016
Merged

Tenancy bug fixes #706

merged 8 commits into from
Nov 8, 2016

Conversation

pdhamdhere
Copy link
Contributor

@pdhamdhere pdhamdhere commented Nov 5, 2016

Fixed following issues;

Testing Done:

  • docker volume create -d vmdk --name=vol1 from tenant VM.
  • Grant access to nonVMDatastore. Do not grant access to VM Home datastore.
    • docker volume ls succeeds
    • docker volume create -d vmdk --name=vol2@nonVMDatastore succeeds
  • For sanity checking, confirmed docker run with and without mount privilege.
  • Print human readable default values;
vmdkops_admin tenant access ls --name=T2
Datastore     Create_volume  Delete_volume  Mount_volume  Max_volume_size  Total_size  
------------  -------------  -------------  ------------  ---------------  ----------  
ssdDatastore  True           True           False         2.00TB           Unset       

#668 Unit test should take into account updated behavior in this change.

@@ -565,7 +565,7 @@ def executeRequest(vm_uuid, vm_name, config_path, cmd, full_vol_name, opts):
Returns None (if all OK) or error string
"""
vm_datastore = get_datastore_name(config_path)
error_info, tenant_uuid, tenant_name = auth.authorize(vm_uuid, vm_datastore, cmd, opts)
error_info, tenant_uuid, tenant_name = auth.get_tenant(vm_uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to call auth.get_tenant here. I think later auth.authorize will call this function inernally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this PR we skip authorization checks for list and get command. However, we do need tenantName to list volumes and thus call to get_tenant

@@ -667,12 +666,12 @@ def _remove_volumes_for_tenant(self, tenant_id):
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

If we hit error when deleting one volume, I think we should continue to delete other volumes. We should return error after go through all volumes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Will fix this.

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 after fix the minor change I mentioned.

@@ -85,7 +85,7 @@ def test_tenant_create_missing_option_fails(self):
self.assert_parse_error('tenant create')

def test_tenant_rm(self):
args = self.parser.parse_args('tenant rm tenant1 --remove-volumes=True'.split())
args = self.parser.parse_args('tenant rm tenant1 --remove-volumes'.split())
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be 'tenant rm --name tenant1..." since "name" is not a positional argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, looks like I forgot to save file before commit. Will push an update.

Copy link
Contributor

@msterin msterin left a comment

Choose a reason for hiding this comment

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

a couple of format comments below. bad hour to review the content :-)

@@ -317,22 +317,20 @@ Remove a tenant, optionally all volumes for a tenant can be removed as well.

Sample:
```
/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant rm tenant1 --remove-volumes True
/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant rm --name=tenant1 --remove-volumes
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess our attempt to follow docker volume command backfired. In docker, it is volume create --name=volname but volume rm name. @kernetime was also commenting on this. So I guess it is confusing. But if we do it consistent and deviate from docker volume command, I'd prefer 'tenant create ' and 'tenant rm '

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean

vmdkops_admin tenant create T1
vmdkops_admin tenant rm T1

Or

vmdkops_admin tenant create --name=T1
vmdkops_admin tenant rm --name=T1

Most of tenant commands accept tenant name in the form of "--name=T1" for e.g. vmdkops_admin tenant access ls --name=T1 So, I changed rm to accept "--name=T1"

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

From a usability stand point

vmdkops_admin tenant create T1
vmdkops_admin tenant rm T1

is a lot nicer, since all the operations are done on a per tenant basis maybe we should change all

vmdkops_admin tenant T1 access add --rights all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kerneltime If we decide to change, let's make it in separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kerneltime - vmdkops_admin tenant T1 access add --rights all is not trivial with argparse package. @andrewjstone - can you check if the above is true :-) ?

I suggest leaving it as is

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure what is being asked about here. The way we do choice parsing is by comma seperated values with no spaces. It should be feasible to have --rights all since it's a single value. See here

@@ -857,8 +859,8 @@ def tenant_rm(args):
# If args "remove_volumes" is not specified in CLI
# args.remove_volumes will be None
if args.remove_volumes:
if args.remove_volumes == 'True':
remove_volumes = True
print "All Volumes will be removed"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not Python v3 compatible. Please use function print("msg"), not language construct print msg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Looks like all "print" in this file are incompatible with Python 3. I don't want to pollute change so only changed newly added print @ L862.

Copy link
Contributor

Choose a reason for hiding this comment

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

it's OK. I will change others in one pass for P3 move (using 2x3 tool). I just want to avoid new ones popping up

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, PR #479 did handle 3.5 compat.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it deviated from the working state (on print, and on list iterators, and probably more) so another pass is required. And. more importantly, we need a CI with 6/5, and pylint as a part of the build. And coverage.py in test runs. So for now I will re-fix on Py3 (or you can do it if you feel like it) and work with @kernetime to add pylinit to the build

@govint
Copy link
Contributor

govint commented Nov 7, 2016

I do remember fixing this file to be Python 3.x compliant. If adding new
code then can we make it compliant?

On Mon, Nov 7, 2016 at 4:43 AM, Prashant Dhamdhere <notifications@github.com

wrote:

@pdhamdhere commented on this pull request.

In esx_service/cli/vmdkops_admin.py
#706:

@@ -857,8 +859,8 @@ def tenant_rm(args):
# If args "remove_volumes" is not specified in CLI
# args.remove_volumes will be None
if args.remove_volumes:

  •    if args.remove_volumes == 'True':
    
  •        remove_volumes = True
    
  •    print "All Volumes will be removed"
    

Done. Looks like all "print" in this file are incompatible with Python 3.
I don't want to pollute change so only changed newly added print @ L862.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#706, or mute the
thread
https://github.com/notifications/unsubscribe-auth/APHseBixQjoASdJaH5NXRa0BA0lhK0ysks5q7l8ugaJpZM4KqIUN
.

error_info, tenant_uuid, tenant_name = auth.authorize(vm_uuid, datastore, cmd, opts)
if error_info:
return err(error_info)

Copy link
Contributor

Choose a reason for hiding this comment

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

won't this authorize for Get also (called below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, Removed CMD_LIST & CMD_GET from check_privileges_for_command.

Copy link
Contributor

Choose a reason for hiding this comment

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

@govint - we do not have pylint in the build and no Py3 in CI test bed, so the py3 compatibility can rot. I will add pylint and @kerneltime - can we add py3 (latest ESX GA) to the CI ?

Copy link
Contributor

@govint govint left a comment

Choose a reason for hiding this comment

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

Can admin CLI sanity tests be added for the create and ls use cases.

Copy link
Contributor

@msterin msterin left a comment

Choose a reason for hiding this comment

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

LGTM with 2 conditionals :-)

  1. CI pass
  2. Please add an issue for relevant Unit Tests - @lipingxue already has some unit tests on the list, they should also cover this PR

@pdhamdhere pdhamdhere merged commit 14dcd21 into master Nov 8, 2016
@pdhamdhere pdhamdhere deleted the tenancy-bug-fixes branch November 8, 2016 00:15
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants