Skip to content

Commit

Permalink
Fixed registration order in AutoYaST
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 22, 2017
1 parent 929d0a3 commit 4927910
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions src/clients/scc_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def register_base_product
# register the addons specified in the profile
def register_addons
# register addons
@config.addons.each do |addon|
read_sorted_addons(@config.addons).each do |addon|
product_service = register_addon(addon)

::Registration::Storage::Cache.instance.addon_services << product_service
Expand All @@ -321,12 +321,71 @@ def register_addons
::Registration::SwMgmt.select_addon_products
end

# read the available addons from the server, sort the addons from the profile
# according to the dependencies, convert to hashes to register them
# @param [Array<Hash>] The requested addons from the AutoYaST profile
# @return [Array<Hash>] The sorted addons to register
def read_sorted_addons(requested_addons)
# ask the server for all available addons
all_addons = registration_ui.get_available_addons

# select the requested addons from the AY profile
requested_addons.each do |addon|
server_addon = all_addons.find do |a|
a.identifier == addon["name"] && a.version == addon["version"] &&
a.arch == addon["arch"]
end

if server_addon
# mark it as selected
server_addon.selected
else
Report.Warning(
# TRANSLATORS: %s is an addon name (including version and arch)
# from the AutoYast XML installation profile
_("Addon '%s'\nis not available for registration\n" \
"and will be skipped." ) % "#{addon["name"]}-#{addon["version"]}-#{addon["arch"]}"
)
end
end

# include also the automatically selected dependent modules/extensions
addons = Registration::Addon.registration_order(
Registration::Addon.selected + Registration::Addon.auto_selected)

if !Registration::Addon.auto_selected.empty?
log.warn("Registering additional automatically selected addons: " +
Registration::Addon.auto_selected.map(&:label).inspect)
end

log.info("Registering addons: #{addons.map(&:label).inspect}")

# convert to hash and add the reg code from the AY profile
addons.map do |a|
config_addon = requested_addons.find do |addon|
a.identifier == addon["name"] && a.version == addon["version"] &&
a.arch == addon["arch"]
end

ret = a.to_h
# keep it to just display it later
ret["label"] = a.label
if config_addon && config_addon["reg_code"]
ret["reg_code"] = config_addon["reg_code"]
end

ret
end
end

def register_addon(addon)
Popup.Feedback(
_(CONTACTING_MESSAGE),
# %s is name of given product
_("Registering %s ...") % addon["name"]
_("Registering %s ...") % addon["label"]
) do
# delete the label, not needed anymore
addon.delete("label")
registration.register_product(addon)
end
end
Expand Down

0 comments on commit 4927910

Please sign in to comment.