[Libguestfs] [v2v PATCH 2/2] rhv-upload: Check that rhv-disk-uuid is not already taken (RHBZ#1789279)
Richard W.M. Jones
rjones at redhat.com
Fri Jan 24 09:34:40 UTC 2020
On Thu, Jan 23, 2020 at 11:12:23PM +0100, Martin Kletzander wrote:
> This makes the code fail with a sensible error message instead of cryptic error
> from ovirtsdk.
>
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
> v2v/rhv-upload-plugin.py | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
> index d3e6260e97f4..edb2699214c2 100644
> --- a/v2v/rhv-upload-plugin.py
> +++ b/v2v/rhv-upload-plugin.py
> @@ -26,6 +26,9 @@ import ssl
> import sys
> import time
>
> +import nbdkit
> +import errno
> +
> from http.client import HTTPSConnection, HTTPConnection
> from urllib.parse import urlparse
>
> @@ -461,6 +464,15 @@ def create_disk(connection):
> system_service = connection.system_service()
> disks_service = system_service.disks_service()
>
> + uuid = params.get('rhv_disk_uuid')
> + if uuid is not None:
> + try:
> + disks_service.disk_service(uuid).get()
> + nbdkit.set_error(errno.EINVAL)
> + raise ValueError("Disk with the specified UUID already exists")
> + except sdk.NotFoundError:
> + pass
> +
> if params['disk_format'] == "raw":
> disk_format = types.DiskFormat.RAW
> else:
ACK
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
More information about the Libguestfs
mailing list