Skip to content
Permalink
Browse files

Initial support for AY autoupgrade

  • Loading branch information...
lslezak committed Apr 9, 2018
1 parent 361bda5 commit 9a453669dae5a9388920d46f7490f43aefd46d2a
Showing with 37 additions and 37 deletions.
  1. +5 −27 src/clients/scc_auto.rb
  2. +32 −10 src/lib/registration/ui/migration_repos_workflow.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

@@ -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,9 +259,11 @@ 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))
result << SwMgmt.remote_product(addon.to_h)
end
next unless Yast::Mode.auto || Yast::Popup.YesNoHeadline(
addon.friendly_name, (msg % addon.friendly_name)
)

result << SwMgmt.remote_product(addon.to_h)
end

products.concat(addons)
@@ -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

0 comments on commit 9a45366

Please sign in to comment.
You can’t perform that action at this time.