Skip to content

Commit

Permalink
send also the registered, but not installed addons
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Oct 12, 2015
1 parent 5f50f3e commit 9fbdd11
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/lib/registration/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#

require "forwardable"
require "registration/sw_mgmt"

module Registration
class Addon
Expand Down Expand Up @@ -50,6 +51,16 @@ def selected
@selected ||= []
end

def registered_not_installed
registered.select do |addon|
!SwMgmt.installed_products.find do |product|
product["name"] == addon.identifier &&
product["version_version"] == addon.version &&
product["arch"] == addon.arch
end
end
end

private

def create_addon_with_deps(root)
Expand Down
40 changes: 32 additions & 8 deletions src/lib/registration/ui/migration_repos_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ def initialize
# The repositories migration workflow is:
#
# - find all installed products
# - TODO: add the registered products
# - query registered addons from the server
# - ask the registration server for the available product migrations
# (for both installed and registered products)
# - user selects the migration target
# - the registered products are upgraded and new services/repositories
# are added to the system
Expand Down Expand Up @@ -162,9 +163,23 @@ def find_products
return :abort
end

merge_registered_addons
log.info "Products to migrate: #{products}"

:next
end

def merge_registered_addons
# load the extensions to merge the registered but not installed extensions
Addon.find_all(registration)

addons = Addon.registered_not_installed.map(&:to_h).map do |addon|
SwMgmt.remote_product(addon)
end

products.concat(addons)
end

# load migration products for the installed products from the registration server
# @return [Symbol] workflow symbol (:next or :abort)
def load_migration_products
Expand All @@ -177,20 +192,14 @@ def load_migration_products
return :abort
end

# FIXME: just to prefill the cache, after upgrading the base product
# the addons for the current base product cannot be loaded
Addon.find_all(registration)

:next
end

# run the migration target selection dialog
# @return [Symbol] workflow symbol (:next or :abort)
def select_migration_products
log.info "Displaying migration target selection dialog"
installed_products = SwMgmt.installed_products
log.info "installed_products: #{installed_products}"
dialog = MigrationSelectionDialog.new(migrations, installed_products)
dialog = MigrationSelectionDialog.new(migrations, products_to_migrate)
ret = dialog.run

if ret == :next
Expand All @@ -202,6 +211,21 @@ def select_migration_products
ret
end

# collect products to migrate
# @return [Array<Hash>] installed or registered products
def products_to_migrate
installed_products = SwMgmt.installed_products
log.info "installed_products: #{installed_products}"

registered_products = Addon.registered_not_installed.map do |addon|
ret = addon.to_h
ret["display_name"] = addon.friendly_name
ret
end

installed_products.concat(registered_products)
end

# upgrade the services to the new version
# @return [Symbol] workflow symbol (:next)
def register_migration_products
Expand Down
5 changes: 5 additions & 0 deletions src/lib/registration/ui/migration_selection_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def run

attr_accessor :migrations

def add_registered_addons
extra = Addon.registered_not_installed.map { |addon| SwMgmt.remote_product(addon) }
installed_products.concat(extra)
end

# the main dialog content
# @return [Yast::Term] UI term
def dialog_content
Expand Down

0 comments on commit 9fbdd11

Please sign in to comment.