Blame SOURCES/0002-ovirt-storage-domain-Introduce-ovirt_storage_domain_.patch

68850c
From 8ab1be89c70d0f6454e74442d382b9ea55f1df58 Mon Sep 17 00:00:00 2001
68850c
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
68850c
Date: Tue, 16 Jun 2020 10:07:49 -0300
68850c
Subject: [PATCH] ovirt-storage-domain: Introduce
68850c
 ovirt_storage_domain_get_disks()
68850c
68850c
This function is used to return the list of disks in a given storage
68850c
domain with DATA type.
68850c
68850c
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
68850c
---
68850c
 govirt/govirt.sym             |  2 ++
68850c
 govirt/ovirt-storage-domain.c | 28 ++++++++++++++++++++++++++++
68850c
 govirt/ovirt-storage-domain.h |  1 +
68850c
 3 files changed, 31 insertions(+)
68850c
68850c
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
68850c
index 1cc2a8e..4cd6bb8 100644
68850c
--- a/govirt/govirt.sym
68850c
+++ b/govirt/govirt.sym
68850c
@@ -146,5 +146,7 @@ GOVIRT_0.4.1 {
68850c
         ovirt_disk_get_type;
68850c
         ovirt_disk_content_type_get_type;
68850c
         ovirt_disk_new;
68850c
+
68850c
+        ovirt_storage_domain_get_disks;
68850c
 } GOVIRT_0.4.0;
68850c
 # .... define new API here using predicted next version number ....
68850c
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
68850c
index a713d89..d02c3d5 100644
68850c
--- a/govirt/ovirt-storage-domain.c
68850c
+++ b/govirt/ovirt-storage-domain.c
68850c
@@ -27,6 +27,7 @@
68850c
 
68850c
 struct _OvirtStorageDomainPrivate {
68850c
     OvirtCollection *files;
68850c
+    OvirtCollection *disks;
68850c
     GStrv data_center_ids;
68850c
 
68850c
     gchar *data_center_href;
68850c
@@ -172,6 +173,7 @@ ovirt_storage_domain_dispose(GObject *obj)
68850c
     OvirtStorageDomain *domain = OVIRT_STORAGE_DOMAIN(obj);
68850c
 
68850c
     g_clear_object(&domain->priv->files);
68850c
+    g_clear_object(&domain->priv->disks);
68850c
     g_clear_pointer(&domain->priv->data_center_ids, g_strfreev);
68850c
     g_clear_pointer(&domain->priv->data_center_href, g_free);
68850c
     g_clear_pointer(&domain->priv->data_center_id, g_free);
68850c
@@ -399,3 +401,29 @@ OvirtCollection *ovirt_storage_domain_get_files(OvirtStorageDomain *domain)
68850c
 
68850c
     return domain->priv->files;
68850c
 }
68850c
+
68850c
+/**
68850c
+ * ovirt_storage_domain_get_disks:
68850c
+ * @domain: a #OvirtStorageDomain
68850c
+ *
68850c
+ * Gets a #OvirtCollection representing the list of remote disks from a
68850c
+ * storage domain object.  This method does not initiate any network
68850c
+ * activity, the remote file list must be then be fetched using
68850c
+ * ovirt_collection_fetch() or ovirt_collection_fetch_async().
68850c
+ *
68850c
+ * Return value: (transfer none): a #OvirtCollection representing the list
68850c
+ * of disks associated with @domain.
68850c
+ */
68850c
+OvirtCollection *ovirt_storage_domain_get_disks(OvirtStorageDomain *domain)
68850c
+{
68850c
+    g_return_val_if_fail(OVIRT_IS_STORAGE_DOMAIN(domain), NULL);
68850c
+
68850c
+    if (domain->priv->disks == NULL)
68850c
+        domain->priv->disks = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(domain),
68850c
+                                                                     "disks",
68850c
+                                                                     "disks",
68850c
+                                                                     OVIRT_TYPE_DISK,
68850c
+                                                                     "disk");
68850c
+
68850c
+    return domain->priv->disks;
68850c
+}
68850c
diff --git a/govirt/ovirt-storage-domain.h b/govirt/ovirt-storage-domain.h
68850c
index f122e27..97cfb06 100644
68850c
--- a/govirt/ovirt-storage-domain.h
68850c
+++ b/govirt/ovirt-storage-domain.h
68850c
@@ -86,6 +86,7 @@ GType ovirt_storage_domain_get_type(void);
68850c
 OvirtStorageDomain *ovirt_storage_domain_new(void);
68850c
 
68850c
 OvirtCollection *ovirt_storage_domain_get_files(OvirtStorageDomain *domain);
68850c
+OvirtCollection *ovirt_storage_domain_get_disks(OvirtStorageDomain *domain);
68850c
 
68850c
 G_END_DECLS
68850c
 
68850c
-- 
68850c
2.26.2
68850c