diff --git a/convert2rhel/actions/post_conversion/hostmetering.py b/convert2rhel/actions/post_conversion/hostmetering.py index 4602b6a175..58289613cb 100644 --- a/convert2rhel/actions/post_conversion/hostmetering.py +++ b/convert2rhel/actions/post_conversion/hostmetering.py @@ -28,20 +28,16 @@ class ConfigureHostMetering(actions.Action): - """Configure host metering on a machine if it's needed. - - env_var: str - Content of CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable. - """ + """Configure host metering on a machine if it's needed.""" id = "CONFIGURE_HOST_METERING_IF_NEEDED" def run(self): """ - Decide whether to install, enable and start host-metering on the system based on the - CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable. + Decide whether to install, enable and start host-metering on the system based on the setting of + 'configure_host_metering' in /etc/convert2rhel.ini. - Behavior can be controlled CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: + The behavior can be controlled via the 'configure_host_metering' as follows: - "auto": host-metering will be configured based on the above conditions - "force": forces configuration of host-metering (e.g., even if not running on a hyperscaler) - any other value: Will be ignored and host metering will not be configured. @@ -53,7 +49,7 @@ def run(self): super(ConfigureHostMetering, self).run() warn_deprecated_env("CONVERT2RHEL_CONFIGURE_HOST_METERING") - if not self._check_env_var(): + if not self._check_host_metering_configuration(): return False if system_info.version.major != 7 and tool_opts.configure_host_metering == "auto": @@ -62,7 +58,7 @@ def run(self): level="INFO", id="CONFIGURE_HOST_METERING_SKIP", title="Did not perform host metering configuration.", - description="Host metering is supportted only for RHEL 7.", + description="Host metering is supported only for RHEL 7.", ) return False @@ -134,52 +130,58 @@ def run(self): return service_running - def _check_env_var(self): - """Check if the env var is set and if it has the right content. If the - content is auto|force, the hostmetering should be configued on the system. + def _check_host_metering_configuration(self): + """Check if host metering has been configured by the user and if the configuration option has the right value. + If the value is auto|force, the host metering should be configured on the system. :return: Return True if the value is equal to auto|force, otherwise False :rtype: bool """ if tool_opts.configure_host_metering is None: - logger.debug("CONVERT2RHEL_CONFIGURE_HOST_METERING was not set. Skipping it.") + logger.debug("Configuration of host metering has not been enabled. Skipping it.") self.add_message( level="INFO", id="CONFIGURE_HOST_METERING_SKIP", title="Did not perform host metering configuration.", - description="CONVERT2RHEL_CONFIGURE_HOST_METERING was not set.", + description="Configuration of host metering has been skipped.", + diagnosis="We haven't detected 'configure_host_metering' in the convert2rhel.ini config file nor" + " the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", ) return False if tool_opts.configure_host_metering not in ("force", "auto"): - logger.debug("Value for environment variable not recognized: {}".format(tool_opts.configure_host_metering)) + logger.debug("Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" + " CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}" + .format(tool_opts.configure_host_metering)) self.add_message( level="WARNING", id="UNRECOGNIZED_OPTION_CONFIGURE_HOST_METERING", - title="Unrecognized option in CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", - description="Environment variable {env_var} not recognized.".format( - env_var=tool_opts.configure_host_metering - ), - remediations="Set the option to `auto` value if you want to configure host metering.", + title="Unexpected value of the host metering setting.", + diagnosis="Unexpected value of 'configure_host_metering' in convert2rhel.ini or the" + " CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable: {}" + .format(tool_opts.configure_host_metering), + description="Host metering will not be configured.", + remediations="Set the option to 'auto' or 'force' if you want to configure host metering.", ) return False if tool_opts.configure_host_metering == "force": logger.warning( - "The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable." + "You've set the host metering setting to 'force'." " Please note that this option is mainly used for testing and will configure host-metering unconditionally. " " For generic usage please use the 'auto' option." ) self.add_message( level="WARNING", id="FORCED_CONFIGURE_HOST_METERING", - title="The `force' option has been used for the CONVERT2RHEL_CONFIGURE_HOST_METERING environment variable.", + title="Configuration of host metering set to 'force'", description="Please note that this option is mainly used for testing and" " will configure host-metering unconditionally." " For generic usage please use the 'auto' option.", ) elif tool_opts.configure_host_metering == "auto": - logger.debug("Automatic detection of host hyperscaler and configuration.") + logger.debug("Configuration of host metering set to 'auto' - host-metering will be enabled based on" + " a detected hyperscaler.") return True diff --git a/convert2rhel/actions/pre_ponr_changes/backup_system.py b/convert2rhel/actions/pre_ponr_changes/backup_system.py index 97a63f8730..942ba79e68 100644 --- a/convert2rhel/actions/pre_ponr_changes/backup_system.py +++ b/convert2rhel/actions/pre_ponr_changes/backup_system.py @@ -192,7 +192,8 @@ def _get_changed_package_files(self): except IOError as err: warn_deprecated_env("CONVERT2RHEL_INCOMPLETE_ROLLBACK") if tool_opts.incomplete_rollback: - logger.debug("Skipping backup of the package files. CONVERT2RHEL_INCOMPLETE_ROLLBACK detected.") + logger.debug("You have set the incomplete rollback inhibitor override - skipping backup of" + " the package files.") # Return empty list results in no backup of the files return data else: diff --git a/convert2rhel/actions/pre_ponr_changes/kernel_modules.py b/convert2rhel/actions/pre_ponr_changes/kernel_modules.py index d99f884ce0..190bf4f2de 100644 --- a/convert2rhel/actions/pre_ponr_changes/kernel_modules.py +++ b/convert2rhel/actions/pre_ponr_changes/kernel_modules.py @@ -247,21 +247,21 @@ def run(self): rhel_supported_kmods = self._get_rhel_supported_kmods() unsupported_kmods = self._get_unsupported_kmods(host_kmods, rhel_supported_kmods) - # Check if we have the environment variable set, if we do, send a + # Check if the user has specified that they allow unavailable kmods and if so, print a # warning and return. warn_deprecated_env("CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS") if tool_opts.allow_unavailable_kmods: logger.warning( - "Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable." - " We will continue the conversion with the following kernel modules unavailable in RHEL:\n" + "You have set the option to allow unavailable kernel modules." + " The conversion will continue with the following kernel modules unavailable in RHEL:\n" "{kmods}\n".format(kmods="\n".join(unsupported_kmods)) ) self.add_message( level="WARNING", id="ALLOW_UNAVAILABLE_KERNEL_MODULES", - title="Did not perform the ensure kernel modules compatibility check", - description="Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable.", - diagnosis="We will continue the conversion with the following kernel modules unavailable in RHEL:\n" + title="Ignoring the check ensuring kernel module availability in RHEL", + diagnosis="You have set the option to allow unavailable kernel modules.", + description="We will continue the conversion with the following kernel modules unavailable in RHEL:\n" "{kmods}\n".format(kmods="\n".join(unsupported_kmods)), ) return @@ -280,8 +280,8 @@ def run(self): "message persists, you can prevent the modules from loading by following {0} and rerun convert2rhel.\n" "Keeping them loaded could cause the system to malfunction after the conversion as they might not work " "properly with the RHEL kernel.\n" - "To circumvent this check and accept the risk you can set environment variable " - "'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS=1'.".format(LINK_PREVENT_KMODS_FROM_LOADING), + "To circumvent this check and accept the risk, set the allow_unavailable_kmods inhibitor override in the" + "/etc/convert2rhel.ini config file to true.".format(LINK_PREVENT_KMODS_FROM_LOADING), ) return diff --git a/convert2rhel/actions/system_checks/convert2rhel_latest.py b/convert2rhel/actions/system_checks/convert2rhel_latest.py index e6b4c210a7..72e28e5f54 100644 --- a/convert2rhel/actions/system_checks/convert2rhel_latest.py +++ b/convert2rhel/actions/system_checks/convert2rhel_latest.py @@ -179,7 +179,7 @@ def run(self): if tool_opts.allow_older_version: diagnosis = ( "You are currently running {} and the latest version of convert2rhel is {}.\n" - "'CONVERT2RHEL_ALLOW_OLDER_VERSION' environment variable detected, continuing conversion".format( + "You have set the option to allow older convert2rhel version, continuing conversion".format( formatted_convert2rhel_version, formatted_available_version ) ) @@ -224,7 +224,8 @@ def run(self): formatted_convert2rhel_version, formatted_available_version ) ), - remediations="If you want to disregard this check, then set the environment variable 'CONVERT2RHEL_ALLOW_OLDER_VERSION=1' to continue.", + remediations="If you want to disregard this check, set the allow_older_version inhibitor" + " override in the /etc/convert2rhel.ini config file to true.", ) return diff --git a/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py b/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py index 1069029846..bb3a59a71a 100644 --- a/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py +++ b/convert2rhel/actions/system_checks/is_loaded_kernel_latest.py @@ -69,8 +69,7 @@ def run(self): warn_deprecated_env("CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK") if tool_opts.skip_kernel_currency_check: logger.warning( - "Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip " - "the {} comparison.\n" + "You have set the option to skip the kernel currency check - we will skip the {} comparison.\n" "Beware, this could leave your system in a broken state.".format(package_to_check) ) @@ -78,8 +77,10 @@ def run(self): level="WARNING", id="UNSUPPORTED_SKIP_KERNEL_CURRENCY_CHECK_DETECTED", title="Did not perform the kernel currency check", - description=( - "Detected 'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' environment variable, we will skip " + description="Not checking if the loaded kernel is of the latest available version could leave your" + " system in a broken state", + diagnosis=( + "You have set the option to skip the kernel currency check - we will skip " "the {} comparison.\n" "Beware, this could leave your system in a broken state.".format(package_to_check) ), @@ -98,7 +99,7 @@ def run(self): logger.debug("Got the following output: %s", repoquery_output) logger.warning( "Couldn't fetch the list of the most recent kernels available in " - "the repositories. Did not perform the loaded kernel check." + "the repositories. Did not perform the loaded kernel currency check." ) self.add_message( level="WARNING", @@ -106,7 +107,7 @@ def run(self): title="Unable to fetch recent kernels", description=( "Couldn't fetch the list of the most recent kernels available in " - "the repositories. Did not perform the loaded kernel check." + "the repositories. Did not perform the loaded kernel currency check." ), ) return @@ -142,8 +143,8 @@ def run(self): ), remediations=( "Please, check if you have any vendor repositories enabled to proceed with the conversion.\n" - "If you wish to disregard this message, set the environment variable " - "'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1." + "If you wish to disregard this message, set the skip_kernel_currency_check inhibitor override in" + " the /etc/convert2rhel.ini config file to true." ), ) return @@ -184,8 +185,8 @@ def run(self): "To proceed with the conversion, update the kernel version by executing the following step:\n\n" "1. yum install {}-{} -y\n" "2. reboot\n" - "If you wish to ignore this message, set the environment variable " - "'CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK' to 1.".format(package_to_check, latest_kernel) + "If you wish to ignore this message, set the skip_kernel_currency_check inhibitor override in" + " the /etc/convert2rhel.ini config file to true.".format(package_to_check, latest_kernel) ), ) return diff --git a/convert2rhel/actions/system_checks/tainted_kmods.py b/convert2rhel/actions/system_checks/tainted_kmods.py index a289bdf82e..e1a7cc1ee2 100644 --- a/convert2rhel/actions/system_checks/tainted_kmods.py +++ b/convert2rhel/actions/system_checks/tainted_kmods.py @@ -62,12 +62,12 @@ def run(self): remediations=( "Prevent the modules from loading by following {0}" " and run convert2rhel again to continue with the conversion." - " Although it is not recommended, you can disregard this message by setting the environment variable" - " 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' to 1. Overriding this check can be dangerous" + " Although it is not recommended, you can disregard this message by setting the" + " tainted_kernel_module_check_skip inhibitor override in the /etc/convert2rhel.ini" + " config file to true. Overriding this check can be dangerous" " so it is recommended that you do a system backup beforehand." - " For information on what a tainted kernel module is, please refer to this documentation {1}".format( - LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS - ) + " For information on what a tainted kernel module is, please refer to this documentation {1}" + .format(LINK_PREVENT_KMODS_FROM_LOADING, LINK_TAINTED_KMOD_DOCS) ), ) return @@ -76,9 +76,9 @@ def run(self): level="WARNING", id="SKIP_TAINTED_KERNEL_MODULE_CHECK", title="Skip tainted kernel module check", + diagnosis="You have set the option to skip the tainted kernel module check.", description=( - "Detected 'CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP' environment variable, we will skip " - "the tainted kernel module check.\n" + "We will ignore results of the check that makes sure no tainted kernel modules are loaded.\n" "Beware, this could leave your system in a broken state." ), ) diff --git a/convert2rhel/cli.py b/convert2rhel/cli.py index a4e83439ac..2ca3b8bac3 100644 --- a/convert2rhel/cli.py +++ b/convert2rhel/cli.py @@ -133,8 +133,8 @@ def _register_options(self): " stored in log files {} and {}. At the end of the conversion, these logs are compared" " to show you what rpm files have been affected by the conversion." " Cannot be used with analyze subcommand." - " The environment variable CONVERT2RHEL_INCOMPLETE_ROLLBACK" - " needs to be set to 1 to use this argument.".format( + " The incomplete_rollback option needs to be set to true in the /etc/convert2rhel.ini config file to" + " use this argument.".format( utils.rpm.PRE_RPM_VA_LOG_FILENAME, utils.rpm.POST_RPM_VA_LOG_FILENAME ), ) diff --git a/convert2rhel/toolopts/__init__.py b/convert2rhel/toolopts/__init__.py index 14c6854677..c09cbdb8f9 100644 --- a/convert2rhel/toolopts/__init__.py +++ b/convert2rhel/toolopts/__init__.py @@ -99,8 +99,8 @@ def _handle_config_conflict(self, config_sources): message = ( "We need to run the 'rpm -Va' command to be able to perform a complete rollback of changes" " done to the system during the pre-conversion analysis. If you accept the risk of an" - " incomplete rollback, set the CONVERT2RHEL_INCOMPLETE_ROLLBACK=1 environment" - " variable. Otherwise, remove the --no-rpm-va option." + " incomplete rollback, set the incomplete_rollback option to true in the /etc/convert2rhel.ini" + " config file. Otherwise, remove the --no-rpm-va option." ) loggerinst.critical(message)