virtManager: clone: build default clone path if we know how

Function do_we_default returns only if we want to default to clone disk
even if we know how to create default clone path.  Only in case that the
storage pool is TYPE_DISK we don't know how to create default path and
we cannot default to clone that disk.  In all other cases as ReadOnly
disk or Shareable and so on we can prepare the default path for user if
they decide to clone it.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1565106

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2019-03-05 10:16:06 +01:00
parent f6a6c58a36
commit a02fc0d022

View File

@ -79,6 +79,7 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
""" Returns (do we clone by default?, info string if not)""" """ Returns (do we clone by default?, info string if not)"""
ignore = conn ignore = conn
info = "" info = ""
can_default = True
def append_str(str1, str2, delim=", "): def append_str(str1, str2, delim=", "):
if not str2: if not str2:
@ -101,11 +102,12 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
pool_type = vol.get_parent_pool().get_type() pool_type = vol.get_parent_pool().get_type()
if pool_type == virtinst.StoragePool.TYPE_DISK: if pool_type == virtinst.StoragePool.TYPE_DISK:
info = append_str(info, _("Disk device")) info = append_str(info, _("Disk device"))
can_default = False
if shared: if shared:
info = append_str(info, _("Shareable")) info = append_str(info, _("Shareable"))
return (not info, info) return (not info, info, can_default)
class vmmCloneVM(vmmGObjectUI): class vmmCloneVM(vmmGObjectUI):
@ -390,8 +392,8 @@ class vmmCloneVM(vmmGObjectUI):
skip_targets.remove(force_target) skip_targets.remove(force_target)
vol = self.conn.get_vol_by_path(path) vol = self.conn.get_vol_by_path(path)
default, definfo = do_we_default(self.conn, vol, path, ro, shared, default, definfo, can_default = do_we_default(self.conn, vol, path,
devtype) ro, shared, devtype)
def storage_add(failinfo=None): def storage_add(failinfo=None):
# pylint: disable=cell-var-from-loop # pylint: disable=cell-var-from-loop
@ -426,7 +428,7 @@ class vmmCloneVM(vmmGObjectUI):
storage_row[STORAGE_INFO_CAN_CLONE] = True storage_row[STORAGE_INFO_CAN_CLONE] = True
# If we cannot create default clone_path don't even try to do that # If we cannot create default clone_path don't even try to do that
if not default: if not can_default:
storage_add() storage_add()
continue continue