On Thu, Jul 5, 2018 at 10:56 AM Richard W.M. Jones <rjones(a)redhat.com>
wrote:
On Thu, Jul 05, 2018 at 10:46:17AM +0300, Daniel Erez wrote:
> From: root <root(a)localhost.localdomain>
>
> For direct upload, a suitable host must be in status 'Up'
> and belong to the same datacenter as the created disk.
> Added these criteria to the host search query.
> ---
> v2v/rhv-upload-plugin.py | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
> index da309e288..c72f5e181 100644
> --- a/v2v/rhv-upload-plugin.py
> +++ b/v2v/rhv-upload-plugin.py
> @@ -67,11 +67,23 @@ def find_host(connection):
> debug("cannot read /etc/vdsm/vdsm.id, using any host: %s" % e)
> return None
>
> - debug("hw_id = %r" % vdsm_id)
> + system_service = connection.system_service()
> + storage_name = params['output_storage']
> + data_centers = system_service.data_centers_service().list(
> + search='storage=%s' % storage_name,
> + case_sensitive=False,
> + )
> + if len(data_centers) == 0:
> + # The storage domain is not attached to a datacenter
> + # (shouldn't happen, would fail on disk creation).
> + return None
> +
> + datacenter = data_centers[0]
> + debug("hw_id = %r, datacenter = %s" % (vdsm_id, datacenter.name))
>
> - hosts_service = connection.system_service().hosts_service()
> + hosts_service = system_service.hosts_service()
> hosts = hosts_service.list(
> - search="hw_id=%s" % vdsm_id,
> + search="hw_id=%s and datacenter=%s and status=Up" % (vdsm_id,
datacenter.name),
I'm assuming these don't have to be quoted in some way?
we don't allow any special characters or whitespaces in datacenter's name,
so it should be fine.
> case_sensitive=False,
> )
> if len(hosts) == 0:
I've added this to my queue, it should go upstream later today.
Thanks,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW