Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reuse by partition number #729

Merged
merged 4 commits into from Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions package/yast2-storage-ng.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Sep 5 21:23:54 UTC 2018 - lorenz@math.tu-berlin.de

- When trying to reuse a partition, AutoYaST will consider only
those partitions from the right disk (bsc#1106774).
- 4.0.209

-------------------------------------------------------------------
Tue Aug 28 13:27:53 UTC 2018 - ancor@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-storage-ng.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-storage-ng
Version: 4.0.208
Version: 4.0.209
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
10 changes: 6 additions & 4 deletions src/lib/y2storage/proposal/autoinst_devices_planner.rb
Expand Up @@ -316,7 +316,7 @@ def subvolume_attrs_for(mount)
# @param partition [Planned::Partition] Planned partition
# @param section [AutoinstProfile::PartitionSection] AutoYaST specification
def add_partition_reuse(partition, section)
partition_to_reuse = find_partition_to_reuse(section)
partition_to_reuse = find_partition_to_reuse(partition, section)
return unless partition_to_reuse
partition.filesystem_type ||= partition_to_reuse.filesystem_type
add_device_reuse(partition, partition_to_reuse.name, section)
Expand Down Expand Up @@ -391,14 +391,16 @@ def add_device_reuse(device, name, section)
device.resize = !!section.resize if device.respond_to?(:resize=)
end

# @param partition [Planned::Partition] Planned partition
# @param part_section [AutoinstProfile::PartitionSection] Partition specification
# from AutoYaST
def find_partition_to_reuse(part_section)
def find_partition_to_reuse(partition, part_section)
disk = devicegraph.find_by_name(partition.disk)
device =
if part_section.partition_nr
devicegraph.partitions.find { |i| i.number == part_section.partition_nr }
disk.partitions.find { |i| i.number == part_section.partition_nr }
elsif part_section.label
devicegraph.partitions.find { |i| i.filesystem_label == part_section.label }
disk.partitions.find { |i| i.filesystem_label == part_section.label }
else
issues_list.add(:missing_reuse_info, part_section)
nil
Expand Down
10 changes: 8 additions & 2 deletions test/y2storage/proposal/autoinst_devices_planner_test.rb
Expand Up @@ -71,14 +71,20 @@
describe "#planned_devices" do
context "reusing partitions" do
context "when a partition number is specified" do
let(:scenario) { "autoyast_drive_examples" }

let(:partitioning_array) do
[{ "device" => "/dev/sdb", "partitions" => [root_spec] }]
end

let(:root_spec) do
{ "create" => false, "mount" => "/", "filesystem" => "ext4", "partition_nr" => 3 }
{ "create" => false, "mount" => "/", "filesystem" => "ext4", "partition_nr" => 2 }
end

it "reuses the partition with that number" do
devices = planner.planned_devices(drives_map)
root = devices.find { |d| d.mount_point == "/" }
expect(root.reuse_name).to eq("/dev/sda3")
expect(root.reuse_name).to eq("/dev/sdb2")
end
end

Expand Down