From b8074b4505a0d8f0e5707587bb48177e3e7b71a2 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 2 Jul 2019 16:56:35 -0400 Subject: [PATCH] storage: Replace volume supports_property with supports_format Helps to make usage more explicit --- virtManager/createvol.py | 2 +- virtManager/device/addstorage.py | 2 +- virtinst/devices/disk.py | 2 +- virtinst/diskbackend.py | 2 +- virtinst/storage.py | 9 ++------- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/virtManager/createvol.py b/virtManager/createvol.py index 7219c77d8..2f8f0e1bc 100644 --- a/virtManager/createvol.py +++ b/virtManager/createvol.py @@ -123,7 +123,7 @@ class vmmCreateVolume(vmmGObjectUI): vol = self._make_stub_vol() - hasformat = vol.supports_property("format") + hasformat = vol.supports_format() uiutil.set_grid_row_visible(self.widget("vol-format"), hasformat) uiutil.set_list_selection(self.widget("vol-format"), self.conn.get_default_storage_format()) diff --git a/virtManager/device/addstorage.py b/virtManager/device/addstorage.py index b98fe9bdd..38cf74d01 100644 --- a/virtManager/device/addstorage.py +++ b/virtManager/device/addstorage.py @@ -184,7 +184,7 @@ class vmmAddStorage(vmmGObjectUI): disk.set_vol_install(vol_install) fmt = self.conn.get_default_storage_format() - if disk.get_vol_install().supports_property("format"): + if disk.get_vol_install().supports_format(): log.debug("Using default prefs format=%s for path=%s", fmt, disk.path) disk.get_vol_install().format = fmt diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py index 2d864899c..b7567212f 100644 --- a/virtinst/devices/disk.py +++ b/virtinst/devices/disk.py @@ -239,7 +239,7 @@ class DeviceDisk(Device): volinst.backing_format = backing_format if fmt: - if not volinst.supports_property("format"): + if not volinst.supports_format(): raise ValueError(_("Format attribute not supported for this " "volume type")) volinst.format = fmt diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py index 65ef52b0b..5c4d56071 100644 --- a/virtinst/diskbackend.py +++ b/virtinst/diskbackend.py @@ -459,7 +459,7 @@ class _StorageCreator(_StorageBase): def get_driver_type(self): if self._vol_install: - if self._vol_install.supports_property("format"): + if self._vol_install.supports_format(): return self._vol_install.format return "raw" diff --git a/virtinst/storage.py b/virtinst/storage.py index b12402f52..ccdd4ce3e 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -643,7 +643,7 @@ class StorageVolume(_StorageObject): log.debug("Found backing store volume XML:\n%s", volxml.get_xml()) - if volxml.supports_property("format"): + if volxml.supports_format(): log.debug("Returning format=%s", volxml.format) return volxml.format @@ -656,18 +656,13 @@ class StorageVolume(_StorageObject): # Public API helpers # ###################### - def _supports_format(self): + def supports_format(self): if self.file_type == self.TYPE_FILE: return True if self._pool_xml.type == StoragePool.TYPE_GLUSTER: return True return False - def supports_property(self, propname): - if propname == "format": - return self._supports_format() - return hasattr(self, propname) - ################## # Build routines #