diff options
author | Cole Robinson <crobinso@redhat.com> | 2020-11-10 16:10:35 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2020-11-11 19:06:32 -0500 |
commit | 4cfb3aeff1bcdae049a23e5a8643af827880519c (patch) | |
tree | 37a1206e73ae73b63d8128adeaeadd3feaf7fa08 | |
parent | 6a6c1c13d74cc31e9d581b74bd7101c141a94a02 (diff) | |
download | virt-manager-4cfb3aeff1bcdae049a23e5a8643af827880519c.tar.gz |
cloner: more detailed error messages about supported network vols
Signed-off-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r-- | tests/data/cli/virtclone/clone-net-http.xml | 24 | ||||
-rw-r--r-- | tests/data/cli/virtclone/clone-net-rbd.xml (renamed from tests/data/cli/virtclone/clone-net.xml) | 15 | ||||
-rw-r--r-- | tests/test_cli.py | 7 | ||||
-rw-r--r-- | virtinst/cloner.py | 16 |
4 files changed, 50 insertions, 12 deletions
diff --git a/tests/data/cli/virtclone/clone-net-http.xml b/tests/data/cli/virtclone/clone-net-http.xml new file mode 100644 index 00000000..6cb75656 --- /dev/null +++ b/tests/data/cli/virtclone/clone-net-http.xml @@ -0,0 +1,24 @@ +<domain type='test' id='1'> + <name>origtest</name> + <uuid>db69fa1f-eef0-e567-3c20-3ef16f10376b</uuid> + <memory>8388608</memory> + <currentMemory>2097152</currentMemory> + <vcpu>2</vcpu> + <os> + <type arch='i686'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='http' name='/my-file.img'> + <host name='example.org'/> + </source> + <target dev='vdaa' bus='virtio'/> + </disk> + </devices> +</domain> diff --git a/tests/data/cli/virtclone/clone-net.xml b/tests/data/cli/virtclone/clone-net-rbd.xml index cd1f085e..048f59b3 100644 --- a/tests/data/cli/virtclone/clone-net.xml +++ b/tests/data/cli/virtclone/clone-net-rbd.xml @@ -13,15 +13,14 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <disk type='network' device='disk'> - <driver name='qemu' type='raw' cache='none' io='native'/> - <auth username='libvirt'> - <secret type='ceph' uuid='11111111-2222-3333-4444-55556666777'/> + <disk type="network" device="disk"> + <auth username="admin"> + <secret type="ceph" uuid="f65cc5a8-b77b-4254-9030-d50a528fb456"/> </auth> - <source protocol='rbd' name='vms/foo1'> - <host name='host1' port='6789'/> - <host name='host2' port='6789'/> - <host name='host3' port='6789'/> + <source protocol="rbd" name="rbd-sourcename/some-rbd-vol"> + <host name="ceph-mon-1.example.com" port="6789"/> + <host name="ceph-mon-2.example.com" port="6789"/> + <host name="ceph-mon-3.example.com" port="6789"/> </source> <target dev='vda' bus='virtio'/> </disk> diff --git a/tests/test_cli.py b/tests/test_cli.py index 51c7c7b4..5e69a135 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1336,7 +1336,8 @@ _CLONE_NVRAM = "--original-xml %s/clone-nvram-auto.xml" % _CLONEXMLDIR _CLONE_NVRAM_NEWPOOL = "--original-xml %s/clone-nvram-newpool.xml" % _CLONEXMLDIR _CLONE_NVRAM_MISSING = "--original-xml %s/clone-nvram-missing.xml" % _CLONEXMLDIR _CLONE_EMPTY = "--original-xml %s/clone-empty.xml" % _CLONEXMLDIR -_CLONE_NET = "--original-xml %s/clone-net.xml" % _CLONEXMLDIR +_CLONE_NET_RBD = "--original-xml %s/clone-net-rbd.xml" % _CLONEXMLDIR +_CLONE_NET_HTTP = "--original-xml %s/clone-net-http.xml" % _CLONEXMLDIR vclon = App("virt-clone") @@ -1373,7 +1374,9 @@ c.add_invalid("-o test --auto-clone", grep="shutoff") # VM is running c.add_invalid("--connect %(URI-TEST-FULL)s -o test-clone-simple -n newvm --file %(EXISTIMG1)s") # Should complain about overwriting existing file c.add_invalid("--connect %(URI-TEST-REMOTE)s -o test-clone-simple --auto-clone --file /dev/default-pool/testvol9.img --check all=off", grep="Clone onto existing storage volume") # hit a specific error message c.add_invalid("--connect %(URI-TEST-FULL)s -o test-clone-full --auto-clone", grep="not enough free space") # catch failure of clone path setting -c.add_invalid(_CLONE_NET + " --auto-clone", grep="'network' is not cloneable") +c.add_invalid(_CLONE_NET_HTTP + " --auto-clone", grep="'http' is not cloneable") +c.add_invalid(_CLONE_NET_RBD + " --auto-clone", grep="'rbd' requires managed storage") # connection doesn't have the referenced rbd volume +c.add_invalid(_CLONE_NET_RBD + " --connect %(URI-TEST-FULL)s --auto-clone", grep="Cloning rbd volumes is not yet supported") c = vclon.add_category("general", "-n clonetest") diff --git a/virtinst/cloner.py b/virtinst/cloner.py index 3cbd63ed..622a2921 100644 --- a/virtinst/cloner.py +++ b/virtinst/cloner.py @@ -174,8 +174,20 @@ def _get_cloneable_msg(disk): """ if disk.wants_storage_creation(): return _("Disk path '%s' does not exist.") % disk.get_source_path() - if (disk.type == "network" and not disk.get_vol_object()): - return _("Disk type '%s' is not cloneable.") % disk.type + + if disk.type == "network": + proto = disk.source.protocol + if proto not in ["rbd"]: + return _("Disk network type '%s' is not cloneable.") % proto + disk.set_backend_for_existing_path() + if not disk.get_vol_object(): + return _("Cloning disk network type '%s' requires " + "managed storage.") % proto + else: + # This case, rbd with managed storage, is implementable. It + # requires open coding a bunch of work in cloner, or reworking + # other disk code to add unique URIs for rbd volumes and pools + return _("Cloning rbd volumes is not yet supported.") def _get_shareable_msg(disk): |