Skip to content

Commit

Permalink
AutoinstDiskDevice#planned_devices accepts only 1 argument
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 26, 2018
1 parent b589bab commit c9e31e8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
3 changes: 2 additions & 1 deletion src/lib/y2storage/proposal/autoinst_devices_planner.rb
Expand Up @@ -84,7 +84,8 @@ def planned_devices(drives_map)

def planned_for_disk_device(drive, disk_name)
planner = Y2Storage::Proposal::AutoinstDiskDevicePlanner.new(devicegraph, issues_list)
planner.planned_devices(drive, disk_name)
drive.device = disk_name
planner.planned_devices(drive)
end

# Returns a planned volume group according to an AutoYaST specification
Expand Down
5 changes: 2 additions & 3 deletions src/lib/y2storage/proposal/autoinst_disk_device_planner.rb
Expand Up @@ -29,12 +29,11 @@ class AutoinstDiskDevicePlanner < AutoinstDrivePlanner
# Returns an array of planned partitions for a given disk or the disk
# itself if there are no partitions planned
#
# @param disk [Disk,Dasd] Disk to place the partitions on
# @param drive [AutoinstProfile::DriveSection] drive section describing
# the layout for the disk
# @return [Array<Planned::Partition, Planned::StrayBlkDevice>] List of planned partitions or disks
def planned_devices(drive, disk_name)
disk = BlkDevice.find_by_name(devicegraph, disk_name)
def planned_devices(drive)
disk = BlkDevice.find_by_name(devicegraph, drive.device)
if disk
planned_for_disk(disk, drive)
else
Expand Down
66 changes: 33 additions & 33 deletions test/y2storage/proposal/autoinst_disk_device_planner_test.rb
Expand Up @@ -53,7 +53,7 @@
let(:root_spec) { { "mount" => "/", "size" => "max", "partition_type" => "primary" } }

it "sets the planned device as 'primary'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(true)
end
Expand All @@ -63,7 +63,7 @@
let(:root_spec) { { "mount" => "/", "size" => "max", "partition_type" => "logical" } }

it "sets planned device as not 'primary'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(false)
end
Expand All @@ -73,7 +73,7 @@
let(:root_spec) { { "mount" => "/", "size" => "max" } }

it "does not set 'primary'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(false)
end
Expand All @@ -92,7 +92,7 @@
let(:size) { "10" }

it "sets the size according to that number and using unit B" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.min_size).to eq(disk_size)
expect(root.max_size).to eq(disk_size)
Expand All @@ -104,7 +104,7 @@
let(:size) { "5GB" }

it "sets the size according to that number and using legacy_units" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.min_size).to eq(disk_size)
expect(root.max_size).to eq(disk_size)
Expand All @@ -116,7 +116,7 @@
let(:size) { "50%" }

it "sets the size according to the percentage" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.min_size).to eq(disk_size)
expect(root.max_size).to eq(disk_size)
Expand All @@ -127,14 +127,14 @@
let(:size) { "max" }

it "sets the size to 'unlimited'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.min_size).to eq(Y2Storage::DiskSize.B(1))
expect(root.max_size).to eq(Y2Storage::DiskSize.unlimited)
end

it "sets the weight to '1'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.weight).to eq(1)
end
Expand All @@ -145,7 +145,7 @@

it "registers an issue" do
expect(issues_list).to be_empty
planner.planned_devices(drive, "/dev/sda")
planner.planned_devices(drive)
issue = issues_list.find { |i| i.is_a?(Y2Storage::AutoinstIssues::InvalidValue) }
expect(issue.value).to eq("huh?")
expect(issue.attr).to eq(:size)
Expand Down Expand Up @@ -185,7 +185,7 @@
end

it "sets min and max" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
swap = devices.find { |d| d.mount_point == "swap" }
expect(swap.min_size).to eq(128.MiB)
expect(swap.max_size).to eq(1.GiB)
Expand All @@ -198,14 +198,14 @@
end

it "ignores the device" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
home = devices.find { |d| d.mount_point == "/home" }
expect(home).to be_nil
end

it "registers an issue" do
expect(issues_list).to be_empty
planner.planned_devices(drive, "/dev/sda")
planner.planned_devices(drive)
issue = issues_list.find { |i| i.is_a?(Y2Storage::AutoinstIssues::InvalidValue) }
expect(issue.value).to eq("auto")
expect(issue.attr).to eq(:size)
Expand All @@ -217,7 +217,7 @@
end

it "sets default values" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
swap = devices.find { |d| d.mount_point == "swap" }
expect(swap.min_size).to eq(512.MiB)
expect(swap.max_size).to eq(2.GiB)
Expand All @@ -230,7 +230,7 @@
let(:size) { "" }

it "sets the size to 'unlimited'" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.min_size).to eq(Y2Storage::DiskSize.B(1))
expect(root.max_size).to eq(Y2Storage::DiskSize.unlimited)
Expand All @@ -253,7 +253,7 @@
end

it "sets the filesystem" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
home = devices.find { |d| d.mount_point == "/home" }
expect(root.filesystem_type).to eq(Y2Storage::Filesystems::Type::EXT4)
Expand All @@ -274,7 +274,7 @@

it "sets to the default type for the given mount point" do
expect(volspec_builder).to receive(:for).with("/srv").and_return(volspec)
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
srv = devices.find { |d| d.mount_point == "/srv" }
expect(srv.filesystem_type).to eq(volspec.fs_type)
end
Expand All @@ -283,14 +283,14 @@
let(:volspec) { Y2Storage::VolumeSpecification.new({}) }

it "sets filesystem to btrfs" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
srv = devices.find { |d| d.mount_point == "/srv" }
expect(srv.filesystem_type).to eq(Y2Storage::Filesystems::Type::BTRFS)
end

context "and is a swap filesystem" do
it "sets filesystem to swap" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
swap = devices.find { |d| d.mount_point == "swap" }
expect(swap.filesystem_type).to eq(Y2Storage::Filesystems::Type::SWAP)
end
Expand All @@ -299,21 +299,21 @@
end

it "sets the mountby properties" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
home = devices.find { |d| d.mount_point == "/home" }
expect(root.mount_by).to be_nil
expect(home.mount_by).to eq(Y2Storage::Filesystems::MountByType::UUID)
end

it "sets fstab options" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.fstab_options).to eq(["ro", "acl"])
end

it "sets mkfs options" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.mkfs_options).to eq("-b 2048")
end
Expand All @@ -325,7 +325,7 @@
end

it "sets the encryption password" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.encryption_password).to eq("secret")
end
Expand All @@ -344,7 +344,7 @@
end

it "reuses the partition with that number" do
devices = planner.planned_devices(drive, "/dev/sdb")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.reuse_name).to eq("/dev/sdb2")
end
Expand All @@ -356,7 +356,7 @@
end

it "reuses the partition with that label" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.reuse_name).to eq("/dev/sda3")
end
Expand All @@ -368,14 +368,14 @@
end

it "adds a new partition" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.reuse_name).to be_nil
end

it "registers an issue" do
expect(issues_list).to be_empty
planner.planned_devices(drive, "/dev/sda")
planner.planned_devices(drive)
issue = issues_list.find { |i| i.is_a?(Y2Storage::AutoinstIssues::MissingReusableDevice) }
expect(issue).to_not be_nil
end
Expand All @@ -387,14 +387,14 @@
end

it "adds a new partition" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
root = devices.find { |d| d.mount_point == "/" }
expect(root.reuse_name).to be_nil
end

it "registers an issue" do
expect(issues_list).to be_empty
planner.planned_devices(drive, "/dev/sda")
planner.planned_devices(drive)
issue = issues_list.find { |i| i.is_a?(Y2Storage::AutoinstIssues::MissingReuseInfo) }
expect(issue).to_not be_nil
end
Expand All @@ -408,7 +408,7 @@
let(:fs) { "xfs" }

it "plans the specified filesystem type" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
planned = devices.find { |d| d.reuse_name == "/dev/sda3" }
expect(planned.reformat?).to eq true
expect(planned.filesystem_type).to eq Y2Storage::Filesystems::Type::XFS
Expand All @@ -419,7 +419,7 @@
let(:fs) { nil }

it "keeps the previous file system type of the partition" do
devices = planner.planned_devices(drive, "/dev/sda")
devices = planner.planned_devices(drive)
planned = devices.find { |d| d.reuse_name == "/dev/sda3" }
expect(planned.reformat?).to eq true
expect(planned.filesystem_type).to eq Y2Storage::Filesystems::Type::EXT4
Expand All @@ -440,7 +440,7 @@
let(:part_section) { [{ "partition_nr" => 2, "format" => true, "filesystem" => "ext2" }] }

it "plans the specified filesystem type" do
devices = planner.planned_devices(drive, "/dev/xdva")
devices = planner.planned_devices(drive)
planned = devices.find { |d| d.reuse_name == "/dev/xvda2" }
expect(planned.reformat?).to eq true
expect(planned.filesystem_type).to eq Y2Storage::Filesystems::Type::EXT2
Expand All @@ -451,7 +451,7 @@
let(:part_section) { [{ "partition_nr" => 2, "format" => true }] }

it "reuses the previous file system type" do
devices = planner.planned_devices(drive, "/dev/xdva")
devices = planner.planned_devices(drive)
planned = devices.find { |d| d.reuse_name == "/dev/xvda2" }
expect(planned.reformat?).to eq true
expect(planned.filesystem_type).to eq Y2Storage::Filesystems::Type::XFS
Expand All @@ -462,7 +462,7 @@
let(:part_section) { [{ "partition_nr" => 1, "format" => true }] }

it "plans no filesystem type" do
devices = planner.planned_devices(drive, "/dev/xdva")
devices = planner.planned_devices(drive)
planned = devices.find { |d| d.reuse_name == "/dev/xvda1" }
expect(planned.reformat?).to eq true
expect(planned.filesystem_type).to be_nil
Expand Down

0 comments on commit c9e31e8

Please sign in to comment.