Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Fix vcd disk list command #560

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions vcd_cli/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand All @@ -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':
Expand Down