|
|
7cfb7a |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
7cfb7a |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
7cfb7a |
Date: Thu, 13 Jul 2017 17:49:36 -0300
|
|
|
7cfb7a |
Subject: [PATCH] cluster: Introduce ovirt_cluster_get_data_center()
|
|
|
7cfb7a |
|
|
|
7cfb7a |
This function can be used to retrieve the data center associated with
|
|
|
7cfb7a |
the cluster.
|
|
|
7cfb7a |
|
|
|
7cfb7a |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
7cfb7a |
---
|
|
|
7cfb7a |
govirt/govirt.sym | 1 +
|
|
|
7cfb7a |
govirt/ovirt-cluster.c | 33 ++++++++++++++++++++++++++++++++-
|
|
|
7cfb7a |
govirt/ovirt-cluster.h | 1 +
|
|
|
7cfb7a |
3 files changed, 34 insertions(+), 1 deletion(-)
|
|
|
7cfb7a |
|
|
|
7cfb7a |
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
|
|
|
7cfb7a |
index 243ce0b..9806033 100644
|
|
|
7cfb7a |
--- a/govirt/govirt.sym
|
|
|
7cfb7a |
+++ b/govirt/govirt.sym
|
|
|
7cfb7a |
@@ -121,6 +121,7 @@ GOVIRT_0.3.2 {
|
|
|
7cfb7a |
ovirt_api_search_vms;
|
|
|
7cfb7a |
ovirt_api_search_vm_pools;
|
|
|
7cfb7a |
|
|
|
7cfb7a |
+ ovirt_cluster_get_data_center;
|
|
|
7cfb7a |
ovirt_cluster_get_type;
|
|
|
7cfb7a |
ovirt_cluster_get_hosts;
|
|
|
7cfb7a |
ovirt_cluster_new;
|
|
|
7cfb7a |
diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
|
|
|
7cfb7a |
index 83b0fa1..4aaf6b1 100644
|
|
|
7cfb7a |
--- a/govirt/ovirt-cluster.c
|
|
|
7cfb7a |
+++ b/govirt/ovirt-cluster.c
|
|
|
7cfb7a |
@@ -42,6 +42,18 @@ enum {
|
|
|
7cfb7a |
PROP_DATA_CENTER_ID,
|
|
|
7cfb7a |
};
|
|
|
7cfb7a |
|
|
|
7cfb7a |
+static const char *get_data_center_href(OvirtCluster *cluster)
|
|
|
7cfb7a |
+{
|
|
|
7cfb7a |
+ if (cluster->priv->data_center_href == NULL &&
|
|
|
7cfb7a |
+ cluster->priv->data_center_id != NULL) {
|
|
|
7cfb7a |
+ cluster->priv->data_center_href = g_strdup_printf("%s/%s",
|
|
|
7cfb7a |
+ "/ovirt-engine/api/data_centers",
|
|
|
7cfb7a |
+ cluster->priv->data_center_id);
|
|
|
7cfb7a |
+ }
|
|
|
7cfb7a |
+
|
|
|
7cfb7a |
+ return cluster->priv->data_center_href;
|
|
|
7cfb7a |
+}
|
|
|
7cfb7a |
+
|
|
|
7cfb7a |
static void ovirt_cluster_get_property(GObject *object,
|
|
|
7cfb7a |
guint prop_id,
|
|
|
7cfb7a |
GValue *value,
|
|
|
7cfb7a |
@@ -51,7 +63,7 @@ static void ovirt_cluster_get_property(GObject *object,
|
|
|
7cfb7a |
|
|
|
7cfb7a |
switch (prop_id) {
|
|
|
7cfb7a |
case PROP_DATA_CENTER_HREF:
|
|
|
7cfb7a |
- g_value_set_string(value, cluster->priv->data_center_href);
|
|
|
7cfb7a |
+ g_value_set_string(value, get_data_center_href(cluster));
|
|
|
7cfb7a |
break;
|
|
|
7cfb7a |
case PROP_DATA_CENTER_ID:
|
|
|
7cfb7a |
g_value_set_string(value, cluster->priv->data_center_id);
|
|
|
7cfb7a |
@@ -213,3 +225,22 @@ OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster)
|
|
|
7cfb7a |
return cluster->priv->hosts;
|
|
|
7cfb7a |
}
|
|
|
7cfb7a |
|
|
|
7cfb7a |
+
|
|
|
7cfb7a |
+/**
|
|
|
7cfb7a |
+ * ovirt_cluster_get_data_center:
|
|
|
7cfb7a |
+ * @cluster: a #OvirtCluster
|
|
|
7cfb7a |
+ *
|
|
|
7cfb7a |
+ * Gets a #OvirtCluster representing the data center the cluster belongs
|
|
|
7cfb7a |
+ * to. This method does not initiate any network activity, the remote data center must
|
|
|
7cfb7a |
+ * be then be fetched using ovirt_resource_refresh() or
|
|
|
7cfb7a |
+ * ovirt_resource_refresh_async().
|
|
|
7cfb7a |
+ *
|
|
|
7cfb7a |
+ * Return value: (transfer full): a #OvirtDataCenter representing data center
|
|
|
7cfb7a |
+ * the @host belongs to.
|
|
|
7cfb7a |
+ */
|
|
|
7cfb7a |
+OvirtDataCenter *ovirt_cluster_get_data_center(OvirtCluster *cluster)
|
|
|
7cfb7a |
+{
|
|
|
7cfb7a |
+ g_return_val_if_fail(OVIRT_IS_CLUSTER(cluster), NULL);
|
|
|
7cfb7a |
+ g_return_val_if_fail(cluster->priv->data_center_id != NULL, NULL);
|
|
|
7cfb7a |
+ return ovirt_data_center_new_from_id(cluster->priv->data_center_id, get_data_center_href(cluster));
|
|
|
7cfb7a |
+}
|
|
|
7cfb7a |
diff --git a/govirt/ovirt-cluster.h b/govirt/ovirt-cluster.h
|
|
|
7cfb7a |
index 9505e8c..cdd54b7 100644
|
|
|
7cfb7a |
--- a/govirt/ovirt-cluster.h
|
|
|
7cfb7a |
+++ b/govirt/ovirt-cluster.h
|
|
|
7cfb7a |
@@ -60,6 +60,7 @@ GType ovirt_cluster_get_type(void);
|
|
|
7cfb7a |
|
|
|
7cfb7a |
OvirtCluster *ovirt_cluster_new(void);
|
|
|
7cfb7a |
OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster);
|
|
|
7cfb7a |
+OvirtDataCenter *ovirt_cluster_get_data_center(OvirtCluster *cluster);
|
|
|
7cfb7a |
|
|
|
7cfb7a |
G_END_DECLS
|
|
|
7cfb7a |
|