|
|
5bafe0 |
From 1ae320d801440c6d7a052013b88031e06d7836d5 Mon Sep 17 00:00:00 2001
|
|
|
5bafe0 |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
5bafe0 |
Date: Thu, 3 Aug 2017 18:48:25 -0300
|
|
|
5bafe0 |
Subject: [PATCH] ovirt-foreign-menu: Fetch host, cluster and data center
|
|
|
5bafe0 |
information
|
|
|
5bafe0 |
|
|
|
5bafe0 |
It is possible that the data center the VM is associated with has more
|
|
|
5bafe0 |
than one storage domain associated with it as well, when only one is
|
|
|
5bafe0 |
active while the others are not.
|
|
|
5bafe0 |
|
|
|
5bafe0 |
The current ovir-foreign-menu code does not take it into consideration,
|
|
|
5bafe0 |
thus the ISO dialog may show invalid results with that scenario. We fix
|
|
|
5bafe0 |
this problem by making use of new functions in libgovirt, adding support
|
|
|
5bafe0 |
or hosts, clusters and data centers.
|
|
|
5bafe0 |
|
|
|
5bafe0 |
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
|
|
|
5bafe0 |
https://bugzilla.redhat.com/show_bug.cgi?id=1428401
|
|
|
5bafe0 |
|
|
|
5bafe0 |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
5bafe0 |
---
|
|
|
5bafe0 |
src/ovirt-foreign-menu.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
5bafe0 |
1 file changed, 154 insertions(+)
|
|
|
5bafe0 |
|
|
|
5bafe0 |
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
|
|
|
5bafe0 |
index 6d0eab3..bf32773 100644
|
|
|
5bafe0 |
--- a/src/ovirt-foreign-menu.c
|
|
|
5bafe0 |
+++ b/src/ovirt-foreign-menu.c
|
|
|
5bafe0 |
@@ -34,6 +34,11 @@ typedef enum {
|
|
|
5bafe0 |
STATE_0,
|
|
|
5bafe0 |
STATE_API,
|
|
|
5bafe0 |
STATE_VM,
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+ STATE_HOST,
|
|
|
5bafe0 |
+ STATE_CLUSTER,
|
|
|
5bafe0 |
+ STATE_DATA_CENTER,
|
|
|
5bafe0 |
+#endif
|
|
|
5bafe0 |
STATE_STORAGE_DOMAIN,
|
|
|
5bafe0 |
STATE_VM_CDROM,
|
|
|
5bafe0 |
STATE_CDROM_FILE,
|
|
|
5bafe0 |
@@ -43,6 +48,11 @@ typedef enum {
|
|
|
5bafe0 |
static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask *task, OvirtForeignMenuState state);
|
|
|
5bafe0 |
static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
+#endif
|
|
|
5bafe0 |
static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu *menu, GTask *task);
|
|
|
5bafe0 |
@@ -55,6 +65,11 @@ struct _OvirtForeignMenuPrivate {
|
|
|
5bafe0 |
OvirtProxy *proxy;
|
|
|
5bafe0 |
OvirtApi *api;
|
|
|
5bafe0 |
OvirtVm *vm;
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+ OvirtHost *host;
|
|
|
5bafe0 |
+ OvirtCluster *cluster;
|
|
|
5bafe0 |
+ OvirtDataCenter *data_center;
|
|
|
5bafe0 |
+#endif
|
|
|
5bafe0 |
char *vm_guid;
|
|
|
5bafe0 |
|
|
|
5bafe0 |
OvirtCollection *files;
|
|
|
5bafe0 |
@@ -184,6 +199,11 @@ ovirt_foreign_menu_dispose(GObject *obj)
|
|
|
5bafe0 |
g_clear_object(&self->priv->proxy);
|
|
|
5bafe0 |
g_clear_object(&self->priv->api);
|
|
|
5bafe0 |
g_clear_object(&self->priv->vm);
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+ g_clear_object(&self->priv->host);
|
|
|
5bafe0 |
+ g_clear_object(&self->priv->cluster);
|
|
|
5bafe0 |
+ g_clear_object(&self->priv->data_center);
|
|
|
5bafe0 |
+#endif
|
|
|
5bafe0 |
g_clear_pointer(&self->priv->vm_guid, g_free);
|
|
|
5bafe0 |
g_clear_object(&self->priv->files);
|
|
|
5bafe0 |
g_clear_object(&self->priv->cdrom);
|
|
|
5bafe0 |
@@ -299,6 +319,27 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu,
|
|
|
5bafe0 |
ovirt_foreign_menu_fetch_vm_async(menu, task);
|
|
|
5bafe0 |
break;
|
|
|
5bafe0 |
}
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+ /* fall through */
|
|
|
5bafe0 |
+ case STATE_HOST:
|
|
|
5bafe0 |
+ if (menu->priv->host == NULL) {
|
|
|
5bafe0 |
+ ovirt_foreign_menu_fetch_host_async(menu, task);
|
|
|
5bafe0 |
+ break;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+ /* fall through */
|
|
|
5bafe0 |
+ case STATE_CLUSTER:
|
|
|
5bafe0 |
+ if (menu->priv->cluster == NULL) {
|
|
|
5bafe0 |
+ ovirt_foreign_menu_fetch_cluster_async(menu, task);
|
|
|
5bafe0 |
+ break;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+ /* fall through */
|
|
|
5bafe0 |
+ case STATE_DATA_CENTER:
|
|
|
5bafe0 |
+ if (menu->priv->data_center == NULL) {
|
|
|
5bafe0 |
+ ovirt_foreign_menu_fetch_data_center_async(menu, task);
|
|
|
5bafe0 |
+ break;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+#endif
|
|
|
5bafe0 |
+ /* fall through */
|
|
|
5bafe0 |
case STATE_STORAGE_DOMAIN:
|
|
|
5bafe0 |
if (menu->priv->files == NULL) {
|
|
|
5bafe0 |
ovirt_foreign_menu_fetch_storage_domain_async(menu, task);
|
|
|
5bafe0 |
@@ -646,6 +687,119 @@ static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu
|
|
|
5bafe0 |
}
|
|
|
5bafe0 |
|
|
|
5bafe0 |
|
|
|
5bafe0 |
+#ifdef HAVE_OVIRT_DATA_CENTER
|
|
|
5bafe0 |
+static void data_center_fetched_cb(GObject *source_object,
|
|
|
5bafe0 |
+ GAsyncResult *result,
|
|
|
5bafe0 |
+ gpointer user_data)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ GError *error = NULL;
|
|
|
5bafe0 |
+ GTask *task = G_TASK(user_data);
|
|
|
5bafe0 |
+ OvirtForeignMenu *menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
|
|
|
5bafe0 |
+ OvirtResource *resource = OVIRT_RESOURCE(source_object);
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_resource_refresh_finish(resource, result, &error);
|
|
|
5bafe0 |
+ if (error != NULL) {
|
|
|
5bafe0 |
+ g_debug("failed to fetch Data Center: %s", error->message);
|
|
|
5bafe0 |
+ g_task_return_error(task, error);
|
|
|
5bafe0 |
+ g_object_unref(task);
|
|
|
5bafe0 |
+ return;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
|
|
|
5bafe0 |
+ GTask *task)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ menu->priv->data_center = ovirt_cluster_get_data_center(menu->priv->cluster);
|
|
|
5bafe0 |
+ ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
|
|
|
5bafe0 |
+ menu->priv->proxy,
|
|
|
5bafe0 |
+ g_task_get_cancellable(task),
|
|
|
5bafe0 |
+ data_center_fetched_cb,
|
|
|
5bafe0 |
+ task);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+static void cluster_fetched_cb(GObject *source_object,
|
|
|
5bafe0 |
+ GAsyncResult *result,
|
|
|
5bafe0 |
+ gpointer user_data)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ GError *error = NULL;
|
|
|
5bafe0 |
+ GTask *task = G_TASK(user_data);
|
|
|
5bafe0 |
+ OvirtForeignMenu *menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
|
|
|
5bafe0 |
+ OvirtResource *resource = OVIRT_RESOURCE(source_object);
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_resource_refresh_finish(resource, result, &error);
|
|
|
5bafe0 |
+ if (error != NULL) {
|
|
|
5bafe0 |
+ g_debug("failed to fetch Cluster: %s", error->message);
|
|
|
5bafe0 |
+ g_task_return_error(task, error);
|
|
|
5bafe0 |
+ g_object_unref(task);
|
|
|
5bafe0 |
+ return;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
|
|
|
5bafe0 |
+ GTask *task)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
|
|
|
5bafe0 |
+ ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cluster),
|
|
|
5bafe0 |
+ menu->priv->proxy,
|
|
|
5bafe0 |
+ g_task_get_cancellable(task),
|
|
|
5bafe0 |
+ cluster_fetched_cb,
|
|
|
5bafe0 |
+ task);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+static void host_fetched_cb(GObject *source_object,
|
|
|
5bafe0 |
+ GAsyncResult *result,
|
|
|
5bafe0 |
+ gpointer user_data)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ GError *error = NULL;
|
|
|
5bafe0 |
+ GTask *task = G_TASK(user_data);
|
|
|
5bafe0 |
+ OvirtForeignMenu *menu = OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
|
|
|
5bafe0 |
+ OvirtResource *resource = OVIRT_RESOURCE(source_object);
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_resource_refresh_finish(resource, result, &error);
|
|
|
5bafe0 |
+ if (error != NULL) {
|
|
|
5bafe0 |
+ g_debug("failed to fetch Host: %s", error->message);
|
|
|
5bafe0 |
+ g_task_return_error(task, error);
|
|
|
5bafe0 |
+ g_object_unref(task);
|
|
|
5bafe0 |
+ return;
|
|
|
5bafe0 |
+ }
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+static void ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu,
|
|
|
5bafe0 |
+ GTask *task)
|
|
|
5bafe0 |
+{
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
|
|
|
5bafe0 |
+ g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+ menu->priv->host = ovirt_vm_get_host(menu->priv->vm);
|
|
|
5bafe0 |
+ ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->host),
|
|
|
5bafe0 |
+ menu->priv->proxy,
|
|
|
5bafe0 |
+ g_task_get_cancellable(task),
|
|
|
5bafe0 |
+ host_fetched_cb,
|
|
|
5bafe0 |
+ task);
|
|
|
5bafe0 |
+}
|
|
|
5bafe0 |
+#endif /* HAVE_OVIRT_DATA_CENTER */
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
+
|
|
|
5bafe0 |
static void vms_fetched_cb(GObject *source_object,
|
|
|
5bafe0 |
GAsyncResult *result,
|
|
|
5bafe0 |
gpointer user_data)
|
|
|
5bafe0 |
--
|
|
|
5bafe0 |
2.13.6
|
|
|
5bafe0 |
|