Skip to content

Commit

Permalink
aded new migration_proposal.rb client
Browse files Browse the repository at this point in the history
use it instead of the update_proposal which has been designed
for offline upgrade and does some specific actions not desired in
online migration
  • Loading branch information
lslezak committed Jul 2, 2015
1 parent a7f2d15 commit 99d1e47
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 3 deletions.
127 changes: 127 additions & 0 deletions src/clients/migration_proposal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2015 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# ------------------------------------------------------------------------------
#

module Yast
# migration proposal client
class MigrationProposalClient < Client
include Yast::Logger

# run the proposal
# @return [Hash] the proposal result
def main
init

func = WFM.Args(0)
log.info "Proposal function: #{func}"
ret = handle_function(func)

log.info "Migration proposal result: #{ret.inspect}"
ret
end

private

# initialize the client
def init
Yast.import "Pkg"
Yast.import "HTML"
Yast.import "Packages"
Yast.import "SpaceCalculation"
Yast.import "Popup"
Yast.import "Update"

textdomain "migration"
end

# handle the requested proposal function
# @param [String] func the proposal function
# @return [Hash] the proposal result
def handle_function(func)
case func
when "MakeProposal"
propose
when "AskUser"
ask_user
when "Description"
description
else
log.error "Unknown function: #{func.inspect}"
end
end

# proposal help text
# @return [String] help text
def help
# TRANSLATORS: help text
_(
"<p>This is an overview of the product migration.</p>\n"
)
end

# the proposal description
# @return [Hash] proposal result
def description
{
# TRANSLATORS: a summary heading
"rich_text_title" => _("Migration Summary"),
# TRANSLATORS: a menu entry
"menu_title" => _("&Migration Summary"),
"id" => "migration_proposal"
}
end

# handle the user feedback
# @return [Hash] proposal result
def ask_user
# TRANSLATORS: popup message
Popup.Message(_("There is nothing to configure."))
# optimization: return :abort to avoid complete propsal re-evaluation
{ "workflow_sequence" => :abort }
end

# propose migration - return migration summary
# @return [Hash] proposal result
def propose
# report dependency issues in the Packages proposal
Pkg.PkgSolve(true)
Update.solve_errors = Pkg.PkgSolveErrors

# recalculate the disk space usage data
SpaceCalculation.GetPartitionInfo

products = Pkg.ResolvableProperties("", :product, "")

ret = {
"preformatted_proposal" => product_summary(products),
"help" => help
}

ret.merge(Packages.product_update_warning(products))
end

# @param [Array<Hash>] products the current libzypp products
# @return [String] product summary text (RichText)
def product_summary(products)
summary_text = Packages.product_update_summary(products).map do |item|
"<li>#{item}</li>"
end

HTML.ListStart + summary_text.join + HTML.ListEnd
end
end
end

Yast::MigrationProposalClient.new.main
2 changes: 1 addition & 1 deletion src/lib/migration/proposal_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProposalStore < Installation::ProposalStore
include Yast::Logger
include Yast::I18n

PROPOSAL_NAMES = ["update_proposal", "packages_proposal"]
PROPOSAL_NAMES = ["migration_proposal", "packages_proposal"]
PROPOSAL_PROPERTIES = {
"enable_skip" => "false"
}
Expand Down
4 changes: 2 additions & 2 deletions test/proposal_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ module Yast

describe ".proposal_names" do
it "returns an update proposal" do
expect(subject.proposal_names).to eq ["update_proposal",
expect(subject.proposal_names).to eq ["migration_proposal",
"packages_proposal"]
end
end

describe ".presentation_order" do
it "returns a presentation order" do
expect(subject.presentation_order).to eq ["update_proposal",
expect(subject.presentation_order).to eq ["migration_proposal",
"packages_proposal"]
end
end
Expand Down

0 comments on commit 99d1e47

Please sign in to comment.