From 31dd38df68543235b3f61a3d58e25e42b100dd9a Mon Sep 17 00:00:00 2001 From: Taras Brodovych Date: Thu, 7 Oct 2021 13:14:54 +0200 Subject: [PATCH] vcd disk list Usage: vcd disk list [OPTIONS] Try "vcd disk list -h" for help. Error: int() argument must be a string, a bytes-like object or a number, not 'NoneType' --- vcd_cli/disk.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vcd_cli/disk.py b/vcd_cli/disk.py index 96b49272..808af4a2 100644 --- a/vcd_cli/disk.py +++ b/vcd_cli/disk.py @@ -15,6 +15,7 @@ import click import humanfriendly from pyvcloud.vcd.client import VCLOUD_STATUS_MAP +from pyvcloud.vcd.client import SIZE_1MB from pyvcloud.vcd.org import Org from pyvcloud.vcd.utils import disk_to_dict from pyvcloud.vcd.utils import extract_id @@ -87,6 +88,12 @@ def list_disks(ctx): if hasattr(disk, 'attached_vms') and \ hasattr(disk.attached_vms, 'VmReference'): attached_vms = disk.attached_vms.VmReference.get('name') + + if 'size' in disk.keys(): + size_in_bytes = int(disk.get('size')) + else: + size_in_bytes = int(disk.get('sizeMb')) * SIZE_1MB + result.append({ 'name': disk.get('name'), @@ -95,9 +102,9 @@ def list_disks(ctx): 'owner': disk.Owner.User.get('name'), 'size': - humanfriendly.format_size(int(disk.get('size'))), + humanfriendly.format_size(int(size_in_bytes)), 'size_bytes': - disk.get('size'), + size_in_bytes, 'status': VCLOUD_STATUS_MAP.get(int(disk.get('status'))), 'vms_attached':