From 19ef2522870cff88c62530069f2330a267ef702a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Mon, 9 Apr 2018 17:44:33 +0200 Subject: [PATCH] Initial support for AY autoupgrade --- src/clients/scc_auto.rb | 32 +++------------- .../ui/migration_repos_workflow.rb | 38 +++++++++++++++---- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/clients/scc_auto.rb b/src/clients/scc_auto.rb index 5b156e885..39541ec76 100644 --- a/src/clients/scc_auto.rb +++ b/src/clients/scc_auto.rb @@ -187,9 +187,10 @@ def write # update the registration in AutoUpgrade mode if the old system was registered if Mode.update && old_system_registered? - updated = update_registration - log.info "Registration updated: #{updated}" - return updated + # FIXME: pass the AY config somehow... + ret = Yast::WFM.CallFunction("offline_migration_workflow") + log.info "Migration result: #{ret}" + return ret == :next end ret = ::Registration::ConnectHelpers.catch_registration_errors do @@ -298,10 +299,8 @@ def registration_ui # update the registration (system, the base product, the installed extensions) def update_registration return false unless update_system_registration - return false unless update_base_product - return false unless update_addons - # register additional addons (e.g. originally not present in SLE11) + # register additional addons (e.g. originally not present in SLE11/SLE12) register_addons end @@ -340,18 +339,6 @@ def old_system_registered? File.exist?(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE) end - # update the system registration - # @return [Boolean] true on success - def update_system_registration - registration_ui.update_system - end - - # update the base product registration - # @return [Boolean] true on success - def update_base_product - handle_product_service { registration_ui.update_base_product } - end - # @yieldreturn [Boolean, SUSE::Connect::Remote::Product] success flag and # remote product pair # @return [Boolean] true on success @@ -364,15 +351,6 @@ def handle_product_service(&block) registration_ui.disable_update_repos(product_service) end - - # @return [Boolean] true on success - # FIXME: share with inst_scc.rb - def update_addons - addons = registration_ui.get_available_addons - - failed_addons = registration_ui.update_addons(addons, enable_updates: @config.install_updates) - failed_addons.empty? - end end unless defined?(SccAutoClient) end diff --git a/src/lib/registration/ui/migration_repos_workflow.rb b/src/lib/registration/ui/migration_repos_workflow.rb index 5f43a443a..8f8d0dc3d 100644 --- a/src/lib/registration/ui/migration_repos_workflow.rb +++ b/src/lib/registration/ui/migration_repos_workflow.rb @@ -41,13 +41,15 @@ class MigrationReposWorkflow < WizardClient Yast.import "Installation" # the constructor - def initialize + def initialize(config = {}) textdomain "registration" url = UrlHelpers.registration_url self.registration = Registration.new(url) self.registration_ui = RegistrationUI.new(registration) self.registered_services = [] + + self.ay_config = config end # The repositories migration workflow is: @@ -95,7 +97,7 @@ def run_sequence private - attr_accessor :products, :migrations, :registration, + attr_accessor :ay_config, :products, :migrations, :registration, :registration_ui, :selected_migration, :registered_services, :manual_repo_selection @@ -159,9 +161,16 @@ def run_sequence # @return [Symbol] workflow symbol, :next if registered, :abort when not def registration_check # handle system upgrade (fate#323163) - if Yast::Stage.initial && Yast::Mode.update - log.info "System upgrade mode detected" - return system_upgrade_check + if Yast::Stage.initial + # test autoupgrade first, Mode.update covers the autoupgrade as well + if Yast::Mode.autoupgrade + return Registration.is_registered? ? :next : :skip + end + + if Yast::Mode.update + log.info "System upgrade mode detected" + return system_upgrade_check + end end return :next if Registration.is_registered? @@ -250,7 +259,9 @@ def merge_registered_addons addons = Addon.registered_not_installed.each_with_object([]) do |addon, result| - if Yast::Popup.YesNoHeadline(addon.friendly_name, (msg % addon.friendly_name)) + if Yast::Mode.auto || Yast::Popup.YesNoHeadline(addon.friendly_name, + (msg % addon.friendly_name)) + result << SwMgmt.remote_product(addon.to_h) end end @@ -318,7 +329,7 @@ def load_migration_products_offline(activations) if migrations.empty? # TRANSLATORS: Error message Yast::Report.Error(_("No migration product found.")) - return :empty + return Yast::Mode.auto ? :abort : :empty end :next @@ -354,6 +365,15 @@ def migration_confirmed?(base_product, activations) # run the migration target selection dialog # @return [Symbol] workflow symbol (:next or :abort) def select_migration_products + if Yast::Mode.auto + self.selected_migration = migrations.first + self.manual_repo_selection = false + log.warn "More than one migration available, usign the first one" if migrations.size > 1 + log.info "Selected migration: #{selected_migration}" + + return :next + end + log.info "Displaying migration target selection dialog" dialog = MigrationSelectionDialog.new(migrations, SwMgmt.installed_products) ret = dialog.run @@ -455,7 +475,9 @@ def activate_migration_repos migration_repos.services << service end - if migration_repos.service_with_update_repo? + if Yast::Mode.auto + migration_repos.install_updates = ay_config.install_updates + elsif migration_repos.service_with_update_repo? migration_repos.install_updates = registration_ui.install_updates? end