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

Add "Tenant" column in "vmdkops_admin ls" output and fix "vmdkops_admin set" command #1014

Merged
merged 3 commits into from
Mar 12, 2017

Conversation

lipingxue
Copy link
Contributor

@lipingxue lipingxue commented Mar 8, 2017

This PR includes:

  1. Add a new column "Tenant" in vmdkops_admin ls command (fixes [Tenant] Add tenant column to admin ls commands #964)
  2. Change to vmdkops_admin set command which take one more argument "--tenant". (fixes Unable to modify access attribute for volume from admin-cli #998)
  3. admin-cli.md is changed accordingly.

@lipingxue
Copy link
Contributor Author

lipingxue commented Mar 9, 2017

Test for add column "Tenant" for vmdkops_admin ls output.

I have done the following test manually:
Configuration:
_DEFAULT tenant and a named tenant "tenant1"
create two volumes with the same name "vol1", which belongs to two different tenant "_DEFAULT" and "tenant1" accordingly

Step1:

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Tenant    Volume    Datastore   Created By VM  Created                   Attached To VM (name/uuid)  Policy  Capacity  Used  Disk Format  Filesystem Type  Access      Attach As              
--------  --------  ----------  -------------  ------------------------  --------------------------  ------  --------  ----  -----------  ---------------  ----------  ---------------------- 
_DEFAULT  vol1      datastore1  photon-6       Sat Sep 10 01:11:07 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  testvol   datastore1  photon-6       Sat Sep 10 04:21:02 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  Vol100MB  datastore1  photon-6       Sat Sep 10 08:36:29 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  persistent             
tenant1   vol1      datastore1  photon-6       Sat Sep 10 09:36:51 2016  detached                    N/A     500MB     23MB  thin         ext4             read-write  independent_persistent 

Step2: remove "tenant1" without removing volumes, "vol1" which belongs to "tenant1" still show up in the output, but column "Tenant" for that volume shows as "N/A" since "tenant1" has been removed.

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant ls
Uuid                                  Name      Description               Default_datastore  VM_list          
------------------------------------  --------  ------------------------  -----------------  ---------------- 
11111111-1111-1111-1111-111111111111  _DEFAULT  This is a default tenant                                      
d91ad806-a9e6-447f-a464-fbd5314db85f  tenant1                                                photon7,photon-6 
 
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py tenant rm --name=tenant1
tenant rm succeeded

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Tenant    Volume    Datastore   Created By VM  Created                   Attached To VM (name/uuid)  Policy  Capacity  Used  Disk Format  Filesystem Type  Access      Attach As              
--------  --------  ----------  -------------  ------------------------  --------------------------  ------  --------  ----  -----------  ---------------  ----------  ---------------------- 
_DEFAULT  vol1      datastore1  photon-6       Sat Sep 10 01:11:07 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  testvol   datastore1  photon-6       Sat Sep 10 04:21:02 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  Vol100MB  datastore1  photon-6       Sat Sep 10 08:36:29 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  persistent             
N/A       vol1      datastore1  photon-6       Sat Sep 10 09:36:51 2016  detached                    N/A     500MB     23MB  thin         ext4             read-write  independent_persistent 

@lipingxue
Copy link
Contributor Author

Test for add argument "--tenant" for vmdkops_admin set command
Step1: run vmdkops_admin ls command

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Tenant    Volume    Datastore   Created By VM  Created                   Attached To VM (name/uuid)  Policy  Capacity  Used  Disk Format  Filesystem Type  Access      Attach As              
--------  --------  ----------  -------------  ------------------------  --------------------------  ------  --------  ----  -----------  ---------------  ----------  ---------------------- 
_DEFAULT  vol1      datastore1  photon-6       Sat Sep 10 01:11:07 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  testvol   datastore1  photon-6       Sat Sep 10 04:21:02 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  Vol100MB  datastore1  photon-6       Sat Sep 10 08:36:29 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  persistent             
N/A       vol1      datastore1  photon-6       Sat Sep 10 09:36:51 2016  detached                    N/A     500MB     23MB  thin         ext4             read-write  independent_persistent 

Step2: run vmdkops_admin set with non-exist tenant "DEFAULT0"

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py set --volume=Vol100MB@datastore1 --tenant=_DEFAULT0 --options="access=read-only"
Failed to update access=read-only for Vol100MB@datastore1.

Step3: run vmdkops_admin set with exist tenant "_DEFAULT"

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py set --volume=Vol100MB@datastore1 --tenant=_DEFAULT --options="access=read-only"
Successfully updated settings for : Vol100MB@datastore1
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Tenant    Volume    Datastore   Created By VM  Created                   Attached To VM (name/uuid)  Policy  Capacity  Used  Disk Format  Filesystem Type  Access      Attach As              
--------  --------  ----------  -------------  ------------------------  --------------------------  ------  --------  ----  -----------  ---------------  ----------  ---------------------- 
_DEFAULT  vol1      datastore1  photon-6       Sat Sep 10 01:11:07 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  testvol   datastore1  photon-6       Sat Sep 10 04:21:02 2016  detached                    N/A     100MB     13MB  thin         ext4             read-write  independent_persistent 
_DEFAULT  Vol100MB  datastore1  photon-6       Sat Sep 10 08:36:29 2016  detached                    N/A     100MB     13MB  thin         ext4             read-only   persistent             
N/A       vol1      datastore1  photon-6       Sat Sep 10 09:36:51 2016  detached                    N/A     500MB     23MB  thin         ext4             read-write  independent_persistent 
 
[root@localhost:~]

@@ -527,14 +531,18 @@ def ls_dash_c(columns, tenant_reg):

def all_ls_headers():
""" Return a list of all header for ls -l """
return ['Volume', 'Datastore', 'Created By VM', 'Created',
return ['Tenant', 'Volume', 'Datastore', 'Created By VM', 'Created',
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 vote for displaying Volume Name as the first column ... can you please accommodate the change?

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.

Good fix. LGTM pending changing column order

  • I agree with @shuklanirdesh82 that volume should be first
  • I think "(name/uuid)" in the "Atatched to VM" column header is not needed, it just makes table wider
  • I suggest having the following columns order:
    Volume
    Datastore
    VM-Group
    Capacity
    Used
    Filesystem
    Attached-to
    Access
    Attach-as
    Created By
    Created Date

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.

Agree with Mark and Nirdesh's comments. Few more nits below.

@@ -415,6 +415,10 @@ def commands():
'help': 'Volume to set options for, specified as "volume@datastore".',
'required': True
},
'--tenant': {
'help': 'Name of the tenant which volume to set belongs to.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Suggest to rephrase a little bit: "Name of the tenant the volume belongs to"

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.

@@ -37,6 +37,7 @@
DEFAULT_TENANT_UUID = '11111111-1111-1111-1111-111111111111'
DEFAULT_DS = '_DEFAULT'
DEFAULT_DS_URL = DEFAULT_DS + "_URL"
ORPHAN_TENANT = "_ORPHAN"
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 define this in auth_data_const.py instead.

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.

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.

@lipingxue
Copy link
Contributor Author

After change the order/name of columns, the output looks like:

[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Volume    Datastore   VM-Group  Capacity  Used  Filesystem  Policy  Disk Format  Attached-to  Access      Attach-as               Created By  Created Date              
--------  ----------  --------  --------  ----  ----------  ------  -----------  -----------  ----------  ----------------------  ----------  ------------------------  
vol1      datastore1  _DEFAULT  100MB     13MB  ext4        N/A     thin         detached     read-write  independent_persistent  photon-6    Sun Sep 11 07:30:47 2016  
new-vol1  datastore1  N/A       100MB     13MB  ext4        N/A     thin         detached     read-write  independent_persistent  photon-6    Sun Sep 11 08:03:56 2016  

@msterin
Copy link
Contributor

msterin commented Mar 10, 2017

No more comments and looks good but - why the CI is failing ? Also , need conflict resolution.

@lipingxue lipingxue force-pushed the unable_to_modify_attach_as.liping branch from f242f22 to c12f94d Compare March 10, 2017 23:54
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.

LGTM.

@@ -419,7 +419,7 @@ def commands():
'required': True
},
'--tenant': {
'help': 'Name of the tenant which volume to set belongs to.',
'help': 'Name of the tenant the volume belongs to.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make sure to resolve the conflicts with the other change which renames tenant to vm-group.

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.

Unable to modify access attribute for volume from admin-cli [Tenant] Add tenant column to admin ls commands
5 participants