|
|
4dfa2a |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
2bd53e |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
|
2bd53e |
Date: Tue, 11 Apr 2017 21:53:26 -0300
|
|
|
2bd53e |
Subject: [PATCH] Initial support for data centers
|
|
|
2bd53e |
|
|
|
2bd53e |
For this higher level object, the list of clusters and storage domains
|
|
|
2bd53e |
associated with it are stored.
|
|
|
2bd53e |
|
|
|
2bd53e |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
2bd53e |
---
|
|
|
2bd53e |
govirt/Makefile.am | 3 +
|
|
|
2bd53e |
govirt/govirt-private.h | 1 +
|
|
|
2bd53e |
govirt/govirt.sym | 7 ++
|
|
|
4dfa2a |
govirt/ovirt-api.c | 47 ++++++++++
|
|
|
2bd53e |
govirt/ovirt-api.h | 2 +
|
|
|
4dfa2a |
govirt/ovirt-data-center-private.h | 37 ++++++++
|
|
|
4dfa2a |
govirt/ovirt-data-center.c | 144 +++++++++++++++++++++++++++++
|
|
|
4dfa2a |
govirt/ovirt-data-center.h | 67 ++++++++++++++
|
|
|
2bd53e |
govirt/ovirt-types.h | 1 +
|
|
|
2bd53e |
9 files changed, 309 insertions(+)
|
|
|
2bd53e |
create mode 100644 govirt/ovirt-data-center-private.h
|
|
|
2bd53e |
create mode 100644 govirt/ovirt-data-center.c
|
|
|
2bd53e |
create mode 100644 govirt/ovirt-data-center.h
|
|
|
2bd53e |
|
|
|
2bd53e |
diff --git a/govirt/Makefile.am b/govirt/Makefile.am
|
|
|
2bd53e |
index cf6b858..9bf0eba 100644
|
|
|
2bd53e |
--- a/govirt/Makefile.am
|
|
|
2bd53e |
+++ b/govirt/Makefile.am
|
|
|
2bd53e |
@@ -21,6 +21,7 @@ libgovirt_la_HEADERS = \
|
|
|
2bd53e |
ovirt-cdrom.h \
|
|
|
2bd53e |
ovirt-cluster.h \
|
|
|
2bd53e |
ovirt-collection.h \
|
|
|
2bd53e |
+ ovirt-data-center.h \
|
|
|
2bd53e |
ovirt-error.h \
|
|
|
2bd53e |
ovirt-host.h \
|
|
|
2bd53e |
ovirt-options.h \
|
|
|
2bd53e |
@@ -41,6 +42,7 @@ noinst_HEADERS = \
|
|
|
2bd53e |
ovirt-api-private.h \
|
|
|
2bd53e |
ovirt-cluster-private.h \
|
|
|
2bd53e |
ovirt-collection-private.h \
|
|
|
2bd53e |
+ ovirt-data-center-private.h \
|
|
|
2bd53e |
ovirt-host-private.h \
|
|
|
2bd53e |
ovirt-proxy-private.h \
|
|
|
2bd53e |
ovirt-resource-private.h \
|
|
|
2bd53e |
@@ -58,6 +60,7 @@ libgovirt_la_SOURCES = \
|
|
|
2bd53e |
ovirt-cdrom.c \
|
|
|
2bd53e |
ovirt-cluster.c \
|
|
|
2bd53e |
ovirt-collection.c \
|
|
|
2bd53e |
+ ovirt-data-center.c \
|
|
|
2bd53e |
ovirt-error.c \
|
|
|
2bd53e |
ovirt-host.c \
|
|
|
2bd53e |
ovirt-options.c \
|
|
|
2bd53e |
diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
|
|
|
2bd53e |
index d466f7a..cd98b5b 100644
|
|
|
2bd53e |
--- a/govirt/govirt-private.h
|
|
|
2bd53e |
+++ b/govirt/govirt-private.h
|
|
|
2bd53e |
@@ -26,6 +26,7 @@
|
|
|
2bd53e |
#include <govirt/ovirt-api-private.h>
|
|
|
2bd53e |
#include <govirt/ovirt-cluster-private.h>
|
|
|
2bd53e |
#include <govirt/ovirt-collection-private.h>
|
|
|
2bd53e |
+#include <govirt/ovirt-data-center-private.h>
|
|
|
2bd53e |
#include <govirt/ovirt-enum-types-private.h>
|
|
|
2bd53e |
#include <govirt/ovirt-host-private.h>
|
|
|
2bd53e |
#include <govirt/ovirt-proxy-private.h>
|
|
|
2bd53e |
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
|
|
|
4dfa2a |
index 56e1d66..b22af76 100644
|
|
|
2bd53e |
--- a/govirt/govirt.sym
|
|
|
2bd53e |
+++ b/govirt/govirt.sym
|
|
|
2bd53e |
@@ -111,9 +111,11 @@ GOVIRT_0.3.2 {
|
|
|
2bd53e |
ovirt_api_search_vm_pools;
|
|
|
2bd53e |
|
|
|
2bd53e |
ovirt_api_get_clusters;
|
|
|
2bd53e |
+ ovirt_api_get_data_centers;
|
|
|
2bd53e |
ovirt_api_get_hosts;
|
|
|
2bd53e |
|
|
|
2bd53e |
ovirt_api_search_clusters;
|
|
|
2bd53e |
+ ovirt_api_search_data_centers;
|
|
|
2bd53e |
ovirt_api_search_hosts;
|
|
|
2bd53e |
ovirt_api_search_storage_domains;
|
|
|
2bd53e |
ovirt_api_search_vms;
|
|
|
2bd53e |
@@ -123,6 +125,11 @@ GOVIRT_0.3.2 {
|
|
|
2bd53e |
ovirt_cluster_get_hosts;
|
|
|
2bd53e |
ovirt_cluster_new;
|
|
|
2bd53e |
|
|
|
2bd53e |
+ ovirt_data_center_get_clusters;
|
|
|
2bd53e |
+ ovirt_data_center_get_storage_domains;
|
|
|
2bd53e |
+ ovirt_data_center_get_type;
|
|
|
2bd53e |
+ ovirt_data_center_new;
|
|
|
2bd53e |
+
|
|
|
2bd53e |
ovirt_host_get_type;
|
|
|
2bd53e |
ovirt_host_get_vms;
|
|
|
2bd53e |
ovirt_host_new;
|
|
|
2bd53e |
diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
|
|
|
4dfa2a |
index 14c6c5a..d78ba7e 100644
|
|
|
2bd53e |
--- a/govirt/ovirt-api.c
|
|
|
2bd53e |
+++ b/govirt/ovirt-api.c
|
|
|
2bd53e |
@@ -42,6 +42,7 @@
|
|
|
2bd53e |
|
|
|
2bd53e |
struct _OvirtApiPrivate {
|
|
|
2bd53e |
OvirtCollection *clusters;
|
|
|
2bd53e |
+ OvirtCollection *data_centers;
|
|
|
2bd53e |
OvirtCollection *hosts;
|
|
|
2bd53e |
OvirtCollection *storage_domains;
|
|
|
2bd53e |
OvirtCollection *vms;
|
|
|
2bd53e |
@@ -76,6 +77,7 @@ static void ovirt_api_dispose(GObject *object)
|
|
|
2bd53e |
OvirtApi *api = OVIRT_API(object);
|
|
|
2bd53e |
|
|
|
2bd53e |
g_clear_object(&api->priv->clusters);
|
|
|
2bd53e |
+ g_clear_object(&api->priv->data_centers);
|
|
|
2bd53e |
g_clear_object(&api->priv->hosts);
|
|
|
2bd53e |
g_clear_object(&api->priv->storage_domains);
|
|
|
2bd53e |
g_clear_object(&api->priv->vms);
|
|
|
4dfa2a |
@@ -339,3 +341,48 @@ OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query)
|
|
|
2bd53e |
"cluster",
|
|
|
2bd53e |
query);
|
|
|
2bd53e |
}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+/**
|
|
|
2bd53e |
+ * ovirt_api_get_data_centers:
|
|
|
2bd53e |
+ * @api: a #OvirtApi
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This method does not initiate any network activity, the collection
|
|
|
2bd53e |
+ * must be fetched with ovirt_collection_fetch() before having up-to-date
|
|
|
2bd53e |
+ * content.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Return value: (transfer none):
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+OvirtCollection *ovirt_api_get_data_centers(OvirtApi *api)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ if (api->priv->data_centers == NULL)
|
|
|
2bd53e |
+ api->priv->data_centers = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
|
|
|
2bd53e |
+ "datacenters",
|
|
|
2bd53e |
+ "data_centers",
|
|
|
2bd53e |
+ OVIRT_TYPE_DATA_CENTER,
|
|
|
2bd53e |
+ "data_center");
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ return api->priv->data_centers;
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+/**
|
|
|
2bd53e |
+ * ovirt_api_search_data_centers:
|
|
|
2bd53e |
+ * @api: a #OvirtApi
|
|
|
2bd53e |
+ * @query: search query
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Return value: (transfer none):
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+OvirtCollection *ovirt_api_search_data_centers(OvirtApi *api, const char *query)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
|
|
|
2bd53e |
+ "datacenters/search",
|
|
|
2bd53e |
+ "data_centers",
|
|
|
2bd53e |
+ OVIRT_TYPE_DATA_CENTER,
|
|
|
2bd53e |
+ "data_center",
|
|
|
2bd53e |
+ query);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
|
|
|
2bd53e |
index 1b60f35..1448296 100644
|
|
|
2bd53e |
--- a/govirt/ovirt-api.h
|
|
|
2bd53e |
+++ b/govirt/ovirt-api.h
|
|
|
2bd53e |
@@ -62,6 +62,8 @@ OvirtApi *ovirt_api_new(void);
|
|
|
2bd53e |
|
|
|
2bd53e |
OvirtCollection *ovirt_api_get_clusters(OvirtApi *api);
|
|
|
2bd53e |
OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query);
|
|
|
2bd53e |
+OvirtCollection *ovirt_api_get_data_centers(OvirtApi *api);
|
|
|
2bd53e |
+OvirtCollection *ovirt_api_search_data_centers(OvirtApi *api, const char *query);
|
|
|
2bd53e |
OvirtCollection *ovirt_api_get_hosts(OvirtApi *api);
|
|
|
2bd53e |
OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query);
|
|
|
2bd53e |
OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
|
|
|
2bd53e |
diff --git a/govirt/ovirt-data-center-private.h b/govirt/ovirt-data-center-private.h
|
|
|
2bd53e |
new file mode 100644
|
|
|
2bd53e |
index 0000000..5839755
|
|
|
2bd53e |
--- /dev/null
|
|
|
2bd53e |
+++ b/govirt/ovirt-data-center-private.h
|
|
|
2bd53e |
@@ -0,0 +1,37 @@
|
|
|
2bd53e |
+/*
|
|
|
2bd53e |
+ * ovirt-data_center-private.h: oVirt data center resource
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is free software; you can redistribute it and/or
|
|
|
2bd53e |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License as published by the Free Software Foundation; either
|
|
|
2bd53e |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is distributed in the hope that it will be useful,
|
|
|
2bd53e |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2bd53e |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2bd53e |
+ * Lesser General Public License for more details.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License along with this library. If not, see
|
|
|
2bd53e |
+ * <http://www.gnu.org/licenses/>.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+#ifndef __OVIRT_DATA_CENTER_PRIVATE_H__
|
|
|
2bd53e |
+#define __OVIRT_DATA_CENTER_PRIVATE_H__
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#include <ovirt-data-center.h>
|
|
|
2bd53e |
+#include <rest/rest-xml-node.h>
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_BEGIN_DECLS
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new_from_id(const char *id,
|
|
|
2bd53e |
+ const char *href);
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new_from_xml(RestXmlNode *node,
|
|
|
2bd53e |
+ GError **error);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_END_DECLS
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#endif /* __OVIRT_DATA_CENTER_PRIVATE_H__ */
|
|
|
2bd53e |
diff --git a/govirt/ovirt-data-center.c b/govirt/ovirt-data-center.c
|
|
|
2bd53e |
new file mode 100644
|
|
|
2bd53e |
index 0000000..577a31f
|
|
|
2bd53e |
--- /dev/null
|
|
|
2bd53e |
+++ b/govirt/ovirt-data-center.c
|
|
|
2bd53e |
@@ -0,0 +1,144 @@
|
|
|
2bd53e |
+/*
|
|
|
2bd53e |
+ * ovirt-data_center.c: oVirt data center handling
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is free software; you can redistribute it and/or
|
|
|
2bd53e |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License as published by the Free Software Foundation; either
|
|
|
2bd53e |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is distributed in the hope that it will be useful,
|
|
|
2bd53e |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2bd53e |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2bd53e |
+ * Lesser General Public License for more details.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License along with this library. If not, see
|
|
|
2bd53e |
+ * <http://www.gnu.org/licenses/>.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#include <config.h>
|
|
|
2bd53e |
+#include "ovirt-enum-types.h"
|
|
|
2bd53e |
+#include "ovirt-data-center.h"
|
|
|
2bd53e |
+#include "govirt-private.h"
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#define OVIRT_DATA_CENTER_GET_PRIVATE(obj) \
|
|
|
2bd53e |
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterPrivate))
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+struct _OvirtDataCenterPrivate {
|
|
|
2bd53e |
+ OvirtCollection *clusters;
|
|
|
2bd53e |
+ OvirtCollection *storage_domains;
|
|
|
2bd53e |
+};
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_DEFINE_TYPE(OvirtDataCenter, ovirt_data_center, OVIRT_TYPE_RESOURCE);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+static void
|
|
|
2bd53e |
+ovirt_data_center_dispose(GObject *obj)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtDataCenter *data_center = OVIRT_DATA_CENTER(obj);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ g_clear_object(&data_center->priv->clusters);
|
|
|
2bd53e |
+ g_clear_object(&data_center->priv->storage_domains);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ G_OBJECT_CLASS(ovirt_data_center_parent_class)->dispose(obj);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+static void ovirt_data_center_class_init(OvirtDataCenterClass *klass)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ g_type_class_add_private(klass, sizeof(OvirtDataCenterPrivate));
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ object_class->dispose = ovirt_data_center_dispose;
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+static void ovirt_data_center_init(OvirtDataCenter *data_center)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ data_center->priv = OVIRT_DATA_CENTER_GET_PRIVATE(data_center);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_GNUC_INTERNAL
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new_from_id(const char *id,
|
|
|
2bd53e |
+ const char *href)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtResource *data_center = ovirt_resource_new_from_id(OVIRT_TYPE_DATA_CENTER, id, href);
|
|
|
2bd53e |
+ return OVIRT_DATA_CENTER(data_center);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_GNUC_INTERNAL
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new_from_xml(RestXmlNode *node,
|
|
|
2bd53e |
+ GError **error)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtResource *data_center = ovirt_resource_new_from_xml(OVIRT_TYPE_DATA_CENTER, node, error);
|
|
|
2bd53e |
+ return OVIRT_DATA_CENTER(data_center);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new(void)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtResource *data_center = ovirt_resource_new(OVIRT_TYPE_DATA_CENTER);
|
|
|
2bd53e |
+ return OVIRT_DATA_CENTER(data_center);
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+/**
|
|
|
2bd53e |
+ * ovirt_data_center_get_clusters:
|
|
|
2bd53e |
+ * @data_center: a #OvirtDataCenter
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Gets a #OvirtCollection representing the list of remote clusters from a
|
|
|
2bd53e |
+ * data center object. This method does not initiate any network
|
|
|
2bd53e |
+ * activity, the remote cluster list must be then be fetched using
|
|
|
2bd53e |
+ * ovirt_collection_fetch() or ovirt_collection_fetch_async().
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Return value: (transfer none): a #OvirtCollection representing the list
|
|
|
2bd53e |
+ * of clusters associated with @data_center.
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+OvirtCollection *ovirt_data_center_get_clusters(OvirtDataCenter *data_center)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ g_return_val_if_fail(OVIRT_IS_DATA_CENTER(data_center), NULL);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ if (data_center->priv->clusters == NULL) {
|
|
|
2bd53e |
+ OvirtCollection *collection;
|
|
|
2bd53e |
+ collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(data_center),
|
|
|
2bd53e |
+ "clusters",
|
|
|
2bd53e |
+ "clusters",
|
|
|
2bd53e |
+ OVIRT_TYPE_CLUSTER,
|
|
|
2bd53e |
+ "cluster");
|
|
|
2bd53e |
+ data_center->priv->clusters = collection;
|
|
|
2bd53e |
+ }
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ return data_center->priv->clusters;
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+/**
|
|
|
2bd53e |
+ * ovirt_data_center_get_storage_domains:
|
|
|
2bd53e |
+ * @data_center: a #OvirtDataCenter
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Gets a #OvirtCollection representing the list of remote storage domains from a
|
|
|
2bd53e |
+ * data center object. This method does not initiate any network
|
|
|
2bd53e |
+ * activity, the remote storage domain list must be then be fetched using
|
|
|
2bd53e |
+ * ovirt_collection_fetch() or ovirt_collection_fetch_async().
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Return value: (transfer none): a #OvirtCollection representing the list
|
|
|
2bd53e |
+ * of storage_domains associated with @data_center.
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+OvirtCollection *ovirt_data_center_get_storage_domains(OvirtDataCenter *data_center)
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ g_return_val_if_fail(OVIRT_IS_DATA_CENTER(data_center), NULL);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ if (data_center->priv->storage_domains == NULL) {
|
|
|
2bd53e |
+ OvirtCollection *collection;
|
|
|
2bd53e |
+ collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(data_center),
|
|
|
2bd53e |
+ "storagedomains",
|
|
|
2bd53e |
+ "storage_domains",
|
|
|
2bd53e |
+ OVIRT_TYPE_STORAGE_DOMAIN,
|
|
|
2bd53e |
+ "storage_domain");
|
|
|
2bd53e |
+ data_center->priv->storage_domains = collection;
|
|
|
2bd53e |
+ }
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ return data_center->priv->storage_domains;
|
|
|
2bd53e |
+}
|
|
|
2bd53e |
diff --git a/govirt/ovirt-data-center.h b/govirt/ovirt-data-center.h
|
|
|
2bd53e |
new file mode 100644
|
|
|
2bd53e |
index 0000000..1bad06f
|
|
|
2bd53e |
--- /dev/null
|
|
|
2bd53e |
+++ b/govirt/ovirt-data-center.h
|
|
|
2bd53e |
@@ -0,0 +1,67 @@
|
|
|
2bd53e |
+/*
|
|
|
2bd53e |
+ * ovirt-data_center.h: oVirt data center resource
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is free software; you can redistribute it and/or
|
|
|
2bd53e |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License as published by the Free Software Foundation; either
|
|
|
2bd53e |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * This library is distributed in the hope that it will be useful,
|
|
|
2bd53e |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2bd53e |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2bd53e |
+ * Lesser General Public License for more details.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
2bd53e |
+ * License along with this library. If not, see
|
|
|
2bd53e |
+ * <http://www.gnu.org/licenses/>.
|
|
|
2bd53e |
+ *
|
|
|
2bd53e |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
2bd53e |
+ */
|
|
|
2bd53e |
+#ifndef __OVIRT_DATA_CENTER_H__
|
|
|
2bd53e |
+#define __OVIRT_DATA_CENTER_H__
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#include <gio/gio.h>
|
|
|
2bd53e |
+#include <glib-object.h>
|
|
|
2bd53e |
+#include <govirt/ovirt-collection.h>
|
|
|
2bd53e |
+#include <govirt/ovirt-resource.h>
|
|
|
2bd53e |
+#include <govirt/ovirt-types.h>
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_BEGIN_DECLS
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#define OVIRT_TYPE_DATA_CENTER (ovirt_data_center_get_type ())
|
|
|
2bd53e |
+#define OVIRT_DATA_CENTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenter))
|
|
|
2bd53e |
+#define OVIRT_DATA_CENTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterClass))
|
|
|
2bd53e |
+#define OVIRT_IS_DATA_CENTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_DATA_CENTER))
|
|
|
2bd53e |
+#define OVIRT_IS_DATA_CENTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_DATA_CENTER))
|
|
|
2bd53e |
+#define OVIRT_DATA_CENTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterClass))
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+typedef struct _OvirtDataCenterPrivate OvirtDataCenterPrivate;
|
|
|
2bd53e |
+typedef struct _OvirtDataCenterClass OvirtDataCenterClass;
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+struct _OvirtDataCenter
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtResource parent;
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ OvirtDataCenterPrivate *priv;
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ /* Do not add fields to this struct */
|
|
|
2bd53e |
+};
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+struct _OvirtDataCenterClass
|
|
|
2bd53e |
+{
|
|
|
2bd53e |
+ OvirtResourceClass parent_class;
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+ gpointer padding[20];
|
|
|
2bd53e |
+};
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+GType ovirt_data_center_get_type(void);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+OvirtDataCenter *ovirt_data_center_new(void);
|
|
|
2bd53e |
+OvirtCollection *ovirt_data_center_get_clusters(OvirtDataCenter *data_center);
|
|
|
2bd53e |
+OvirtCollection *ovirt_data_center_get_storage_domains(OvirtDataCenter *data_center);
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+G_END_DECLS
|
|
|
2bd53e |
+
|
|
|
2bd53e |
+#endif /* __OVIRT_DATA_CENTER_H__ */
|
|
|
2bd53e |
diff --git a/govirt/ovirt-types.h b/govirt/ovirt-types.h
|
|
|
2bd53e |
index e2f196e..eb85fd6 100644
|
|
|
2bd53e |
--- a/govirt/ovirt-types.h
|
|
|
2bd53e |
+++ b/govirt/ovirt-types.h
|
|
|
2bd53e |
@@ -29,6 +29,7 @@ typedef struct _OvirtApi OvirtApi;
|
|
|
2bd53e |
typedef struct _OvirtCdrom OvirtCdrom;
|
|
|
2bd53e |
typedef struct _OvirtCluster OvirtCluster;
|
|
|
2bd53e |
typedef struct _OvirtCollection OvirtCollection;
|
|
|
2bd53e |
+typedef struct _OvirtDataCenter OvirtDataCenter;
|
|
|
2bd53e |
typedef struct _OvirtHost OvirtHost;
|
|
|
2bd53e |
typedef struct _OvirtProxy OvirtProxy;
|
|
|
2bd53e |
typedef struct _OvirtStorageDomain OvirtStorageDomain;
|