[Libosinfo] [libosinfo PATCH 3/7] install-script: Add _(get|set)_preferred_injection_method()
Fabiano Fidêncio
fidencio at redhat.com
Mon Dec 3 09:11:48 UTC 2018
Those new methods are going to be used to tell the install-scripts
whether the injection-method that's going to be used is. We have to do
so as the command-line may be different depending on the
injection-method used, for example:
- fedora using cdrom, disk or floppy: ks=hd:/(vda|sda)/fedora.ks
- fedora using initrd: ks=file:/fedora.ks
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
osinfo/libosinfo.syms | 3 ++
osinfo/osinfo_install_script.c | 79 ++++++++++++++++++++++++++++++++++
osinfo/osinfo_install_script.h | 4 ++
3 files changed, 86 insertions(+)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 365914c..26298df 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -536,6 +536,9 @@ LIBOSINFO_1.3.0 {
osinfo_error_quark;
+ osinfo_install_script_get_preferred_injection_method;
+ osinfo_install_script_set_preferred_injection_method;
+
osinfo_os_add_maximum_resources;
osinfo_os_get_all_device_links;
osinfo_os_get_maximum_resources;
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 016f850..10cb5f3 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -64,6 +64,7 @@ enum {
PROP_PRODUCT_KEY_FORMAT,
PROP_PATH_FORMAT,
PROP_AVATAR_FORMAT,
+ PROP_PREFERRED_INJECTION_METHOD
};
typedef struct _OsinfoInstallScriptGenerateData OsinfoInstallScriptGenerateData;
@@ -105,6 +106,11 @@ osinfo_install_script_set_property(GObject *object,
data);
break;
+ case PROP_PREFERRED_INJECTION_METHOD:
+ osinfo_install_script_set_preferred_injection_method(script,
+ g_value_get_flags(value));
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -151,6 +157,11 @@ osinfo_install_script_get_property(GObject *object,
osinfo_install_script_get_avatar_format(script));
break;
+ case PROP_PREFERRED_INJECTION_METHOD:
+ g_value_set_flags(value,
+ osinfo_install_script_get_preferred_injection_method(script));
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -254,6 +265,17 @@ osinfo_install_script_class_init(OsinfoInstallScriptClass *klass)
PROP_AVATAR_FORMAT,
pspec);
+ pspec = g_param_spec_flags("preferred-injection-method",
+ "Preferred Injection Method",
+ _("The preferred injection method"),
+ OSINFO_TYPE_INSTALL_SCRIPT_INJECTION_METHOD,
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK, /* default value */
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property(g_klass,
+ PROP_PREFERRED_INJECTION_METHOD,
+ pspec);
+
g_type_class_add_private(klass, sizeof(OsinfoInstallScriptPrivate));
}
@@ -1765,6 +1787,63 @@ gboolean osinfo_install_script_get_needs_internet(OsinfoInstallScript *script)
FALSE);
}
+/**
+ * osinfo_install_script_set_preferred_injection_method:
+ * @script: the install script
+ * @method: one of the injection methods:
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_CDROM,
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK,
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_FLOPPY,
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_INITRD,
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_WEB
+ *
+ * Set the preferred injection method to be used with the @script
+ */
+void osinfo_install_script_set_preferred_injection_method(OsinfoInstallScript *script,
+ OsinfoInstallScriptInjectionMethod method)
+{
+ unsigned int supported_methods;
+
+ supported_methods = osinfo_install_script_get_injection_methods(script);
+ if ((method & supported_methods) == 0) {
+ g_warning("The injection-method passed is not supported by the install-script");
+ return;
+ }
+
+ osinfo_entity_set_param_flags
+ (OSINFO_ENTITY(script),
+ OSINFO_INSTALL_SCRIPT_PROP_PREFERRED_INJECTION_METHOD,
+ method,
+ OSINFO_TYPE_INSTALL_SCRIPT_INJECTION_METHOD);
+}
+
+/**
+ * osinfo_install_script_get_preferred_injection_method:
+ * @script: the install script
+ *
+ * Returns: the preferred injection method for the script. If none is set and
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK is supported,
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK is returned, otherwise
+ * OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_INITRD is returned.
+ */
+OsinfoInstallScriptInjectionMethod
+osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script)
+{
+ unsigned int supported_methods;
+ OsinfoInstallScriptInjectionMethod default_preferred;
+ supported_methods = osinfo_install_script_get_injection_methods(script);
+
+ if ((OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK & supported_methods) != 0)
+ default_preferred = OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK;
+ else
+ default_preferred = OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_INITRD;
+
+ return osinfo_entity_get_param_value_flags
+ (OSINFO_ENTITY(script),
+ OSINFO_INSTALL_SCRIPT_PROP_PREFERRED_INJECTION_METHOD,
+ OSINFO_TYPE_INSTALL_SCRIPT_INJECTION_METHOD,
+ default_preferred);
+}
/*
* Local variables:
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index e07ab5e..ed634db 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -60,6 +60,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
#define OSINFO_INSTALL_SCRIPT_PROP_PRE_INSTALL_DRIVERS_SIGNING_REQ "pre-install-drivers-signing-req"
#define OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ "post-install-drivers-signing-req"
#define OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD "injection-method"
+#define OSINFO_INSTALL_SCRIPT_PROP_PREFERRED_INJECTION_METHOD "preferred-injection-method"
/* object */
struct _OsinfoInstallScript
@@ -255,6 +256,9 @@ unsigned int osinfo_install_script_get_injection_methods(OsinfoInstallScript *sc
gboolean osinfo_install_script_get_needs_internet(OsinfoInstallScript *script);
+void osinfo_install_script_set_preferred_injection_method(OsinfoInstallScript *script,
+ OsinfoInstallScriptInjectionMethod method);
+OsinfoInstallScriptInjectionMethod osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script);
#endif /* __OSINFO_INSTALL_SCRIPT_H__ */
/*
* Local variables:
--
2.19.1
More information about the Libosinfo
mailing list