-
Notifications
You must be signed in to change notification settings - Fork 95
Conversation
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 '
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
I do remember fixing this file to be Python 3.x compliant. If adding new On Mon, Nov 7, 2016 at 4:43 AM, Prashant Dhamdhere <notifications@github.com
|
error_info, tenant_uuid, tenant_name = auth.authorize(vm_uuid, datastore, cmd, opts) | ||
if error_info: | ||
return err(error_info) | ||
|
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this 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.
There was a problem hiding this 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 :-)
- CI pass
- Please add an issue for relevant Unit Tests - @lipingxue already has some unit tests on the list, they should also cover this PR
995e482
to
2d4e401
Compare
Fixed following issues;
docker volume ls
fails withlist vmdk: VolumeDriver.List: No mount privilege
error. Fixes Tenancy: Better error message for docker commands #686tenant rm <T_Name>
changed totenant rm --name=<T_Name>
Fixes Tenancy: Tenant rm command needs updates #688 Tenant cli improvement #675Testing Done:
docker volume create -d vmdk --name=vol1
from tenant VM.docker volume ls
succeedsdocker volume create -d vmdk --name=vol2@nonVMDatastore
succeedsdocker run
with and without mount privilege.#668 Unit test should take into account updated behavior in this change.