Blame SOURCES/0007-ovirt-foreign-menu-Fix-endpoint-for-storage-domains-.patch

3e75f9
From 1486be8472a30a2a7766465a03b8f9b3631a52f5 Mon Sep 17 00:00:00 2001
3e75f9
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3e75f9
Date: Fri, 9 Aug 2019 16:26:13 -0300
3e75f9
Subject: [PATCH virt-viewer] ovirt-foreign-menu: Fix endpoint for storage
3e75f9
 domains query
3e75f9
3e75f9
Instead of fetching toplevel REST API query, we use the one relative
3e75f9
from the data center, which returns more detailed information,
3e75f9
especially the status of the storage domain.
3e75f9
3e75f9
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1427467
3e75f9
3e75f9
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
3e75f9
Acked-by: Victor Toso <victortoso@redhat.com>
3e75f9
---
3e75f9
 src/ovirt-foreign-menu.c | 26 ++++++++++++++++++++------
3e75f9
 1 file changed, 20 insertions(+), 6 deletions(-)
3e75f9
3e75f9
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
3e75f9
index b482401..cbb0e88 100644
3e75f9
--- a/src/ovirt-foreign-menu.c
3e75f9
+++ b/src/ovirt-foreign-menu.c
3e75f9
@@ -680,6 +680,7 @@ static void storage_domains_fetched_cb(GObject *source_object,
3e75f9
     OvirtCollection *collection = OVIRT_COLLECTION(source_object);
3e75f9
     GHashTableIter iter;
3e75f9
     OvirtStorageDomain *domain;
3e75f9
+    gboolean domain_valid = FALSE;
3e75f9
 
3e75f9
     ovirt_collection_fetch_finish(collection, result, &error);
3e75f9
     if (error != NULL) {
3e75f9
@@ -693,7 +694,8 @@ static void storage_domains_fetched_cb(GObject *source_object,
3e75f9
     while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&domain)) {
3e75f9
         OvirtCollection *file_collection;
3e75f9
 
3e75f9
-        if (!storage_domain_validate(menu, domain))
3e75f9
+        domain_valid = storage_domain_validate(menu, domain);
3e75f9
+        if (!domain_valid)
3e75f9
             continue;
3e75f9
 
3e75f9
         file_collection = ovirt_storage_domain_get_files(domain);
3e75f9
@@ -710,9 +712,11 @@ static void storage_domains_fetched_cb(GObject *source_object,
3e75f9
     if (menu->priv->files != NULL) {
3e75f9
         ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
3e75f9
     } else {
3e75f9
-        g_debug("Could not find iso file collection");
3e75f9
-        g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED,
3e75f9
-                                "Could not find ISO file collection");
3e75f9
+        const char *msg = domain_valid ? "Could not find ISO file collection"
3e75f9
+                                       : "Could not find valid ISO storage domain";
3e75f9
+
3e75f9
+        g_debug(msg);
3e75f9
+        g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, msg);
3e75f9
         g_object_unref(task);
3e75f9
     }
3e75f9
 }
3e75f9
@@ -721,9 +725,19 @@ static void storage_domains_fetched_cb(GObject *source_object,
3e75f9
 static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu,
3e75f9
                                                           GTask *task)
3e75f9
 {
3e75f9
-    OvirtCollection *collection = ovirt_api_get_storage_domains(menu->priv->api);
3e75f9
+    OvirtCollection *collection = NULL;
3e75f9
+
3e75f9
+#ifdef HAVE_OVIRT_DATA_CENTER
3e75f9
+    g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
3e75f9
+    g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
3e75f9
+    g_return_if_fail(OVIRT_IS_DATA_CENTER(menu->priv->data_center));
3e75f9
+
3e75f9
+    collection = ovirt_data_center_get_storage_domains(menu->priv->data_center);
3e75f9
+#else
3e75f9
+    collection = ovirt_api_get_storage_domains(menu->priv->api);
3e75f9
+#endif
3e75f9
 
3e75f9
-    g_debug("Start fetching oVirt REST collection");
3e75f9
+    g_debug("Start fetching iso file collection");
3e75f9
     ovirt_collection_fetch_async(collection, menu->priv->proxy,
3e75f9
                                  g_task_get_cancellable(task),
3e75f9
                                  storage_domains_fetched_cb, task);
3e75f9
-- 
3e75f9
2.21.0
3e75f9