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

fixed type of convert() return for values < 1KB #985

Merged
merged 1 commit into from
Mar 2, 2017

Conversation

msterin
Copy link
Contributor

@msterin msterin commented Mar 1, 2017

Fixes #972

When the value of UsedSize was <1K (exactly 0 in the failed test) , the kvESX.py:convert() used to return int type instead of str and that broke the logic of CLI table size estimate

tested by manually changing the kvESX.py:convert on ESX with a repro, and rerunning (previously failed) command:

BEFORE the fix

[root@sc-rdops-vm16-dhcp-230-73:/tmp] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Traceback (most recent call last):
  File "/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py", line 1011, in <module>
    main()
  File "/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py", line 51, in main
    args.func(args)
  File "/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py", line 509, in ls
    print(cli_table.create(header, rows))
  File "/usr/lib/vmware/vmdkops/Python/cli_table.py", line 33, in create
    max_sizes = max_column_sizes(header, data)
  File "/usr/lib/vmware/vmdkops/Python/cli_table.py", line 157, in max_column_sizes
    if len(row[i]) > sizes[i]:
TypeError: object of type 'int' has no len()

AFTER the fix:

[root@sc-rdops-vm16-dhcp-230-73:/tmp] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py ls
Volume       Datastore     Created By VM  Created                   Attached To VM (name/uuid)            Policy  Capacity  Used  Disk Format  Filesystem Type  Access      Attach As               
-----------  ------------  -------------  ------------------------  ------------------------------------  ------  --------  ----  -----------  ---------------  ----------  ----------------------  
vol_test_1   sharedVmfs-0  photon-VM0.0   Wed Mar  1 19:05:54 2017  564dd428-c912-27ea-7db6-40047a6e72ad  N/A     200MB     0     thin         ext4             read-write  independent_persistent  
vol_test_2   sharedVmfs-0  photon-VM0.0   Wed Mar  1 19:08:17 2017  detached                              N/A     200MB     14MB  thin         ext4             read-write  independent_persistent  
vol_test_33  sharedVmfs-0  photon-VM0.1   Wed Mar  1 19:23:05 2017  detached                              N/A     200MB     14MB  thin         ext4             read-write  independent_persistent  

//CC @pshahzeb

Fixes #972

When the value (e.g. of UsedSize) was < 1KB, the convert returned int instead of str
and that broke the logic of CLI table size estimate
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

@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!

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

@msterin msterin merged commit 5056749 into master Mar 2, 2017
@msterin msterin deleted the admin_ls_failed_issue972.msterin branch March 2, 2017 01:23
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.

Admin cli command to list volume fails
5 participants