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