Skip to content

Commit

Permalink
Merge 42acf63 into 860c429
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Feb 27, 2019
2 parents 860c429 + 42acf63 commit 102f952
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package/yast2-storage-ng.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Feb 27 09:57:10 UTC 2019 - David Díaz <dgonzalez@suse.com>

- Do not export the partition_type attribute when it belongs to a
GPT partition table (bsc#1115751).

-------------------------------------------------------------------
Fri Feb 22 15:11:37 UTC 2019 - José Iván López González <jlopez@suse.com>

Expand Down
19 changes: 17 additions & 2 deletions src/lib/y2storage/autoinst_profile/partition_section.rb
Expand Up @@ -124,7 +124,8 @@ def self.attributes
# @return [Integer] the partition number of this partition

# @!attribute partition_type
# @return [String] undocumented attribute that can only contain "primary"
# @return [String, nil] the partition type of this partition (only can be "primary")
# @see #primary_partition?

# @!attribute subvolumes
# @return [Array<SubvolSpecification>,nil] list of subvolumes or nil if not
Expand Down Expand Up @@ -297,7 +298,7 @@ def init_fields_by_type(device)
def init_partition_fields(partition)
@create = !NO_CREATE_IDS.include?(partition.id)
@partition_nr = partition.number
@partition_type = "primary" if partition.type.is?(:primary)
@partition_type = "primary" if primary_partition?(partition)
@partition_id = partition_id_from(partition)
@lvm_group = lvm_group_name(partition)
@raid_name = partition.md.name if partition.md
Expand Down Expand Up @@ -431,6 +432,20 @@ def lvm_group_name(device)
def fixed_size?(device)
device.is?(:disk_device, :software_raid)
end

private

# Whether given partition is primary or not
#
# Always false when the partition belongs to a GPT partition table.
#
# @param partition [Y2Storgae::Partition] the partition to check
# @return [Boolean] true when is a primary partition; false otherwise
def primary_partition?(partition)
return false if partition.partition_table.type.is?(:gpt)

partition.type.is?(:primary)
end
end
end
end
8 changes: 8 additions & 0 deletions test/y2storage/autoinst_profile/partition_section_test.rb
Expand Up @@ -70,6 +70,14 @@ def section_for(name)
end
end

context "when the partition belongs to a GPT partition table" do
let(:dev) { device("sdh") }

it "does not include the partition_type" do
expect(section_for("sdh1").partition_type).to be_nil
end
end

context "when the partition belongs to an MD RAID" do
let(:dev) { device("sdb1") }
let(:md) { instance_double(Y2Storage::Md, name: "/dev/md0") }
Expand Down

0 comments on commit 102f952

Please sign in to comment.