<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Jul 5, 2018 at 8:24 PM Daniel Erez <<a href="mailto:derez@redhat.com">derez@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 | 28 ++++++++++++++++++++++++----<br>
 1 file changed, 24 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py<br>
index da309e288..931fcfaa2 100644<br>
--- a/v2v/rhv-upload-plugin.py<br>
+++ b/v2v/rhv-upload-plugin.py<br>
@@ -69,14 +69,34 @@ def find_host(connection):<br>
<br>
     debug("hw_id = %r" % vdsm_id)<br>
<br>
-    hosts_service = connection.system_service().hosts_service()<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>
+        debug("storange domain (%s) is not attached to a DC" % storage_name)<br>
+        return None<br>
+<br>
+    datacenter = data_centers[0]<br>
+    debug("datacenter = %s" % <a href="http://datacenter.name" rel="noreferrer" target="_blank">datacenter.name</a>)<br>
+<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>
         case_sensitive=False,<br>
     )<br>
     if len(hosts) == 0:<br>
-        # This oVirt host is not registered with engine.<br>
-        debug("cannot find host with hw_id=%r, using any host" % vdsm_id)<br>
+        # Couldn't find a host that's fulfilling the following criteria:<br>
+        # - 'hw_id' equals to 'vdsm_id'<br>
+        # - Its status is 'Up'<br>
+        # - Belongs to the storage domain's datacenter<br>
+        debug("cannot find a running host with hw_id=%r, " \<br>
+              "that belongs to datacenter '%s', " \<br>
+              "using any host" % (vdsm_id, <a href="http://datacenter.name" rel="noreferrer" target="_blank">datacenter.name</a>))<br>
         return None<br>
<br>
     host = hosts[0]<br></blockquote><div><br></div><div>Looks good.</div><div><br></div><div>This fixes both <a href="https://bugzilla.redhat.com/1596810">https://bugzilla.redhat.com/1596810</a> and</div><div><a href="https://bugzilla.redhat.com/1596851">https://bugzilla.redhat.com/1596851</a> so we need to backport</div><div>the patch to RHEL 7.6.</div><div><br></div><div>Nir</div></div></div>