[libgovirt] Add OvirtStorageDomain class



commit 2ca74c5240074ce5bf7289e53f99b35b8802984f
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Aug 20 18:12:31 2013 +0200

    Add OvirtStorageDomain class

 govirt/Makefile.am            |    2 +
 govirt/govirt.h               |    1 +
 govirt/govirt.sym             |    5 +
 govirt/ovirt-storage-domain.c |  216 +++++++++++++++++++++++++++++++++++++++++
 govirt/ovirt-storage-domain.h |   85 ++++++++++++++++
 5 files changed, 309 insertions(+), 0 deletions(-)
---
diff --git a/govirt/Makefile.am b/govirt/Makefile.am
index f5ddf36..4d40b8c 100644
--- a/govirt/Makefile.am
+++ b/govirt/Makefile.am
@@ -21,6 +21,7 @@ libgovirt_la_HEADERS =                                                \
        ovirt-proxy.h                                           \
        ovirt-resource.h                                        \
        ovirt-rest-call-error.h                                 \
+       ovirt-storage-domain.h                                  \
        ovirt-types.h                                           \
        ovirt-vm.h                                              \
        ovirt-vm-display.h                                      \
@@ -47,6 +48,7 @@ libgovirt_la_SOURCES =                                                \
        ovirt-proxy-deprecated.c                                \
        ovirt-resource.c                                        \
        ovirt-rest-call.c                                       \
+       ovirt-storage-domain.c                                  \
        ovirt-utils.c                                           \
        ovirt-vm.c                                              \
        ovirt-vm-display.c                                      \
diff --git a/govirt/govirt.h b/govirt/govirt.h
index c4b1bbe..81264d2 100644
--- a/govirt/govirt.h
+++ b/govirt/govirt.h
@@ -29,6 +29,7 @@
 #include <govirt/ovirt-proxy.h>
 #include <govirt/ovirt-resource.h>
 #include <govirt/ovirt-rest-call-error.h>
+#include <govirt/ovirt-storage-domain.h>
 #include <govirt/ovirt-vm.h>
 #include <govirt/ovirt-vm-display.h>
 
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
index e23a17f..62fb8b1 100644
--- a/govirt/govirt.sym
+++ b/govirt/govirt.sym
@@ -62,6 +62,11 @@ GOVIRT_0.2.1 {
         ovirt_proxy_fetch_api;
         ovirt_proxy_fetch_api_async;
         ovirt_proxy_fetch_api_finish;
+
+        ovirt_storage_domain_get_type;
+        ovirt_storage_domain_state_get_type;
+        ovirt_storage_domain_format_version_get_type;
+        ovirt_storage_domain_type_get_type;
 } GOVIRT_0.2.0;
 
 
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
new file mode 100644
index 0000000..10159ad
--- /dev/null
+++ b/govirt/ovirt-storage-domain.c
@@ -0,0 +1,216 @@
+/*
+ * ovirt-storage-domain.c: oVirt storage domain handling
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+
+#include <config.h>
+#include "ovirt-enum-types.h"
+#include "ovirt-storage-domain.h"
+
+#define OVIRT_STORAGE_DOMAIN_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_STORAGE_DOMAIN, OvirtStorageDomainPrivate))
+
+struct _OvirtStorageDomainPrivate {
+    OvirtStorageDomainType type;
+    gboolean is_master;
+    guint64 available;
+    guint64 used;
+    guint64 committed;
+    OvirtStorageDomainFormatVersion version;
+    OvirtStorageDomainState state;
+};
+
+G_DEFINE_TYPE(OvirtStorageDomain, ovirt_storage_domain, OVIRT_TYPE_RESOURCE);
+
+enum {
+    PROP_0,
+    PROP_STORAGE_TYPE,
+    PROP_MASTER,
+    PROP_AVAILABLE,
+    PROP_USED,
+    PROP_COMMITTED,
+    PROP_VERSION,
+    PROP_STATE
+};
+
+static void ovirt_storage_domain_get_property(GObject *object,
+                                              guint prop_id,
+                                              GValue *value,
+                                              GParamSpec *pspec)
+{
+    OvirtStorageDomain *domain = OVIRT_STORAGE_DOMAIN(object);
+
+    switch (prop_id) {
+    case PROP_STORAGE_TYPE:
+        g_value_set_enum(value, domain->priv->type);
+        break;
+    case PROP_MASTER:
+        g_value_set_boolean(value, domain->priv->is_master);
+        break;
+    case PROP_AVAILABLE:
+        g_value_set_uint64(value, domain->priv->available);
+        break;
+    case PROP_USED:
+        g_value_set_uint64(value, domain->priv->used);
+        break;
+    case PROP_COMMITTED:
+        g_value_set_uint64(value, domain->priv->committed);
+        break;
+    case PROP_VERSION:
+        g_value_set_enum(value, domain->priv->version);
+        break;
+    case PROP_STATE:
+        g_value_set_enum(value, domain->priv->state);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void ovirt_storage_domain_set_property(GObject *object,
+                                              guint prop_id,
+                                              const GValue *value,
+                                              GParamSpec *pspec)
+{
+    OvirtStorageDomain *domain = OVIRT_STORAGE_DOMAIN(object);
+
+    switch (prop_id) {
+    case PROP_STORAGE_TYPE:
+        domain->priv->type = g_value_get_enum(value);
+        break;
+    case PROP_MASTER:
+        domain->priv->is_master = g_value_get_boolean(value);
+        break;
+    case PROP_AVAILABLE:
+        domain->priv->available = g_value_get_uint64(value);
+        break;
+    case PROP_USED:
+        domain->priv->used = g_value_get_uint64(value);
+        break;
+    case PROP_COMMITTED:
+        domain->priv->committed = g_value_get_uint64(value);
+        break;
+    case PROP_VERSION:
+        domain->priv->version = g_value_get_enum(value);
+        break;
+    case PROP_STATE:
+        domain->priv->state = g_value_get_enum(value);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void ovirt_storage_domain_class_init(OvirtStorageDomainClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+    GParamSpec *param_spec;
+
+    g_type_class_add_private(klass, sizeof(OvirtStorageDomainPrivate));
+
+    object_class->get_property = ovirt_storage_domain_get_property;
+    object_class->set_property = ovirt_storage_domain_set_property;
+
+    param_spec = g_param_spec_enum("type",
+                                   "Storage Type",
+                                   "Type of the storage domain",
+                                   OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
+                                   OVIRT_STORAGE_DOMAIN_TYPE_DATA,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_STORAGE_TYPE,
+                                    param_spec);
+
+    param_spec = g_param_spec_boolean("master",
+                                      "Master Storage Domain?",
+                                      "Indicates whether the storage domain is a master on not",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_MASTER,
+                                    param_spec);
+
+    param_spec = g_param_spec_uint64("available",
+                                     "Space available",
+                                     "Space available in the storage domain in bytes",
+                                     0,
+                                     G_MAXUINT64,
+                                     0,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_AVAILABLE,
+                                    param_spec);
+
+    param_spec = g_param_spec_uint64("used",
+                                     "Space used",
+                                     "Space used in the storage domain in bytes",
+                                     0,
+                                     G_MAXUINT64,
+                                     0,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_USED,
+                                    param_spec);
+
+    param_spec = g_param_spec_uint64("committed",
+                                     "Space committed",
+                                     "Space committed in the storage domain in bytes",
+                                     0,
+                                     G_MAXUINT64,
+                                     0,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_COMMITTED,
+                                    param_spec);
+
+    param_spec = g_param_spec_enum("version",
+                                   "Storage Format Version",
+                                   "Storage Format Version of the storage domain",
+                                   OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
+                                   OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V1,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_VERSION,
+                                    param_spec);
+
+    param_spec = g_param_spec_enum("state",
+                                   "Storage Domain State",
+                                   "State of the storage domain",
+                                   OVIRT_TYPE_STORAGE_DOMAIN_STATE,
+                                   OVIRT_STORAGE_DOMAIN_STATE_UNKNOWN,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(object_class,
+                                    PROP_STATE,
+                                    param_spec);
+}
+
+static void ovirt_storage_domain_init(OvirtStorageDomain *domain)
+{
+    domain->priv = OVIRT_STORAGE_DOMAIN_GET_PRIVATE(domain);
+}
diff --git a/govirt/ovirt-storage-domain.h b/govirt/ovirt-storage-domain.h
new file mode 100644
index 0000000..2967f9d
--- /dev/null
+++ b/govirt/ovirt-storage-domain.h
@@ -0,0 +1,85 @@
+/*
+ * ovirt-storage-domain.h: oVirt storage domain resource
+ *
+ * Copyright (C) 2012, 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+#ifndef __OVIRT_STORAGE_DOMAIN_H__
+#define __OVIRT_STORAGE_DOMAIN_H__
+
+#include <gio/gio.h>
+#include <glib-object.h>
+#include <govirt/ovirt-resource.h>
+#include <govirt/ovirt-types.h>
+
+G_BEGIN_DECLS
+
+#define OVIRT_TYPE_STORAGE_DOMAIN            (ovirt_storage_domain_get_type ())
+#define OVIRT_STORAGE_DOMAIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_STORAGE_DOMAIN, 
OvirtStorageDomain))
+#define OVIRT_STORAGE_DOMAIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_STORAGE_DOMAIN, 
OvirtStorageDomainClass))
+#define OVIRT_IS_STORAGE_DOMAIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_STORAGE_DOMAIN))
+#define OVIRT_IS_STORAGE_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_STORAGE_DOMAIN))
+#define OVIRT_STORAGE_DOMAIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_STORAGE_DOMAIN, 
OvirtStorageDomainClass))
+
+typedef enum {
+    OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V1,
+    OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V2,
+    OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V3,
+} OvirtStorageDomainFormatVersion;
+
+typedef enum {
+    OVIRT_STORAGE_DOMAIN_STATE_ACTIVE,
+    OVIRT_STORAGE_DOMAIN_STATE_INACTIVE,
+    OVIRT_STORAGE_DOMAIN_STATE_LOCKED,
+    OVIRT_STORAGE_DOMAIN_STATE_MIXED,
+    OVIRT_STORAGE_DOMAIN_STATE_UNATTACHED,
+    OVIRT_STORAGE_DOMAIN_STATE_MAINTENANCE,
+    OVIRT_STORAGE_DOMAIN_STATE_UNKNOWN,
+} OvirtStorageDomainState;
+
+typedef enum {
+    OVIRT_STORAGE_DOMAIN_TYPE_DATA,
+    OVIRT_STORAGE_DOMAIN_TYPE_ISO,
+    OVIRT_STORAGE_DOMAIN_TYPE_EXPORT,
+} OvirtStorageDomainType;
+
+typedef struct _OvirtStorageDomain OvirtStorageDomain;
+typedef struct _OvirtStorageDomainPrivate OvirtStorageDomainPrivate;
+typedef struct _OvirtStorageDomainClass OvirtStorageDomainClass;
+
+struct _OvirtStorageDomain
+{
+    OvirtResource parent;
+
+    OvirtStorageDomainPrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _OvirtStorageDomainClass
+{
+    OvirtResourceClass parent_class;
+
+    gpointer padding[20];
+};
+
+GType ovirt_storage_domain_get_type(void);
+
+G_END_DECLS
+
+#endif /* __OVIRT_STORAGE_DOMAIN_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]