!6 check if disklabel supports partition names

Merge pull request !6 from algorithmofdish/master
This commit is contained in:
openeuler-ci-bot 2020-03-21 21:50:40 +08:00 committed by Gitee
commit 3fd70004a0
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From 6817db6f11ffbaac511c5d43129473910c80736e Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Sat, 21 Mar 2020 18:06:51 +0800
Subject: [PATCH] check if disklabel supports partition names
pyparted now raises an exception when trying to access partition
name on a disklabel that doesn't support partition names, see
https://github.com/dcantrell/pyparted/issues/59
---
blivet/formats/disklabel.py | 7 +++++++
blivet/populator/helpers/boot.py | 1 +
2 files changed, 8 insertions(+)
diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py
index e13ab2f..125f2ba 100644
--- a/blivet/formats/disklabel.py
+++ b/blivet/formats/disklabel.py
@@ -329,6 +329,13 @@ class DiskLabel(DeviceFormat):
""" Device status. """
return False
+ @property
+ def supports_names(self):
+ if not self.supported or not self.parted_disk:
+ return False
+
+ return self.parted_disk.supportsFeature(parted.DISK_TYPE_PARTITION_NAME)
+
def _create(self, **kwargs):
""" Create the device. """
log_method_call(self, device=self.device,
diff --git a/blivet/populator/helpers/boot.py b/blivet/populator/helpers/boot.py
index 76eed22..5eee9ae 100644
--- a/blivet/populator/helpers/boot.py
+++ b/blivet/populator/helpers/boot.py
@@ -59,6 +59,7 @@ class MacEFIFormatPopulator(BootFormatPopulator):
fmt = formats.get_format(cls._type_specifier)
try:
return (super(MacEFIFormatPopulator, MacEFIFormatPopulator).match(data, device) and
+ device.disk.format.supports_names and
device.parted_partition.name == fmt.name)
except AttributeError:
# just in case device.parted_partition has no name attr
--
1.8.3.1

View File

@ -2,7 +2,7 @@
Name: python-blivet Name: python-blivet
Version: 3.1.1 Version: 3.1.1
Release: 6 Release: 7
Epoch: 1 Epoch: 1
Summary: A python module for system storage configuration Summary: A python module for system storage configuration
License: LGPLv2+ License: LGPLv2+
@ -21,6 +21,9 @@ Patch1: 0002-Fix-options-for-ISCSI-functions-1632656.patch
Patch9000: fix-the-long-hostname.patch Patch9000: fix-the-long-hostname.patch
# from upstream https://github.com/dcantrell/pyparted/issues/59
Patch6000: check-if-disklabel-supports-partition-names.patch
%description %description
The python-blivet package is a python module for examining and modifying The python-blivet package is a python module for examining and modifying
storage configuration. storage configuration.
@ -119,6 +122,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install
%doc README %doc README
%changelog %changelog
* Sat Mar 21 2020 hexiujun <hexiujun1@huawei.com> - 3.1.1-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:check if disklabel supports partition names
* Sat Mar 14 2020 hexiujun <hexiujun1@huawei.com> - 3.1.1-6 * Sat Mar 14 2020 hexiujun <hexiujun1@huawei.com> - 3.1.1-6
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA