Skip to content

Commit

Permalink
Merge pull request #419 from yast/imo-fix-bsc-1061253
Browse files Browse the repository at this point in the history
Filter out '@' subvolumes when importing
  • Loading branch information
imobachgs committed Nov 8, 2017
2 parents ee120b2 + fe04ba4 commit 2ae59c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
7 changes: 7 additions & 0 deletions package/yast2-storage-ng.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 8 14:45:22 UTC 2017 - igonzalezsosa@suse.com

- AutoYaST: filter out old '@' entries when importing the list of
subvolumes (bsc#1061253)
- 4.0.27

-------------------------------------------------------------------
Wed Nov 8 10:07:09 UTC 2017 - ancor@suse.com

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

Name: yast2-storage-ng
Version: 4.0.26
Version: 4.0.27
Release: 0
BuildArch: noarch

Expand Down
17 changes: 16 additions & 1 deletion src/lib/y2storage/autoinst_profile/partition_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def init_from_hashes(hash)
if hash["raid_options"]
@raid_options = RaidOptionsSection.new_from_hashes(hash["raid_options"], self)
end
@subvolumes = SubvolSpecification.list_from_control_xml(hash["subvolumes"]) if hash["subvolumes"]
@subvolumes = subvolumes_from_hashes(hash["subvolumes"]) if hash["subvolumes"]
@fstab_options = hash["fstopt"].split(",").map(&:strip) if hash["fstopt"]
end

Expand Down Expand Up @@ -347,6 +347,21 @@ def subvolumes_to_hashes
{ "path" => subvol_path, "copy_on_write" => subvol.copy_on_write }
end
end

# Return a list of subvolumes from an array of hashes
#
# This method builds a list of SubvolSpecification objects from an array
# of subvolumes in hash form (according to AutoYaST specification).
#
# Additionally, it filters out "@" subvolumes entries which were
# generated by older AutoYaST versions. See bnc#1061253.
#
# @param hashes [Array<Hash>] List of subvolumes in hash form
# @return [Array<SubvolSpecification>] List of subvolumes
def subvolumes_from_hashes(hashes)
subvolumes = SubvolSpecification.list_from_control_xml(hashes)
subvolumes.reject { |s| s.path == "@" }
end
end
end
end
11 changes: 11 additions & 0 deletions test/y2storage/autoinst_profile/partition_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ def section_for(name)
end
end

context "when the '@' subvolume is present" do
let(:hash) { { "subvolumes" => ["@", "srv"] } }

it "filters out the '@' subvolume" do
subvolumes = described_class.new_from_hashes(hash).subvolumes
expect(subvolumes).to contain_exactly(
an_object_having_attributes(path: "srv", copy_on_write: true)
)
end
end

context "when raid_options are not present" do
it "initializes raid_options to nil" do
section = described_class.new_from_hashes(hash)
Expand Down

0 comments on commit 2ae59c5

Please sign in to comment.