<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Jul 5, 2018 at 10:46 AM 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">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></blockquote><div><br></div><div>I would leave this as is...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    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></blockquote><div><br></div><div>A debug message here would be helpful.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        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></blockquote><div><br></div><div>And log only the datacenter here, to match other logs in the plugin.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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>
         case_sensitive=False,<br>
     )<br>
     if len(hosts) == 0:<br></blockquote><div><br></div><div>We need to change the comments and debug message here. The current code is:</div><div><br></div><div><div><div> 77     if len(hosts) == 0:</div><div> 78         # This oVirt host is not registered with engine.</div><div> 79         debug("cannot find host with hw_id=%r, using any host" % vdsm_id)</div><div> 80         return None</div></div></div><div><br></div><div>We are handling 3 cases:</div><div>1. host not found</div><div>2. host no in the datacenter</div><div>3. host not up</div><div><br></div><div>The comment and the debug message should make it clear.</div><div><br></div><div>Nir</div></div></div>