Skip to content

Commit

Permalink
Merge branch 'SLE-12-SP2-CASP'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Feb 15, 2017
2 parents 7025780 + c395c14 commit 30f8d12
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 82 deletions.
6 changes: 6 additions & 0 deletions package/yast2-kdump.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Feb 14 12:08:46 UTC 2017 - mvidner@suse.com

- Explicitly create the kdump initrd (bsc#1022496).
- 3.2.2

-------------------------------------------------------------------
Wed Jan 25 13:01:58 UTC 2017 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-kdump.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-kdump
Version: 3.2.1
Version: 3.2.2
Release: 0
Summary: Configuration of kdump
License: GPL-2.0
Expand Down
72 changes: 2 additions & 70 deletions src/clients/kdump_finish.rb
@@ -1,70 +1,2 @@
# encoding: utf-8

# File:
# kdump_finish.ycp
#
# Module:
# Step of base installation finish
#
# Authors:
# Jozef Uhliarik <juhliarik@suse.cz>
#
#
module Yast
class KdumpFinishClient < Client
def main

textdomain "kdump"

Yast.import "Kdump"
Yast.import "Mode"
Yast.import "Progress"

@ret = nil
@func = ""
@param = {}

# Check arguments
if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
Ops.is_string?(WFM.Args(0))
@func = Convert.to_string(WFM.Args(0))
if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
Ops.is_map?(WFM.Args(1))
@param = Convert.to_map(WFM.Args(1))
end
end

@progress_orig = Progress.set(false)

Builtins.y2milestone("starting kdump_finish")
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Info"
return {
"steps" => 3,
# progress step title
"title" => _("Saving kdump configuration..."),
"when" => [:installation, :update, :autoinst]
}
elsif @func == "Write"
# propose settings for kdump if autoyast doesn't include settings for yast2-kdump
Kdump.Propose if !Kdump.import_called && (Mode.autoinst || Mode.autoupgrade)
if Mode.update
Kdump.Update
else
Kdump.Write
end
else
Builtins.y2error("unknown function: %1", @func)
@ret = nil
end
Progress.set(@progress_orig)
Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("kdump_finish finished")
deep_copy(@ret)
end
end
end

Yast::KdumpFinishClient.new.main
require "kdump/clients/finish"
::Y2Kdump::Clients::Finish.run
56 changes: 56 additions & 0 deletions src/lib/kdump/clients/finish.rb
@@ -0,0 +1,56 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2017 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.
#
# ------------------------------------------------------------------------------

require "installation/finish_client"

module Y2Kdump
module Clients
class Finish < ::Installation::FinishClient
def initialize
textdomain "kdump"

Yast.import "Kdump"
Yast.import "Mode"
Yast.import "Progress"
end

def title
# progress step title
_("Saving kdump configuration...")
end

def modes
[:installation, :update, :autoinst]
end

def steps
3
end

def write
progress_orig = Progress.set(false)
# propose settings for kdump
# if autoyast doesn't include settings for yast2-kdump
Kdump.Propose if !Kdump.import_called && Mode.auto
if Mode.update
Kdump.Update
else
Kdump.Write
end
Progress.set(progress_orig)
end
end
end
end
20 changes: 15 additions & 5 deletions src/modules/Kdump.rb
Expand Up @@ -385,10 +385,24 @@ def ReadKdumpSettings
#
# @return [Boolean] whether successful
def update_initrd
# For CaaSP we need an explicit initrd rebuild before the
# first boot, when the root filesystem becomes read only.
rebuild_cmd = "/usr/sbin/tu-rebuild-kdump-initrd"
# part of transactional-update.rpm
update_initrd_with("if test -x #{rebuild_cmd}; then #{rebuild_cmd}; fi")

return true unless using_fadump_changed?

# See FATE#315780
# See https://www.suse.com/support/kb/doc.php?id=7012786
# FIXME what about dracut?
update_command = (using_fadump? ? "mkdumprd -f" : "mkinitrd")
update_initrd_with(update_command)
end

# @param update_command [String] a command for .target.bash
# @return [Boolean] whether successful
def update_initrd_with(update_command)
update_logfile = File.join(Directory.vardir, "y2logmkinitrd")

run_command = update_command + " >> #{update_logfile} 2>&1"
Expand Down Expand Up @@ -429,11 +443,7 @@ def WriteKdumpSettingsTo(scr_path, file_name)
def WriteKdumpSettings
WriteKdumpSettingsTo(path(".sysconfig.kdump"), @kdump_file)

if using_fadump_changed? && ! update_initrd
return false
end

true
update_initrd
end

# Write kdump boot arguments - crashkernel and fadump
Expand Down
51 changes: 51 additions & 0 deletions test/finish_test.rb
@@ -0,0 +1,51 @@
#!/usr/bin/env rspec

require_relative "./test_helper"

require "kdump/clients/finish"

describe Y2Kdump::Clients::Finish do
describe "#steps" do
it "returns an integer" do
expect(subject.steps).to be_an Integer
end
end

describe "#title" do
it "returns a string" do
expect(subject.title).to be_a String
end
end

describe "#modes" do
it "returns a list" do
modes = subject.modes
# If we want to make this a generic FinishClient test,
# remember the API allows a nil
expect(modes).to be_an Array
modes.each do |m|
# elements are fixed symbol values
expect(m).to be_a Symbol
end
end
end

describe "#write" do
before do
allow(Yast::Kdump).to receive(:Propose)
Yast::Kdump.import_called = false
end

it "calls Kdump.Write for installing" do
expect(Yast::Mode).to receive(:update).and_return(false)
expect(Yast::Kdump).to receive(:Write)
subject.write
end

it "calls Kdump.Update for updating" do
expect(Yast::Mode).to receive(:update).and_return(true)
expect(Yast::Kdump).to receive(:Update)
subject.write
end
end
end
11 changes: 5 additions & 6 deletions test/test_helper.rb
Expand Up @@ -7,14 +7,13 @@

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start

# For coverage we need to load all ruby files
# Note that clients/ are excluded because they run too eagerly by design
Dir["#{srcdir}/{include,modules}/**/*.rb"].each do |f|
require_relative f
SimpleCov.start do
add_filter "/test/"
end

# track all ruby files under src
SimpleCov.track_files("#{srcdir}/**/*.rb")

# use coveralls for on-line code coverage reporting at Travis CI
if ENV["TRAVIS"]
require "coveralls"
Expand Down

0 comments on commit 30f8d12

Please sign in to comment.