Skip to content

Commit

Permalink
Merge pull request #230 from yast/review_160715_bnc_986124_sles12_sp2
Browse files Browse the repository at this point in the history
[Review] Request from 'schubi2' @ 'yast/yast-autoinstallation/review_160715_bnc_986124_sles12_sp2'
  • Loading branch information
schubi2 committed Jul 15, 2016
2 parents 6497347 + 216acbd commit 5036ccd
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 12 deletions.
6 changes: 6 additions & 0 deletions package/autoyast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jul 14 15:01:29 CEST 2016 - schubi@suse.de

- Exporting NFS root partition correctly. (bnc#986124)
- 3.1.140

-------------------------------------------------------------------
Wed Jul 13 09:15:05 CEST 2016 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: autoyast2
Version: 3.1.139
Version: 3.1.140
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
6 changes: 5 additions & 1 deletion src/modules/AutoinstDrive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ def removePartition(drive, idx)

def parseDrive(drive)
drive = deep_copy(drive)
# If it is a root nfs partition we do not need any additional
# conversation. (bnc#986124)
return drive if drive["type"] == :CT_NFS

newDrive = new("auto", Ops.get_symbol(drive, "type", :CT_DISK))
newDrive = set(
newDrive,
Expand Down Expand Up @@ -384,7 +388,7 @@ def Export(drive)
exportDrive,
"use",
symbol2string(Ops.get_symbol(exportDrive, "use", :Empty))
)
) if exportDrive.fetch("use", :Empty).is_a?( Symbol )
# let AutoinstPartition do it's own filtering
Ops.set(
exportDrive,
Expand Down
29 changes: 19 additions & 10 deletions src/modules/AutoinstPartPlan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,18 @@ def ReadHelper
_StorageMap = Builtins.eval(Storage.GetTargetMap)

_StorageMap = _StorageMap.select do |d, p|
ok = d != "/dev/evms" && d != "/dev/nfs"
ok = true
if( d == "/dev/nfs" && p["partitions"] != nil)
# Checking if /dev/nfs container has a root partition.
# If yes, it can be taken for the plan (bnc#986124)
ok = p["partitions"].any?{ |part| part["mount"] == "/" }
end
if( ok && p.fetch("partitions", []).size==0 )
ok = p.fetch("used_by_type",:UB_NONE)==:UB_LVM
end
ok
end
Builtins.y2milestone("Storagemap %1", _StorageMap)
# list evms_vgs = [];

drives = Builtins.maplist(_StorageMap) do |k, v|
partitions = []
Expand All @@ -360,6 +364,17 @@ def ReadHelper
Builtins.foreach(Ops.get_list(v, "partitions", [])) do |pe|
next if Ops.get_symbol(pe, "type", :x) == :extended
new_pe = {}

# Handling nfs root partitions. (bnc#986124)
if pe["type"] == :nfs
new_pe["type"] = pe["type"]
new_pe["device"] = pe["device"]
new_pe["mount"] = pe["mount"]
new_pe["fstopt"] = pe["fstopt"]
partitions << new_pe
end
next if pe["type"] == :nfs

Ops.set(new_pe, "create", true)
new_pe["ignore_fstab"] = pe["ignore_fstab"] if pe.has_key?("ignore_fstab")
skipwin = false
Expand Down Expand Up @@ -587,7 +602,8 @@ def ReadHelper
# they must exist
drive = {}
Ops.set(drive, "type", Ops.get_symbol(v, "type", :CT_DISK))
Ops.set(drive, "disklabel", Ops.get_string(v, "label", "msdos"))
# A disklabel for the container of NFS mounts is useless.
Ops.set(drive, "disklabel", Ops.get_string(v, "label", "msdos")) unless drive["type"] == :CT_NFS
if no_create
partitions = Builtins.maplist(
Convert.convert(partitions, :from => "list", :to => "list <map>")
Expand Down Expand Up @@ -644,13 +660,6 @@ def ReadHelper
end
deep_copy(drive)
end
# drives = filter( map v, (list<map>)drives, ``{
# if( ! (contains( evms_vgs, v["device"]:"") && v["type"]:`x == `CT_LVM ) )
# return true;
# y2milestone("kicking LVM %1 out of the profile because an EVMS with that name exists",v);
# return false;
# });
# remove drives with no mountpoint
drives = Builtins.filter(
Convert.convert(drives, :from => "list", :to => "list <map>")
) do |v|
Expand Down
33 changes: 33 additions & 0 deletions test/AutoinstPartPlan_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env rspec

require_relative "test_helper"
require "yaml"

Yast.import "AutoinstPartPlan"
Yast.import "Profile"

describe Yast::AutoinstPartPlan do
FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
let(:target_map_path) { File.join(FIXTURES_PATH, 'storage', "nfs_root.yml") }

describe "#read partition target" do

it "exporting nfs root partition" do
target_map = YAML.load_file(target_map_path)

expect(Yast::Storage).to receive(:GetTargetMap).and_return(target_map)
expect(Yast::AutoinstPartPlan.Read).to eq(true)
expect(Yast::AutoinstPartPlan.Export).to eq(
[{"type"=>:CT_NFS,
"partitions"=>[{"type"=>:nfs,
"device"=>"192.168.4.1:/srv/nfsroot/sles12sp1",
"mount"=>"/",
"fstopt"=>"minorversion=1"}],
"device"=>"/dev/nfs", "use"=>"all"}
]
)
end

end

end
63 changes: 63 additions & 0 deletions test/fixtures/storage/nfs_root.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
"/dev/nfs":
device: "/dev/nfs"
name: "nfs"
partitions:
- detected_fs: :nfs4
device: "192.168.4.1:/srv/nfsroot/sles12sp1"
fstopt: "minorversion=1"
fstype: "NFS"
mount: "/"
mountby: :device
name: "192.168.4.1:/srv/nfsroot/sles12sp1"
size_k: 41943040
type: :nfs
used_by_device: ""
used_by_type: :UB_NONE
used_fs: :nfs4
type: :CT_NFS
used_by_device: ""
used_by_type: :UB_NONE
"/dev/tmpfs":
device: "/dev/tmpfs"
name: "tmpfs"
partitions:
- detected_fs: :tmpfs
device: "tmpfs"
fstype: "TMPFS"
ignore_fstab: true
mount: "/dev/shm"
mountby: :uuid
name: "none"
size_k: 1026484
type: :tmpfs
used_by_device: ""
used_by_type: :UB_NONE
used_fs: :tmpfs
- detected_fs: :tmpfs
device: "tmpfs"
fstype: "TMPFS"
ignore_fstab: true
mount: "/run"
mountby: :uuid
name: "none"
size_k: 1026484
type: :tmpfs
used_by_device: ""
used_by_type: :UB_NONE
used_fs: :tmpfs
- detected_fs: :tmpfs
device: "tmpfs"
fstype: "TMPFS"
ignore_fstab: true
mount: "/sys/fs/cgroup"
mountby: :uuid
name: "none"
size_k: 1026484
type: :tmpfs
used_by_device: ""
used_by_type: :UB_NONE
used_fs: :tmpfs
type: :CT_TMPFS
used_by_device: ""
used_by_type: :UB_NONE

0 comments on commit 5036ccd

Please sign in to comment.