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