Let's try to guess the timezone from '/etc/localtime' and use it, if possible. Otherwise, let's just let it be and libosinfo will use the default 'America/New_York' one. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- virtinst/osdict.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index 53e03020..0408e232 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -13,7 +13,7 @@ import re import gi gi.require_version('Libosinfo', '1.0') from gi.repository import Libosinfo as libosinfo -from gi.repository import GLib as glib +from gi.repository import GLib as glib, Gio as gio ################### @@ -554,6 +554,24 @@ class _OsVariant(object): def requires_admin_password(script): return requires_param(libosinfo.INSTALL_CONFIG_PROP_ADMIN_PASSWORD) + def get_timezone(): + TZ_FILE = "/etc/localtime" + localtime = gio.File.new_for_path(TZ_FILE) + if not localtime.query_exists(): + return None + info = localtime.query_info( + gio.FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, + gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS) + if not info: + return None + target = info.get_symlink_target() + if not target: + return None + tokens = target.split("zoneinfo/") + if not tokens or len(tokens) < 2: + return None + return tokens[1] + config = libosinfo.InstallConfig() # Set user login and name based on the one from the system @@ -593,6 +611,16 @@ class _OsVariant(object): config.set_hardware_arch(arch) config.set_hostname(hostname) + # Try to guess the timezone from '/etc/localtime', in case it's not + # possible 'America/New_York' will be used. + timezone = get_timezone() + if timezone: + config.set_l10n_timezone(timezone) + else: + logging.warning( + _("'America/New_York' timezone will be used for this " + "unattended installation.")) + logging.debug("InstallScriptConfig created with the following params:") logging.debug("username: %s", config.get_user_login()) logging.debug("realname: %s", config.get_user_realname()) @@ -601,6 +629,7 @@ class _OsVariant(object): logging.debug("target disk: %s", config.get_target_disk()) logging.debug("hardware arch: %s", config.get_hardware_arch()) logging.debug("hostname: %s", config.get_hostname()) + logging.debug("timezone: %s", config.get_l10n_timezone()) return config -- 2.20.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list