mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-08 04:58:29 +03:00
virtinst.storage: improve detection of disk type
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
af60c860d1
commit
82eaf4742e
@ -190,7 +190,7 @@ def path_is_url(path):
|
||||
return bool(re.match("[a-zA-Z]+(\+[a-zA-Z]+)?://.*", path))
|
||||
|
||||
|
||||
def _get_dev_type(path, vol_xml, vol_object, remote):
|
||||
def _get_dev_type(path, vol_xml, vol_object, pool_xml, remote):
|
||||
"""
|
||||
Try to get device type for volume.
|
||||
"""
|
||||
@ -214,6 +214,13 @@ def _get_dev_type(path, vol_xml, vol_object, remote):
|
||||
elif t == StorageVolume.TYPE_NETWORK:
|
||||
return "network"
|
||||
|
||||
if pool_xml:
|
||||
t = pool_xml.get_disk_type()
|
||||
if t == StorageVolume.TYPE_BLOCK:
|
||||
return "block"
|
||||
elif t == StorageVolume.TYPE_NETWORK:
|
||||
return "network"
|
||||
|
||||
if path:
|
||||
if path_is_url(path):
|
||||
return "network"
|
||||
@ -321,6 +328,7 @@ class _StorageCreator(_StorageBase):
|
||||
def get_dev_type(self):
|
||||
if not self._dev_type:
|
||||
self._dev_type = _get_dev_type(self._path, self._vol_install, None,
|
||||
self.get_parent_pool_xml(),
|
||||
self._conn.is_remote())
|
||||
return self._dev_type
|
||||
|
||||
@ -588,6 +596,7 @@ class StorageBackend(_StorageBase):
|
||||
if self._vol_object:
|
||||
vol_xml = self.get_vol_xml()
|
||||
self._dev_type = _get_dev_type(self._path, vol_xml, self._vol_object,
|
||||
self.get_parent_pool_xml(),
|
||||
self._conn.is_remote())
|
||||
return self._dev_type
|
||||
|
||||
|
@ -477,6 +477,19 @@ class StoragePool(_StorageObject):
|
||||
StoragePool.TYPE_RBD, StoragePool.TYPE_SHEEPDOG,
|
||||
StoragePool.TYPE_ZFS]
|
||||
|
||||
def get_disk_type(self):
|
||||
if (self.type == StoragePool.TYPE_DISK or
|
||||
self.type == StoragePool.TYPE_LOGICAL or
|
||||
self.type == StoragePool.TYPE_SCSI or
|
||||
self.type == StoragePool.TYPE_MPATH or
|
||||
self.type == StoragePool.TYPE_ZFS):
|
||||
return StorageVolume.TYPE_BLOCK
|
||||
if (self.type == StoragePool.TYPE_GLUSTER or
|
||||
self.type == StoragePool.TYPE_RBD or
|
||||
self.type == StoragePool.TYPE_ISCSI or
|
||||
self.type == StoragePool.TYPE_SHEEPDOG):
|
||||
return StorageVolume.TYPE_NETWORK
|
||||
return StorageVolume.TYPE_FILE
|
||||
|
||||
##################
|
||||
# Build routines #
|
||||
@ -701,15 +714,7 @@ class StorageVolume(_StorageObject):
|
||||
return self.TYPE_DIR
|
||||
elif self.type == "network":
|
||||
return self.TYPE_NETWORK
|
||||
if (self._pool_xml.type == StoragePool.TYPE_DISK or
|
||||
self._pool_xml.type == StoragePool.TYPE_LOGICAL or
|
||||
self._pool_xml.type == StoragePool.TYPE_ZFS):
|
||||
return self.TYPE_BLOCK
|
||||
if (self._pool_xml.type == StoragePool.TYPE_GLUSTER or
|
||||
self._pool_xml.type == StoragePool.TYPE_RBD or
|
||||
self._pool_xml.type == StoragePool.TYPE_SHEEPDOG):
|
||||
return self.TYPE_NETWORK
|
||||
return self.TYPE_FILE
|
||||
return self._pool_xml.get_disk_type()
|
||||
file_type = property(_get_vol_type)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user