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

Admincli improvement #993

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Admincli improvement #993

merged 2 commits into from
Mar 9, 2017

Conversation

pshahzeb
Copy link
Contributor

@pshahzeb pshahzeb commented Mar 4, 2017

  1. Info message for default tenant vm ls command

  2. Moving default tenant and privilege constants to auth_data_const.py
    Related changes for using these constants

  3. Making use of --name option for policy rm

Testing:
Updated testcases

Resolving: #965

[root@sc-rdops-vm17-dhcp-30-74:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant vm ls --name _DEFAULT
_DEFAULT tenant contains all VMs which were not added to other tenants

Fixes #922

[root@sc-rdops-vm17-dhcp-30-74:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py policy ls
Policy Name  Policy Content                                             Active
-----------  ---------------------------------------------------------  ------
test-policy  (("proportionalCapacity" i0)("hostFailuresToTolerate" i0)  Unused

[root@sc-rdops-vm17-dhcp-30-74:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py policy rm --name test-policy
Successfully removed policy: test-policy
[root@sc-rdops-vm17-dhcp-30-74:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py policy ls
Policy Name  Policy Content  Active
-----------  --------------  ------

1. Printing info message for default tenant command instead of showing an empty list
2. Removing usage of --name option for tenant rm command

Testing:
Updated testcases
Copy link
Contributor

@shaominchen shaominchen left a comment

Choose a reason for hiding this comment

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

Looks good. Just one comment below.


# Handling _DEFAULT tenant case separately to print info message
# instead of printing empty list
if (args.name == "_DEFAULT"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a constant instead of hard-coded string? I'd suggest to move all the constants below from auth.py to auth_data_const.py so that they can be shared by other modules:

DEFAULT_TENANT = '_DEFAULT'
DEFAULT_TENANT_UUID = '11111111-1111-1111-1111-111111111111'
DEFAULT_DS = '_DEFAULT'
DEFAULT_DS_URL = DEFAULT_DS + "_URL"

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this

# Handling _DEFAULT tenant case separately to print info message
# instead of printing empty list
if (args.name == "_DEFAULT"):
print("All VMs that do not belong to any tenant belong to _DEFAULT tenant")
Copy link
Contributor

Choose a reason for hiding this comment

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

the message is confusing IMO. Should be something "'__DEFAULT' tenant contains all VMs which were not added to other tenants"


# Handling _DEFAULT tenant case separately to print info message
# instead of printing empty list
if (args.name == "_DEFAULT"):
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this

@@ -236,9 +236,8 @@ def commands():
'func': tenant_rm,
'help': 'Delete a tenant',
'args': {
'--name': {
'name': {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it changed for 'tenant rm' ? I see 'tenant create' and 'tenant update' are stil using --name and 'tenant rm' now uses positional 'name'. This is inconsistent.

Please drop this change, and instead use #922 to enumerate all changes to --name or name whihc are needed to make all consistent. See #922 for more comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's discuss this in #922.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the decision is we only use positional name for "rm" type of command? @shaominchen

Copy link
Contributor

Choose a reason for hiding this comment

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

@lipingxue We all agree that local consistency is more important. For AdminCLI commands, the only inconsistent command is "policy rm". So we should just fix that command to use "--name" instead of fixing all other commands to use positional name.

1. Info message for default tenant vm ls command.

2. Moving default tenant and privilege constants to auth_data_const.py
   Related changes for using these constants

3. Making use of --name option for policy rm and reverting the tenant rm
   to also make use of --name option.

Testing:
Updated test cases
@pshahzeb pshahzeb merged commit 92088a3 into master Mar 9, 2017
@pshahzeb pshahzeb deleted the issue_965_922.pshahzeb branch March 9, 2017 19:44
@@ -159,8 +159,9 @@ def commands():
'func': policy_rm,
'help': 'Remove a storage policy',
'args': {
'name': {
'help': 'Policy name'
'--name': {
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I am late. Can you make sure admin_cli information is in sync with the proposed changes?

e.g. https://github.com/vmware/docker-volume-vsphere/blob/master/docs/user-guide/admin-cli.md#remove-3

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

6 participants