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

[libvirt] [libvirt-glib 2/4] gconfig: Add GVirConfigStoragePoolSource getters



---
 .../libvirt-gconfig-storage-pool-source.c          | 132 +++++++++++++++++++++
 .../libvirt-gconfig-storage-pool-source.h          |   8 ++
 libvirt-gconfig/libvirt-gconfig.sym                |   9 ++
 libvirt-gconfig/tests/test-domain-create.c         |   3 +
 4 files changed, 152 insertions(+)

diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
index e3967ad..ad8b28d 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
@@ -71,6 +71,22 @@ GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new_from_xml(const
     return GVIR_CONFIG_STORAGE_POOL_SOURCE(object);
 }
 
+/**
+ * gvir_config_storage_pool_source_get_adapter:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * For pools backed by a SCSI adapter, returns the SCSI adapter name
+ *
+ * Returns: the SCSI adapter name.
+ */
+const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "adapter",
+                                            "name");
+}
+
 void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source,
                                                  const char *adapter)
 {
@@ -84,6 +100,23 @@ void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *so
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_get_device_path:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * For pools backed by a physical device, returns the path to the block
+ * device node
+ *
+ * Returns: fully qualified path to the block device node.
+ */
+const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "device",
+                                            "path");
+}
+
 void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source,
                                                      const char *device_path)
 {
@@ -97,6 +130,22 @@ void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_get_directory:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * For pools backed by a directory, returns the path to the backing directory
+ *
+ * Returns: path to the directory backing directory.
+ */
+const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "directory",
+                                            "path");
+}
+
 void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source,
                                                    const char *directory)
 {
@@ -110,6 +159,24 @@ void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_get_format:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * Provides information about the format of the pool. This format is
+ * backend-specific but is typically used to indicate filesystem type, or
+ * network filesystem type, or partition table type, or LVM metadata type.
+ *
+ * Returns: the storage pool format.
+ */
+const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "format",
+                                            "type");
+}
+
 void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source,
                                                 const char *format)
 {
@@ -123,6 +190,23 @@ void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *sou
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_get_host:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * For pools backed by storage from remote server, returns the hostname
+ * of the remote server.
+ *
+ * Returns: hostname or IP address of the remote server.
+ */
+const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "host",
+                                            "name");
+}
+
 void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *source,
                                               const char *host)
 {
@@ -137,6 +221,22 @@ void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *sourc
 }
 
 /**
+ * gvir_config_storage_pool_source_get_name:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * For pools backed by storage from a named element (for example, LV
+ * groups), returns the name of the element
+ *
+ * Returns: name of the element used by @source
+ */
+const char *gvir_config_storage_pool_source_get_name(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(source),
+                                               "name");
+}
+
+/**
  * gvir_config_storage_pool_source_set_name:
  * @name: (allow-none):
  */
@@ -149,6 +249,22 @@ void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *sourc
                                         "name", name);
 }
 
+/**
+ * gvir_config_storage_pool_source_get_product:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * Gets the product name of the storage device.
+ *
+ * Returns: product name of the storage device.
+ */
+const char *gvir_config_storage_pool_source_get_product(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "product",
+                                            "name");
+}
+
 void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *source,
                                                  const char *product)
 {
@@ -162,6 +278,22 @@ void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *so
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_get_vendor:
+ * @source: a #GVirConfigStoragePoolSource
+ *
+ * Gets the vendor name of the storage device.
+ *
+ * Returns: vendor name of the storage device.
+ */
+const char *gvir_config_storage_pool_source_get_vendor(GVirConfigStoragePoolSource *source)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
+                                            "vendor",
+                                            "name");
+}
+
 void gvir_config_storage_pool_source_set_vendor(GVirConfigStoragePoolSource *source,
                                                 const char *vendor)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h
index 8ecaae3..d0056fc 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h
@@ -63,20 +63,28 @@ GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new(void);
 GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new_from_xml(const gchar *xml,
                                                                           GError **error);
 
+const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source,
                                                  const char *adapter);
+const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source,
                                                      const char *device_path);
+const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source,
                                                    const char *directory);
+const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source,
                                                 const char *format);
+const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *source,
                                               const char *host);
+const char *gvir_config_storage_pool_source_get_name(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *source,
                                               const char *name);
+const char *gvir_config_storage_pool_source_get_product(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *source,
                                                  const char *product);
+const char *gvir_config_storage_pool_source_get_vendor(GVirConfigStoragePoolSource *source);
 void gvir_config_storage_pool_source_set_vendor(GVirConfigStoragePoolSource *source,
                                                 const char *vendor);
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 93b2e33..49072dd 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -522,6 +522,15 @@ LIBVIRT_GCONFIG_0.1.7 {
 	gvir_config_storage_pool_get_source;
 	gvir_config_storage_pool_get_target;
 	gvir_config_storage_pool_get_uuid;
+
+	gvir_config_storage_pool_source_get_adapter;
+	gvir_config_storage_pool_source_get_device_path;
+	gvir_config_storage_pool_source_get_directory;
+	gvir_config_storage_pool_source_get_format;
+	gvir_config_storage_pool_source_get_host;
+	gvir_config_storage_pool_source_get_name;
+	gvir_config_storage_pool_source_get_product;
+	gvir_config_storage_pool_source_get_vendor;
 } LIBVIRT_GCONFIG_0.1.6;
 
 # .... define new API here using predicted next version number ....
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index e30f643..f7cb076 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -405,6 +405,9 @@ int main(int argc, char **argv)
     gvir_config_storage_pool_source_set_directory(pool_source, "/foo/bar");
     gvir_config_storage_pool_set_source(pool, pool_source);
     g_object_unref(G_OBJECT(pool_source));
+    pool_source = gvir_config_storage_pool_get_source(pool);
+    g_str_const_check(gvir_config_storage_pool_source_get_directory(pool_source), "/foo/bar");
+    g_object_unref(G_OBJECT(pool_source));
 
     perms = gvir_config_storage_permissions_new();
     gvir_config_storage_permissions_set_owner(perms, 1001);
-- 
1.8.1.4


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