[Libosinfo] [libosinfo PATCH 08/11] os: Deal with network-install resources

Fabiano Fidêncio fabiano at fidencio.org
Tue Jan 22 19:28:17 UTC 2019


network-install resources represent the resources to be used during a
network installation. It may differs from the minimum resources as the
network installers (not only the medias, but the trees) may download a
huge amount of data to the RAM* consuming way more than the minimum or
recommended RAM for the OS.

*: anaconda downloads the whole stage2 of the installer into the RAM in
order to perform a network installation.

Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
---
 osinfo/libosinfo.syms      |  2 ++
 osinfo/osinfo_os.c         | 60 ++++++++++++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_os.h         |  2 ++
 osinfo/osinfo_os_private.h |  1 +
 4 files changed, 65 insertions(+)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 56cf9a5..2a60689 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -553,9 +553,11 @@ LIBOSINFO_1.3.0 {
 
 	osinfo_os_add_image;
 	osinfo_os_add_maximum_resources;
+	osinfo_os_add_network_install_resources;
 	osinfo_os_get_all_device_links;
 	osinfo_os_get_image_list;
 	osinfo_os_get_maximum_resources;
+	osinfo_os_get_network_install_resources;
 
 	osinfo_tree_has_treeinfo;
 } LIBOSINFO_0.2.13;
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 0e3bb3c..73ad3a3 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -56,6 +56,7 @@ struct _OsinfoOsPrivate
     OsinfoTreeList *trees;
     OsinfoImageList *images;
     OsinfoOsVariantList *variants;
+    OsinfoResourcesList *network_install;
     OsinfoResourcesList *minimum;
     OsinfoResourcesList *recommended;
     OsinfoResourcesList *maximum;
@@ -116,6 +117,7 @@ osinfo_os_finalize(GObject *object)
     g_object_unref(os->priv->trees);
     g_object_unref(os->priv->images);
     g_object_unref(os->priv->variants);
+    g_object_unref(os->priv->network_install);
     g_object_unref(os->priv->minimum);
     g_object_unref(os->priv->recommended);
     g_object_unref(os->priv->maximum);
@@ -183,6 +185,7 @@ osinfo_os_init(OsinfoOs *os)
     os->priv->trees = osinfo_treelist_new();
     os->priv->images = osinfo_imagelist_new();
     os->priv->variants = osinfo_os_variantlist_new();
+    os->priv->network_install = osinfo_resourceslist_new();
     os->priv->minimum = osinfo_resourceslist_new();
     os->priv->recommended = osinfo_resourceslist_new();
     os->priv->maximum = osinfo_resourceslist_new();
@@ -951,6 +954,45 @@ OsinfoResourcesList *osinfo_os_get_recommended_resources(OsinfoOs *os)
 }
 
 /**
+ * osinfo_os_get_network_install_resources_without_inheritance:
+ * @os: an operating system
+ *
+ * Get the list of resources needed for network installing an operating system
+ * @os.
+ *
+ * Mind that this method is *private*!
+ *
+ * Returns: (transfer full): A list of resources
+ */
+OsinfoResourcesList *
+osinfo_os_get_network_install_resources_without_inheritance(OsinfoOs *os)
+{
+    g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+    OsinfoResourcesList *newList = osinfo_resourceslist_new();
+
+    osinfo_list_add_all(OSINFO_LIST(newList),
+                        OSINFO_LIST(os->priv->network_install));
+
+    return newList;
+}
+
+/**
+ * osinfo_os_get_network_install_resources:
+ * @os: an operating system
+ *
+ * Get the list of resources needed for network installing an operating system
+ * @os.
+ *
+ * Returns: (transfer full): A list of resources
+ */
+OsinfoResourcesList *osinfo_os_get_network_install_resources(OsinfoOs *os)
+{
+    return osinfo_os_get_resources_internal
+            (os, osinfo_os_get_network_install_resources_without_inheritance);
+}
+
+/**
  * osinfo_os_add_minimum_resources:
  * @os: an operating system
  * @resources: (transfer none): the resources to add
@@ -1000,6 +1042,24 @@ void osinfo_os_add_maximum_resources(OsinfoOs *os,
 }
 
 /**
+ * osinfo_os_add_network_install_resources:
+ * @os: an operating system
+ * @resources: (transfer none): the resources to add
+ *
+ * Adds @resources to list of resources needed for network installing an
+ * operating system @os.
+ */
+void osinfo_os_add_network_install_resources(OsinfoOs *os,
+                                     OsinfoResources *resources)
+{
+    g_return_if_fail(OSINFO_IS_OS(os));
+    g_return_if_fail(OSINFO_IS_RESOURCES(resources));
+
+    osinfo_list_add(OSINFO_LIST(os->priv->network_install),
+                    OSINFO_ENTITY(resources));
+}
+
+/**
  * osinfo_os_find_install_script:
  * @os:      an operating system
  * @profile: the install script profile that must be either
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index 4eb4b1b..5e677e1 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -123,9 +123,11 @@ OsinfoImageList *osinfo_os_get_image_list(OsinfoOs *os);
 void osinfo_os_add_image(OsinfoOs *os, OsinfoImage *image);
 OsinfoOsVariantList *osinfo_os_get_variant_list(OsinfoOs *os);
 void osinfo_os_add_variant(OsinfoOs *os, OsinfoOsVariant *variant);
+OsinfoResourcesList *osinfo_os_get_network_install_resources(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_minimum_resources(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_recommended_resources(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_maximum_resources(OsinfoOs *os);
+void osinfo_os_add_network_install_resources(OsinfoOs *os, OsinfoResources *resources);
 void osinfo_os_add_minimum_resources(OsinfoOs *os, OsinfoResources *resources);
 void osinfo_os_add_recommended_resources(OsinfoOs *os, OsinfoResources *resources);
 void osinfo_os_add_maximum_resources(OsinfoOs *os, OsinfoResources *resources);
diff --git a/osinfo/osinfo_os_private.h b/osinfo/osinfo_os_private.h
index 3b0e2ce..b4df87d 100644
--- a/osinfo/osinfo_os_private.h
+++ b/osinfo/osinfo_os_private.h
@@ -26,6 +26,7 @@
 #ifndef __OSINFO_OS_PRIVATE_H__
 #define __OSINFO_OS_PRIVATE_H__
 
+OsinfoResourcesList *osinfo_os_get_network_install_resources_without_inheritance(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_minimum_resources_without_inheritance(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_recommended_resources_without_inheritance(OsinfoOs *os);
 OsinfoResourcesList *osinfo_os_get_maximum_resources_without_inheritance(OsinfoOs *os);
-- 
1.8.3.1




More information about the Libosinfo mailing list