From 57fa64e542ff684d5dae9e4259aa11c6cec02ef2 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 5 Sep 2015 17:59:47 -0400 Subject: [PATCH] details: Use devicedisk path lookup for source_pool --- tests/testdriver.xml | 4 ++-- virtManager/delete.py | 13 +------------ virtManager/details.py | 24 ++++-------------------- virtinst/devicedisk.py | 15 --------------- 4 files changed, 7 insertions(+), 49 deletions(-) diff --git a/tests/testdriver.xml b/tests/testdriver.xml index 36d4d21a3..8f3c55cd1 100644 --- a/tests/testdriver.xml +++ b/tests/testdriver.xml @@ -432,8 +432,8 @@ Foo bar baz & yeah boii < > yeahfoo - - + + diff --git a/virtManager/delete.py b/virtManager/delete.py index a8ccf1dea..4c01db96e 100644 --- a/virtManager/delete.py +++ b/virtManager/delete.py @@ -234,18 +234,7 @@ def populate_storage_list(storage_list, vm, conn): model = storage_list.get_model() model.clear() - def get_path(disk): - if disk.source_pool: - pool = conn.get_pool(disk.source_pool) - if pool is None: - return disk.path - vol = pool.get_volume(disk.path) - if vol is None: - return disk.path - return vol.get_target_path() - return disk.path - - diskdata = [(d.target, get_path(d), d.read_only, d.shareable) for + diskdata = [(d.target, d.path, d.read_only, d.shareable) for d in vm.get_disk_devices()] diskdata.append(("kernel", vm.get_xmlobj().os.kernel, True, False)) diff --git a/virtManager/details.py b/virtManager/details.py index 5d3639320..9c834265b 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -2639,7 +2639,6 @@ class vmmDetails(vmmGObjectUI): return path = disk.path - source_pool = disk.source_pool devtype = disk.device ro = disk.read_only share = disk.shareable @@ -2661,27 +2660,12 @@ class vmmDetails(vmmGObjectUI): virtinst.VirtualDisk.path_definitely_exists( disk.conn, disk.path)) - size = _("Unknown") - if not path: - size = "-" - else: - vol = None - if source_pool: - pool = self.conn.get_pool(source_pool) - if pool is not None: - vol = pool.get_volume(path) - else: - vol = self.conn.get_vol_by_path(path) - + size = "-" + if path: + size = _("Unknown") + vol = self.conn.get_vol_by_path(path) if vol: size = vol.get_pretty_capacity() - elif not self.conn.is_remote(): - ignore, val = virtinst.VirtualDisk.stat_local_path(path) - if val != 0: - if val > (1024 * 1024 * 1024): - size = "%2.2f GiB" % (val / (1024.0 * 1024.0 * 1024.0)) - else: - size = "%2.2f MiB" % (val / (1024.0 * 1024.0)) is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM) is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY) diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index 9c2d9321c..72269e43c 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -385,21 +385,6 @@ class VirtualDisk(VirtualDevice): return ret - @staticmethod - def stat_local_path(path): - """ - Return tuple (storage type, storage size) for the passed path on - the local machine. This is a best effort attempt. - - @return: tuple of - (True if regular file, False otherwise, default is True, - max size of storage, default is 0) - """ - try: - return util.stat_disk(path) - except: - return (True, 0) - @staticmethod def build_vol_install(conn, volname, poolobj, size, sparse, fmt=None, backing_store=None):