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

Commit

Permalink
Fix - disk list size
Browse files Browse the repository at this point in the history
  • Loading branch information
azzamsa committed May 20, 2020
1 parent 0d88338 commit acee8d5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions vcd_cli/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@
#

import click

import humanfriendly
from pyvcloud.vcd.client import VCLOUD_STATUS_MAP
from pyvcloud.vcd.org import Org
from pyvcloud.vcd.utils import disk_to_dict
from pyvcloud.vcd.utils import extract_id
from pyvcloud.vcd.utils import disk_to_dict, extract_id
from pyvcloud.vcd.vdc import VDC

from vcd_cli.utils import extract_name_and_id
from vcd_cli.utils import restore_session
from vcd_cli.utils import stderr
from vcd_cli.utils import stdout
from vcd_cli.vcd import abort_if_false
from vcd_cli.vcd import vcd
from vcd_cli.utils import extract_name_and_id, restore_session, stderr, stdout
from vcd_cli.vcd import abort_if_false, vcd


@vcd.group(short_help='manage independent disks')
Expand Down Expand Up @@ -87,6 +82,10 @@ 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')) * (1024 * 1024)
result.append({
'name':
disk.get('name'),
Expand All @@ -95,9 +94,8 @@ def list_disks(ctx):
'owner':
disk.Owner.User.get('name'),
'size':
humanfriendly.format_size(int(disk.get('size'))),
'size_bytes':
disk.get('size'),
humanfriendly.format_size(size_in_bytes),
'size_bytes': size_in_bytes,
'status':
VCLOUD_STATUS_MAP.get(int(disk.get('status'))),
'vms_attached':
Expand Down

0 comments on commit acee8d5

Please sign in to comment.