|
|
4dfa2a |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
2bd53e |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
2bd53e |
Date: Thu, 13 Jul 2017 17:44:13 -0300
|
|
|
2bd53e |
Subject: [PATCH] host: Introduce ovirt_host_get_cluster()
|
|
|
2bd53e |
|
|
|
2bd53e |
Following the same principle as previous commits, this functions can be
|
|
|
2bd53e |
used to retrieve the cluster that includes this host.
|
|
|
2bd53e |
|
|
|
2bd53e |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
2bd53e |
---
|
|
|
2bd53e |
govirt/govirt.sym | 1 +
|
|
|
2bd53e |
govirt/ovirt-host.c | 35 ++++++++++++++++++++++++++++++++++-
|
|
|
2bd53e |
govirt/ovirt-host.h | 1 +
|
|
|
2bd53e |
3 files changed, 36 insertions(+), 1 deletion(-)
|
|
|
2bd53e |
|
|
|
2bd53e |
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
|
|
|
4dfa2a |
index bbfbd79..243ce0b 100644
|
|
|
2bd53e |
--- a/govirt/govirt.sym
|
|
|
2bd53e |
+++ b/govirt/govirt.sym
|
|
|
2bd53e |
@@ -130,6 +130,7 @@ GOVIRT_0.3.2 {
|
|
|
2bd53e |
ovirt_data_center_get_type;
|
|
|
2bd53e |
ovirt_data_center_new;
|
|
|
2bd53e |
|
|
|
2bd53e |
+ ovirt_host_get_cluster;
|
|
|
2bd53e |
ovirt_host_get_type;
|
|
|
2bd53e |
ovirt_host_get_vms;
|
|
|
2bd53e |
ovirt_host_new;
|
|
|
2bd53e |
diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
|
|
|
2bd53e |
index 2df2a64..191b360 100644
|
|
|
2bd53e |
--- a/govirt/ovirt-host.c
|
|
|
2bd53e |
+++ b/govirt/ovirt-host.c
|
|
|
2bd53e |
@@ -42,6 +42,19 @@ enum {
|
|
|
2bd53e |
PROP_CLUSTER_ID,
|
|
|
2bd53e |
};
|
|
|
2bd53e |
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+static const char *get_cluster_href(OvirtHost *host)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ if (host->priv->cluster_href == NULL &&
|
|
|
2bd53e |
+ host->priv->cluster_id != NULL) {
|
|
|
2bd53e |
+ host->priv->cluster_href = g_strdup_printf("%s/%s",
|
|
|
2bd53e |
+ "/ovirt-engine/api/clusters",
|
|
|
2bd53e |
+ host->priv->cluster_id);
|
|
|
2bd53e |
+ }
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ return host->priv->cluster_href;
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
static void ovirt_host_get_property(GObject *object,
|
|
|
2bd53e |
guint prop_id,
|
|
|
2bd53e |
GValue *value,
|
|
|
2bd53e |
@@ -51,7 +64,7 @@ static void ovirt_host_get_property(GObject *object,
|
|
|
2bd53e |
|
|
|
2bd53e |
switch (prop_id) {
|
|
|
2bd53e |
case PROP_CLUSTER_HREF:
|
|
|
2bd53e |
- g_value_set_string(value, host->priv->cluster_href);
|
|
|
2bd53e |
+ g_value_set_string(value, get_cluster_href(host));
|
|
|
2bd53e |
break;
|
|
|
2bd53e |
case PROP_CLUSTER_ID:
|
|
|
2bd53e |
g_value_set_string(value, host->priv->cluster_id);
|
|
|
2bd53e |
@@ -212,3 +225,23 @@ OvirtCollection *ovirt_host_get_vms(OvirtHost *host)
|
|
|
2bd53e |
|
|
|
2bd53e |
return host->priv->vms;
|
|
|
2bd53e |
}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+/**
|
|
|
2bd53e |
+ * ovirt_host_get_cluster:
|
|
|
2bd53e |
+ * @host: a #OvirtHost
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Gets a #OvirtCluster representing the cluster the host belongs
|
|
|
2bd53e |
+ * to. This method does not initiate any network activity, the remote host must
|
|
|
2bd53e |
+ * be then be fetched using ovirt_resource_refresh() or
|
|
|
2bd53e |
+ * ovirt_resource_refresh_async().
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Return value: (transfer full): a #OvirtCluster representing cluster the @host
|
|
|
2bd53e |
+ * belongs to.
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+OvirtCluster *ovirt_host_get_cluster(OvirtHost *host)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ g_return_val_if_fail(OVIRT_IS_HOST(host), NULL);
|
|
|
2bd53e |
+ g_return_val_if_fail(host->priv->cluster_id != NULL, NULL);
|
|
|
2bd53e |
+ return ovirt_cluster_new_from_id(host->priv->cluster_id, get_cluster_href(host));
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
diff --git a/govirt/ovirt-host.h b/govirt/ovirt-host.h
|
|
|
2bd53e |
index 91441f6..cdf702c 100644
|
|
|
2bd53e |
--- a/govirt/ovirt-host.h
|
|
|
2bd53e |
+++ b/govirt/ovirt-host.h
|
|
|
2bd53e |
@@ -60,6 +60,7 @@ GType ovirt_host_get_type(void);
|
|
|
2bd53e |
|
|
|
2bd53e |
OvirtHost *ovirt_host_new(void);
|
|
|
2bd53e |
OvirtCollection *ovirt_host_get_vms(OvirtHost *host);
|
|
|
2bd53e |
+OvirtCluster *ovirt_host_get_cluster(OvirtHost *host);
|
|
|
2bd53e |
|
|
|
2bd53e |
G_END_DECLS
|
|
|
2bd53e |
|