Skip to content

Commit

Permalink
allow autoyast import of device map (found during debugging bnc#995627)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Aug 30, 2016
1 parent 7fe421f commit 148353c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/bootloader/autoyast_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "bootloader/bootloader_factory"

Yast.import "BootStorage"
Yast.import "Arch"

module Bootloader
# Represents unsupported bootloader type error
Expand Down Expand Up @@ -32,6 +33,7 @@ def import(data)
import_grub2(data, bootloader)
import_stage1(data, bootloader)
import_default(data, bootloader.grub_default)
import_device_map(data, bootloader)
# TODO: import Initrd

log.warn "autoyast profile contain sections which won't be processed" if data["sections"]
Expand Down Expand Up @@ -106,6 +108,19 @@ def import_timeout(data, default)
end
end

def import_device_map(data, bootloader)
return unless bootloader.name == "grub2"
return if !Yast::Arch.x86_64 && !Yast::Arch.i386

dev_map = data["device_map"]
return unless dev_map

bootloader.device_map.clear_mapping
dev_map.each do |entry|
bootloader.device_map.add_mapping(entry["firmware"], entry["linux"])
end
end

STAGE1_DEVICES_MAPPING = {
"boot_root" => :RootPartitionDevice,
"boot_boot" => :BootPartitionDevice,
Expand Down
1 change: 1 addition & 0 deletions src/lib/bootloader/device_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def read
end

def write
log.info "writting device map: #{to_s}"
@model.save
end

Expand Down
17 changes: 17 additions & 0 deletions test/autoyast_converter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require "bootloader/autoyast_converter"
require "bootloader/grub2"

Yast.import "Arch"

describe Bootloader::AutoyastConverter do
subject { described_class }

Expand Down Expand Up @@ -63,6 +65,21 @@
expect(bootloader.trusted_boot).to eq true
end

it "imports device map for grub2 on intel architecture" do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
data = {
"loader_type" => "grub2",
"device_map" => [
{"firmware" => "hd0", "linux" => "/dev/vda"},
{"firmware" => "hd1", "linux" => "/dev/vdb"}
]
}

bootloader = subject.import(data)
expect(bootloader.device_map.system_device_for("hd0")).to eq "/dev/vda"
expect(bootloader.device_map.system_device_for("hd1")).to eq "/dev/vdb"
end

it "supports SLE9 format" do
data = {
"activate" => "true",
Expand Down

0 comments on commit 148353c

Please sign in to comment.