diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 219e094..3e2f5d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,9 +31,12 @@ repos: ] - id: sync-scripts-to-yaml name: sync-scripts-to-yaml - entry: python misc/sync_scripts_to_yaml.py + entry: python misc/sync_scripts.py + additional_dependencies: [ruamel.yaml==0.16.13] args: ["--target", "repo"] language: python + types: [python] + pass_filenames: false files: scripts/.*\.py$ diff --git a/playbooks/leapp_preupgrade_script.yaml b/playbooks/leapp_preupgrade_script.yaml index 9666228..53c7641 100644 --- a/playbooks/leapp_preupgrade_script.yaml +++ b/playbooks/leapp_preupgrade_script.yaml @@ -227,7 +227,7 @@ def setup_leapp(version): leapp_install_command, rhel_rhui_packages = _get_leapp_command_and_packages(version) - if _check_if_package_installed('leapp-upgrade'): + if _check_if_package_installed("leapp-upgrade"): print("'leapp-upgrade' already installed, skipping ...") else: print("Installing leapp ...") @@ -352,7 +352,11 @@ ) ) if reboot_required: - message += " System is ready to be upgraded. Rebooting system in 1 minute." + problem_info = message.lstrip("Your system has ").rstrip(".") + message = ( + "System will be upgraded (%s). Rebooting system in 1 minute." + % problem_info + ) alert = inhibitor_count > 0 or error_count > 0 status = ( _find_highest_report_level(report_entries) @@ -425,11 +429,11 @@ remove_previous_reports() leapp_output = execute_operation(operation_command) - reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output - parse_results(output, reboot_required) + upgrade_reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output + parse_results(output, upgrade_reboot_required) update_insights_inventory(output) print("Operation {} finished successfully.".format(SCRIPT_TYPE.title())) - if reboot_required: + if upgrade_reboot_required: reboot_system() except ProcessError as exception: print(exception.report) diff --git a/playbooks/leapp_upgrade_script.yaml b/playbooks/leapp_upgrade_script.yaml index c0dd9ff..9a36f8e 100644 --- a/playbooks/leapp_upgrade_script.yaml +++ b/playbooks/leapp_upgrade_script.yaml @@ -227,7 +227,7 @@ def setup_leapp(version): leapp_install_command, rhel_rhui_packages = _get_leapp_command_and_packages(version) - if _check_if_package_installed('leapp-upgrade'): + if _check_if_package_installed("leapp-upgrade"): print("'leapp-upgrade' already installed, skipping ...") else: print("Installing leapp ...") @@ -352,7 +352,11 @@ ) ) if reboot_required: - message += " System is ready to be upgraded. Rebooting system in 1 minute." + problem_info = message.lstrip("Your system has ").rstrip(".") + message = ( + "System will be upgraded (%s). Rebooting system in 1 minute." + % problem_info + ) alert = inhibitor_count > 0 or error_count > 0 status = ( _find_highest_report_level(report_entries) @@ -425,11 +429,11 @@ remove_previous_reports() leapp_output = execute_operation(operation_command) - reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output - parse_results(output, reboot_required) + upgrade_reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output + parse_results(output, upgrade_reboot_required) update_insights_inventory(output) print("Operation {} finished successfully.".format(SCRIPT_TYPE.title())) - if reboot_required: + if upgrade_reboot_required: reboot_system() except ProcessError as exception: print(exception.report) diff --git a/scripts/leapp_script.py b/scripts/leapp_script.py index 0925b99..b253580 100644 --- a/scripts/leapp_script.py +++ b/scripts/leapp_script.py @@ -220,7 +220,7 @@ def _get_leapp_command_and_packages(version): def setup_leapp(version): leapp_install_command, rhel_rhui_packages = _get_leapp_command_and_packages(version) - if _check_if_package_installed('leapp-upgrade'): + if _check_if_package_installed("leapp-upgrade"): print("'leapp-upgrade' already installed, skipping ...") else: print("Installing leapp ...") @@ -345,7 +345,11 @@ def parse_results(output, reboot_required=False): ) ) if reboot_required: - message += " System is ready to be upgraded. Rebooting system in 1 minute." + problem_info = message.lstrip("Your system has ").rstrip(".") + message = ( + "System will be upgraded (%s). Rebooting system in 1 minute." + % problem_info + ) alert = inhibitor_count > 0 or error_count > 0 status = ( _find_highest_report_level(report_entries) @@ -418,11 +422,11 @@ def main(): remove_previous_reports() leapp_output = execute_operation(operation_command) - reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output - parse_results(output, reboot_required) + upgrade_reboot_required = REBOOT_GUIDANCE_MESSAGE in leapp_output + parse_results(output, upgrade_reboot_required) update_insights_inventory(output) print("Operation {} finished successfully.".format(SCRIPT_TYPE.title())) - if reboot_required: + if upgrade_reboot_required: reboot_system() except ProcessError as exception: print(exception.report) diff --git a/tests/test_parse_results.py b/tests/test_parse_results.py index 8cc3e63..a5fee98 100644 --- a/tests/test_parse_results.py +++ b/tests/test_parse_results.py @@ -51,7 +51,7 @@ def test_gather_report_files_exist_with_reboot(mock_find_level, mock_exists): assert output.report_json.get("test") == "hi" assert ( output.message - == "Your system has 0 errors and 0 inhibitors out of 0 potential problems. System is ready to be upgraded. Rebooting system in 1 minute." + == "System will be upgraded (0 errors and 0 inhibitors out of 0 potential problems). Rebooting system in 1 minute." )