|
 |
7cfb7a |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
 |
7cfb7a |
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
|
|
 |
7cfb7a |
Date: Tue, 11 Apr 2017 21:47:44 -0300
|
|
 |
7cfb7a |
Subject: [PATCH] Initial support for hosts
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
At the moment, we only care about the information about the cluster the
|
|
 |
7cfb7a |
host is part of, and the list of the vms associated with it.
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
govirt/Makefile.am | 3 +
|
|
 |
7cfb7a |
govirt/govirt-private.h | 1 +
|
|
 |
7cfb7a |
govirt/govirt.sym | 11 ++
|
|
 |
7cfb7a |
govirt/ovirt-api.c | 47 ++++++++
|
|
 |
7cfb7a |
govirt/ovirt-api.h | 2 +
|
|
 |
7cfb7a |
govirt/ovirt-host-private.h | 37 +++++++
|
|
 |
7cfb7a |
govirt/ovirt-host.c | 214 ++++++++++++++++++++++++++++++++++++
|
|
 |
7cfb7a |
govirt/ovirt-host.h | 66 +++++++++++
|
|
 |
7cfb7a |
govirt/ovirt-types.h | 1 +
|
|
 |
7cfb7a |
9 files changed, 382 insertions(+)
|
|
 |
7cfb7a |
create mode 100644 govirt/ovirt-host-private.h
|
|
 |
7cfb7a |
create mode 100644 govirt/ovirt-host.c
|
|
 |
7cfb7a |
create mode 100644 govirt/ovirt-host.h
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
index e905f1f..c62a1d6 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -21,6 +21,7 @@ libgovirt_la_HEADERS = \
|
|
 |
7cfb7a |
ovirt-cdrom.h \
|
|
 |
7cfb7a |
ovirt-collection.h \
|
|
 |
7cfb7a |
ovirt-error.h \
|
|
 |
7cfb7a |
+ ovirt-host.h \
|
|
 |
7cfb7a |
ovirt-options.h \
|
|
 |
7cfb7a |
ovirt-proxy.h \
|
|
 |
7cfb7a |
ovirt-resource.h \
|
|
 |
7cfb7a |
@@ -38,6 +39,7 @@ noinst_HEADERS = \
|
|
 |
7cfb7a |
ovirt-action-rest-call.h \
|
|
 |
7cfb7a |
ovirt-api-private.h \
|
|
 |
7cfb7a |
ovirt-collection-private.h \
|
|
 |
7cfb7a |
+ ovirt-host-private.h \
|
|
 |
7cfb7a |
ovirt-proxy-private.h \
|
|
 |
7cfb7a |
ovirt-resource-private.h \
|
|
 |
7cfb7a |
ovirt-rest-call.h \
|
|
 |
7cfb7a |
@@ -54,6 +56,7 @@ libgovirt_la_SOURCES = \
|
|
 |
7cfb7a |
ovirt-cdrom.c \
|
|
 |
7cfb7a |
ovirt-collection.c \
|
|
 |
7cfb7a |
ovirt-error.c \
|
|
 |
7cfb7a |
+ ovirt-host.c \
|
|
 |
7cfb7a |
ovirt-options.c \
|
|
 |
7cfb7a |
ovirt-proxy.c \
|
|
 |
7cfb7a |
ovirt-proxy-deprecated.c \
|
|
 |
7cfb7a |
diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
|
|
 |
7cfb7a |
index 972ebac..b51feb3 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
+++ b/govirt/govirt-private.h
|
|
 |
7cfb7a |
@@ -26,6 +26,7 @@
|
|
 |
7cfb7a |
#include <govirt/ovirt-api-private.h>
|
|
 |
7cfb7a |
#include <govirt/ovirt-collection-private.h>
|
|
 |
7cfb7a |
#include <govirt/ovirt-enum-types-private.h>
|
|
 |
7cfb7a |
+#include <govirt/ovirt-host-private.h>
|
|
 |
7cfb7a |
#include <govirt/ovirt-proxy-private.h>
|
|
 |
7cfb7a |
#include <govirt/ovirt-resource-private.h>
|
|
 |
7cfb7a |
#include <govirt/ovirt-resource-rest-call.h>
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
index d02e77f..6dc8159 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -109,6 +109,17 @@ GOVIRT_0.3.2 {
|
|
 |
7cfb7a |
ovirt_api_search_storage_domains;
|
|
 |
7cfb7a |
ovirt_api_search_vms;
|
|
 |
7cfb7a |
ovirt_api_search_vm_pools;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ ovirt_api_get_hosts;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ ovirt_api_search_hosts;
|
|
 |
7cfb7a |
+ ovirt_api_search_storage_domains;
|
|
 |
7cfb7a |
+ ovirt_api_search_vms;
|
|
 |
7cfb7a |
+ ovirt_api_search_vm_pools;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ ovirt_host_get_type;
|
|
 |
7cfb7a |
+ ovirt_host_get_vms;
|
|
 |
7cfb7a |
+ ovirt_host_new;
|
|
 |
7cfb7a |
} GOVIRT_0.3.1;
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
GOVIRT_0.3.4 {
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
index 93dc3d5..fef04ba 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -41,6 +41,7 @@
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
struct _OvirtApiPrivate {
|
|
 |
7cfb7a |
+ OvirtCollection *hosts;
|
|
 |
7cfb7a |
OvirtCollection *storage_domains;
|
|
 |
7cfb7a |
OvirtCollection *vms;
|
|
 |
7cfb7a |
OvirtCollection *vm_pools;
|
|
 |
7cfb7a |
@@ -73,6 +74,7 @@ static void ovirt_api_dispose(GObject *object)
|
|
 |
7cfb7a |
{
|
|
 |
7cfb7a |
OvirtApi *api = OVIRT_API(object);
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
+ g_clear_object(&api->priv->hosts);
|
|
 |
7cfb7a |
g_clear_object(&api->priv->storage_domains);
|
|
 |
7cfb7a |
g_clear_object(&api->priv->vms);
|
|
 |
7cfb7a |
g_clear_object(&api->priv->vm_pools);
|
|
 |
7cfb7a |
@@ -245,3 +247,48 @@ OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *que
|
|
 |
7cfb7a |
"storage_domain",
|
|
 |
7cfb7a |
query);
|
|
 |
7cfb7a |
}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+/**
|
|
 |
7cfb7a |
+ * ovirt_api_get_hosts:
|
|
 |
7cfb7a |
+ * @api: a
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This method does not initiate any network activity, the collection
|
|
 |
7cfb7a |
+ * must be fetched with ovirt_collection_fetch() before having up-to-date
|
|
 |
7cfb7a |
+ * content.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Return value: (transfer none):
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_api_get_hosts(OvirtApi *api)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ if (api->priv->hosts == NULL)
|
|
 |
7cfb7a |
+ api->priv->hosts = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
|
|
 |
7cfb7a |
+ "hosts",
|
|
 |
7cfb7a |
+ "hosts",
|
|
 |
7cfb7a |
+ OVIRT_TYPE_HOST,
|
|
 |
7cfb7a |
+ "host");
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ return api->priv->hosts;
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+/**
|
|
 |
7cfb7a |
+ * ovirt_api_search_hosts:
|
|
 |
7cfb7a |
+ * @api: a
|
|
 |
7cfb7a |
+ * @query: search query
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Return value: (transfer none):
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
|
|
 |
7cfb7a |
+ "hosts",
|
|
 |
7cfb7a |
+ "hosts",
|
|
 |
7cfb7a |
+ OVIRT_TYPE_HOST,
|
|
 |
7cfb7a |
+ "host",
|
|
 |
7cfb7a |
+ query);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
index d511d70..c46e934 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -60,6 +60,8 @@ struct _OvirtApiClass
|
|
 |
7cfb7a |
GType ovirt_api_get_type(void);
|
|
 |
7cfb7a |
OvirtApi *ovirt_api_new(void);
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_api_get_hosts(OvirtApi *api);
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query);
|
|
 |
7cfb7a |
OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
|
|
 |
7cfb7a |
OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *query);
|
|
 |
7cfb7a |
OvirtCollection *ovirt_api_get_vms(OvirtApi *api);
|
|
 |
7cfb7a |
diff --git a/govirt/ovirt-host-private.h b/govirt/ovirt-host-private.h
|
|
 |
7cfb7a |
new file mode 100644
|
|
 |
7cfb7a |
index 0000000..26587ea
|
|
 |
7cfb7a |
--- /dev/null
|
|
 |
7cfb7a |
+++ b/govirt/ovirt-host-private.h
|
|
 |
7cfb7a |
@@ -0,0 +1,37 @@
|
|
 |
7cfb7a |
+/*
|
|
 |
7cfb7a |
+ * ovirt-host-private.h: oVirt host resource
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is free software; you can redistribute it and/or
|
|
 |
7cfb7a |
+ * modify it under the terms of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License as published by the Free Software Foundation; either
|
|
 |
7cfb7a |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is distributed in the hope that it will be useful,
|
|
 |
7cfb7a |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
 |
7cfb7a |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
 |
7cfb7a |
+ * Lesser General Public License for more details.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * You should have received a copy of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License along with this library. If not, see
|
|
 |
7cfb7a |
+ * <http://www.gnu.org/licenses/>.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+#ifndef __OVIRT_HOST_PRIVATE_H__
|
|
 |
7cfb7a |
+#define __OVIRT_HOST_PRIVATE_H__
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#include <ovirt-host.h>
|
|
 |
7cfb7a |
+#include <rest/rest-xml-node.h>
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_BEGIN_DECLS
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new_from_id(const char *id,
|
|
 |
7cfb7a |
+ const char *href);
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new_from_xml(RestXmlNode *node,
|
|
 |
7cfb7a |
+ GError **error);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_END_DECLS
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#endif
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
new file mode 100644
|
|
 |
7cfb7a |
index 0000000..2df2a64
|
|
 |
7cfb7a |
--- /dev/null
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -0,0 +1,214 @@
|
|
 |
7cfb7a |
+/*
|
|
 |
7cfb7a |
+ * ovirt-host.c: oVirt host handling
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is free software; you can redistribute it and/or
|
|
 |
7cfb7a |
+ * modify it under the terms of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License as published by the Free Software Foundation; either
|
|
 |
7cfb7a |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is distributed in the hope that it will be useful,
|
|
 |
7cfb7a |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
 |
7cfb7a |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
 |
7cfb7a |
+ * Lesser General Public License for more details.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * You should have received a copy of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License along with this library. If not, see
|
|
 |
7cfb7a |
+ * <http://www.gnu.org/licenses/>.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#include <config.h>
|
|
 |
7cfb7a |
+#include "ovirt-enum-types.h"
|
|
 |
7cfb7a |
+#include "ovirt-host.h"
|
|
 |
7cfb7a |
+#include "govirt-private.h"
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#define OVIRT_HOST_GET_PRIVATE(obj) \
|
|
 |
7cfb7a |
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_HOST, OvirtHostPrivate))
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+struct _OvirtHostPrivate {
|
|
 |
7cfb7a |
+ gchar *cluster_href;
|
|
 |
7cfb7a |
+ gchar *cluster_id;
|
|
 |
7cfb7a |
+ OvirtCollection *vms;
|
|
 |
7cfb7a |
+};
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_DEFINE_TYPE(OvirtHost, ovirt_host, OVIRT_TYPE_RESOURCE);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+enum {
|
|
 |
7cfb7a |
+ PROP_0,
|
|
 |
7cfb7a |
+ PROP_CLUSTER_HREF,
|
|
 |
7cfb7a |
+ PROP_CLUSTER_ID,
|
|
 |
7cfb7a |
+};
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static void ovirt_host_get_property(GObject *object,
|
|
 |
7cfb7a |
+ guint prop_id,
|
|
 |
7cfb7a |
+ GValue *value,
|
|
 |
7cfb7a |
+ GParamSpec *pspec)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtHost *host = OVIRT_HOST(object);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ switch (prop_id) {
|
|
 |
7cfb7a |
+ case PROP_CLUSTER_HREF:
|
|
 |
7cfb7a |
+ g_value_set_string(value, host->priv->cluster_href);
|
|
 |
7cfb7a |
+ break;
|
|
 |
7cfb7a |
+ case PROP_CLUSTER_ID:
|
|
 |
7cfb7a |
+ g_value_set_string(value, host->priv->cluster_id);
|
|
 |
7cfb7a |
+ break;
|
|
 |
7cfb7a |
+ default:
|
|
 |
7cfb7a |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
 |
7cfb7a |
+ }
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static void ovirt_host_set_property(GObject *object,
|
|
 |
7cfb7a |
+ guint prop_id,
|
|
 |
7cfb7a |
+ const GValue *value,
|
|
 |
7cfb7a |
+ GParamSpec *pspec)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtHost *host = OVIRT_HOST(object);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ switch (prop_id) {
|
|
 |
7cfb7a |
+ case PROP_CLUSTER_HREF:
|
|
 |
7cfb7a |
+ g_free(host->priv->cluster_href);
|
|
 |
7cfb7a |
+ host->priv->cluster_href = g_value_dup_string(value);
|
|
 |
7cfb7a |
+ break;
|
|
 |
7cfb7a |
+ case PROP_CLUSTER_ID:
|
|
 |
7cfb7a |
+ g_free(host->priv->cluster_id);
|
|
 |
7cfb7a |
+ host->priv->cluster_id = g_value_dup_string(value);
|
|
 |
7cfb7a |
+ break;
|
|
 |
7cfb7a |
+ default:
|
|
 |
7cfb7a |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
 |
7cfb7a |
+ }
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static void
|
|
 |
7cfb7a |
+ovirt_host_dispose(GObject *obj)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtHost *host = OVIRT_HOST(obj);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ g_clear_pointer(&host->priv->cluster_href, g_free);
|
|
 |
7cfb7a |
+ g_clear_pointer(&host->priv->cluster_id, g_free);
|
|
 |
7cfb7a |
+ g_clear_object(&host->priv->vms);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ G_OBJECT_CLASS(ovirt_host_parent_class)->dispose(obj);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static gboolean ovirt_host_init_from_xml(OvirtResource *resource,
|
|
 |
7cfb7a |
+ RestXmlNode *node,
|
|
 |
7cfb7a |
+ GError **error)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResourceClass *parent_class;
|
|
 |
7cfb7a |
+ OvirtXmlElement host_elements[] = {
|
|
 |
7cfb7a |
+ { .prop_name = "cluster-href",
|
|
 |
7cfb7a |
+ .type = G_TYPE_STRING,
|
|
 |
7cfb7a |
+ .xml_path = "cluster",
|
|
 |
7cfb7a |
+ .xml_attr = "href",
|
|
 |
7cfb7a |
+ },
|
|
 |
7cfb7a |
+ { .prop_name = "cluster-id",
|
|
 |
7cfb7a |
+ .type = G_TYPE_STRING,
|
|
 |
7cfb7a |
+ .xml_path = "cluster",
|
|
 |
7cfb7a |
+ .xml_attr = "id",
|
|
 |
7cfb7a |
+ },
|
|
 |
7cfb7a |
+ { NULL , },
|
|
 |
7cfb7a |
+ };
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ if (!ovirt_rest_xml_node_parse(node, G_OBJECT(resource), host_elements))
|
|
 |
7cfb7a |
+ return FALSE;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ parent_class = OVIRT_RESOURCE_CLASS(ovirt_host_parent_class);
|
|
 |
7cfb7a |
+ return parent_class->init_from_xml(resource, node, error);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static void ovirt_host_class_init(OvirtHostClass *klass)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
|
 |
7cfb7a |
+ OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
|
|
 |
7cfb7a |
+ GParamSpec *param_spec;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ g_type_class_add_private(klass, sizeof(OvirtHostPrivate));
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ resource_class->init_from_xml = ovirt_host_init_from_xml;
|
|
 |
7cfb7a |
+ object_class->dispose = ovirt_host_dispose;
|
|
 |
7cfb7a |
+ object_class->get_property = ovirt_host_get_property;
|
|
 |
7cfb7a |
+ object_class->set_property = ovirt_host_set_property;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ param_spec = g_param_spec_string("cluster-href",
|
|
 |
7cfb7a |
+ "Cluster href",
|
|
 |
7cfb7a |
+ "Cluster href for the Host",
|
|
 |
7cfb7a |
+ NULL,
|
|
 |
7cfb7a |
+ G_PARAM_READWRITE |
|
|
 |
7cfb7a |
+ G_PARAM_STATIC_STRINGS);
|
|
 |
7cfb7a |
+ g_object_class_install_property(object_class,
|
|
 |
7cfb7a |
+ PROP_CLUSTER_HREF,
|
|
 |
7cfb7a |
+ param_spec);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ param_spec = g_param_spec_string("cluster-id",
|
|
 |
7cfb7a |
+ "Cluster Id",
|
|
 |
7cfb7a |
+ "Cluster Id for the Host",
|
|
 |
7cfb7a |
+ NULL,
|
|
 |
7cfb7a |
+ G_PARAM_READWRITE |
|
|
 |
7cfb7a |
+ G_PARAM_STATIC_STRINGS);
|
|
 |
7cfb7a |
+ g_object_class_install_property(object_class,
|
|
 |
7cfb7a |
+ PROP_CLUSTER_ID,
|
|
 |
7cfb7a |
+ param_spec);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+static void ovirt_host_init(OvirtHost *host)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ host->priv = OVIRT_HOST_GET_PRIVATE(host);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_GNUC_INTERNAL
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new_from_id(const char *id,
|
|
 |
7cfb7a |
+ const char *href)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResource *host = ovirt_resource_new_from_id(OVIRT_TYPE_HOST, id, href);
|
|
 |
7cfb7a |
+ return OVIRT_HOST(host);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_GNUC_INTERNAL
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new_from_xml(RestXmlNode *node,
|
|
 |
7cfb7a |
+ GError **error)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResource *host = ovirt_resource_new_from_xml(OVIRT_TYPE_HOST, node, error);
|
|
 |
7cfb7a |
+ return OVIRT_HOST(host);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new(void)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResource *host = ovirt_resource_new(OVIRT_TYPE_HOST);
|
|
 |
7cfb7a |
+ return OVIRT_HOST(host);
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+/**
|
|
 |
7cfb7a |
+ * ovirt_host_get_vms:
|
|
 |
7cfb7a |
+ * @host: a
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Gets a
|
|
 |
7cfb7a |
+ * host object. This method does not initiate any network
|
|
 |
7cfb7a |
+ * activity, the remote vm list must be then be fetched using
|
|
 |
7cfb7a |
+ * ovirt_collection_fetch() or ovirt_collection_fetch_async().
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Return value: (transfer none): a
|
|
 |
7cfb7a |
+ * of vms associated with @host.
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_host_get_vms(OvirtHost *host)
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ g_return_val_if_fail(OVIRT_IS_HOST(host), NULL);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ if (host->priv->vms == NULL) {
|
|
 |
7cfb7a |
+ OvirtCollection *collection;
|
|
 |
7cfb7a |
+ collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(host),
|
|
 |
7cfb7a |
+ "vms",
|
|
 |
7cfb7a |
+ "vms",
|
|
 |
7cfb7a |
+ OVIRT_TYPE_VM,
|
|
 |
7cfb7a |
+ "vm");
|
|
 |
7cfb7a |
+ host->priv->vms = collection;
|
|
 |
7cfb7a |
+ }
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ return host->priv->vms;
|
|
 |
7cfb7a |
+}
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
new file mode 100644
|
|
 |
7cfb7a |
index 0000000..91441f6
|
|
 |
7cfb7a |
--- /dev/null
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -0,0 +1,66 @@
|
|
 |
7cfb7a |
+/*
|
|
 |
7cfb7a |
+ * ovirt-host.h: oVirt host resource
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Copyright (C) 2017 Red Hat, Inc.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is free software; you can redistribute it and/or
|
|
 |
7cfb7a |
+ * modify it under the terms of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License as published by the Free Software Foundation; either
|
|
 |
7cfb7a |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * This library is distributed in the hope that it will be useful,
|
|
 |
7cfb7a |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
 |
7cfb7a |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
 |
7cfb7a |
+ * Lesser General Public License for more details.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * You should have received a copy of the GNU Lesser General Public
|
|
 |
7cfb7a |
+ * License along with this library. If not, see
|
|
 |
7cfb7a |
+ * <http://www.gnu.org/licenses/>.
|
|
 |
7cfb7a |
+ *
|
|
 |
7cfb7a |
+ * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
 |
7cfb7a |
+ */
|
|
 |
7cfb7a |
+#ifndef __OVIRT_HOST_H__
|
|
 |
7cfb7a |
+#define __OVIRT_HOST_H__
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#include <gio/gio.h>
|
|
 |
7cfb7a |
+#include <glib-object.h>
|
|
 |
7cfb7a |
+#include <govirt/ovirt-collection.h>
|
|
 |
7cfb7a |
+#include <govirt/ovirt-resource.h>
|
|
 |
7cfb7a |
+#include <govirt/ovirt-types.h>
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_BEGIN_DECLS
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#define OVIRT_TYPE_HOST (ovirt_host_get_type ())
|
|
 |
7cfb7a |
+#define OVIRT_HOST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_HOST, OvirtHost))
|
|
 |
7cfb7a |
+#define OVIRT_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_HOST, OvirtHostClass))
|
|
 |
7cfb7a |
+#define OVIRT_IS_HOST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_HOST))
|
|
 |
7cfb7a |
+#define OVIRT_IS_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_HOST))
|
|
 |
7cfb7a |
+#define OVIRT_HOST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_HOST, OvirtHostClass))
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+typedef struct _OvirtHostPrivate OvirtHostPrivate;
|
|
 |
7cfb7a |
+typedef struct _OvirtHostClass OvirtHostClass;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+struct _OvirtHost
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResource parent;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ OvirtHostPrivate *priv;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ /* Do not add fields to this struct */
|
|
 |
7cfb7a |
+};
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+struct _OvirtHostClass
|
|
 |
7cfb7a |
+{
|
|
 |
7cfb7a |
+ OvirtResourceClass parent_class;
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+ gpointer padding[20];
|
|
 |
7cfb7a |
+};
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+GType ovirt_host_get_type(void);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+OvirtHost *ovirt_host_new(void);
|
|
 |
7cfb7a |
+OvirtCollection *ovirt_host_get_vms(OvirtHost *host);
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+G_END_DECLS
|
|
 |
7cfb7a |
+
|
|
 |
7cfb7a |
+#endif
|
|
 |
7cfb7a |
diff
|
|
 |
7cfb7a |
index c89521b..42fc004 100644
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
|
|
 |
7cfb7a |
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
|
|
 |
7cfb7a |
typedef struct _OvirtApi OvirtApi;
|
|
 |
7cfb7a |
typedef struct _OvirtCdrom OvirtCdrom;
|
|
 |
7cfb7a |
typedef struct _OvirtCollection OvirtCollection;
|
|
 |
7cfb7a |
+typedef struct _OvirtHost OvirtHost;
|
|
 |
7cfb7a |
typedef struct _OvirtProxy OvirtProxy;
|
|
 |
7cfb7a |
typedef struct _OvirtStorageDomain OvirtStorageDomain;
|
|
 |
7cfb7a |
typedef struct _OvirtVmDisplay OvirtVmDisplay;
|