Skip to content

Commit

Permalink
Simplify loading migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 17, 2018
1 parent 7ed5e87 commit 35855ec
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions src/lib/registration/ui/migration_repos_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ def run_sequence
log.info "Starting migration repositories sequence"

aliases = {
"registration_check" => [->() { registration_check }, true],
"not_installed_products_check" => [->() { not_installed_products_check }, true],
"find_products" => [->() { find_products }, true],
"load_migration_products" => [->() { load_migration_products }, true],
"load_migration_products_offline" => [->() { load_migration_products_offline }, true],
"select_migration_products" => ->() { select_migration_products },
"update_releasever" => ->() { update_releasever },
"register_migration_products" => [->() { register_migration_products }, true],
"activate_migration_repos" => [->() { activate_migration_repos }, true],
"select_migration_repos" => ->() { select_migration_repos },
"store_repos_state" => ->() { store_repos_state }
"registration_check" => [->() { registration_check }, true],
"not_installed_products_check" => [->() { not_installed_products_check }, true],
"find_products" => [->() { find_products }, true],
"load_migration_products" => [->() { load_migration_products }, true],
"select_migration_products" => ->() { select_migration_products },
"update_releasever" => ->() { update_releasever },
"register_migration_products" => [->() { register_migration_products }, true],
"activate_migration_repos" => [->() { activate_migration_repos }, true],
"select_migration_repos" => ->() { select_migration_repos },
"store_repos_state" => ->() { store_repos_state }
}

ui = Yast::Sequencer.Run(aliases, WORKFLOW_SEQUENCE)
Expand All @@ -96,57 +95,52 @@ def run_sequence
:manual_repo_selection

WORKFLOW_SEQUENCE = {
"ws_start" => "registration_check",
"registration_check" => {
"ws_start" => "registration_check",
"registration_check" => {
abort: :abort,
skip: :next,
next: "not_installed_products_check"
},
"not_installed_products_check" => {
"not_installed_products_check" => {
abort: :abort,
cancel: :abort,
next: "find_products"
},
"find_products" => {
"find_products" => {
abort: :abort,
cancel: :abort,
next: "load_migration_products"
},
"load_migration_products" => {
abort: :abort,
cancel: :abort,
next: "load_migration_products_offline"
},
"load_migration_products_offline" => {
"load_migration_products" => {
abort: :abort,
cancel: :abort,
next: "select_migration_products"
},
"select_migration_products" => {
"select_migration_products" => {
abort: :abort,
cancel: :abort,
next: "update_releasever"
},
"update_releasever" => {
"update_releasever" => {
next: "register_migration_products"
},
"register_migration_products" => {
"register_migration_products" => {
abort: :rollback,
cancel: :rollback,
next: "activate_migration_repos"
},
"activate_migration_repos" => {
"activate_migration_repos" => {
abort: :rollback,
cancel: :rollback,
repo_selection: "select_migration_repos",
next: "store_repos_state"
},
"select_migration_repos" => {
"select_migration_repos" => {
abort: :rollback,
cancel: :rollback,
next: "store_repos_state"
},
"store_repos_state" => {
"store_repos_state" => {
next: :next
}
}.freeze
Expand Down Expand Up @@ -246,11 +240,21 @@ def merge_registered_addons
products.concat(addons)
end

# load migration products for the installed products from the registration server
# load migration products for the installed products from the registration server,
# loads online or offline migrations depending on the system state
# @return [Symbol] workflow symbol (:next or :abort)
def load_migration_products
return :next if Yast::Stage.initial && Yast::Mode.update
if Yast::Stage.initial && Yast::Mode.update
load_migration_products_offline
else
load_migration_products_online
end
end

# load migration products for the installed products from the registration server
# for the currently running system (online migration)
# @return [Symbol] workflow symbol (:next or :abort)
def load_migration_products_online
log.info "Loading migration products from server"
self.migrations = registration_ui.migration_products(products)

Expand All @@ -264,11 +268,10 @@ def load_migration_products
end

# load migration products for the installed products from the registration server
# on a system that is not running (offline)
# on a system that is not running (offline migration)
# @return [Symbol] workflow symbol (:next or :abort)
def load_migration_products_offline
return :next unless Yast::Stage.initial && Yast::Mode.update

# FIXME: read the correct product from the medium
base_product = { "identifier" => "SLES", "version" => "15", "arch" => "x86_64" }

log.info "Loading migration products from server on an offline sytem"
Expand Down

0 comments on commit 35855ec

Please sign in to comment.