Skip to content

Commit

Permalink
Initial support for AY autoupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 12, 2018
1 parent 361bda5 commit 19ef252
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
32 changes: 5 additions & 27 deletions src/clients/scc_auto.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
38 changes: 30 additions & 8 deletions src/lib/registration/ui/migration_repos_workflow.rb
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 19ef252

Please sign in to comment.