Skip to content

Commit

Permalink
Merge pull request #5758 from KKoukiou/parted-part
Browse files Browse the repository at this point in the history
storage: store the partition name in device attrs for partitions
  • Loading branch information
KKoukiou committed Jul 16, 2024
2 parents 5511174 + cb83c58 commit d27cd3e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyanaconda/modules/common/structures/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ def attrs(self) -> Dict[Str, Str]:
hba-id
path-id
Attributes for partitions:
partition-label
:return: a dictionary of attributes
"""
return self._attrs
Expand Down
4 changes: 4 additions & 0 deletions pyanaconda/modules/storage/devicetree/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from functools import partial

from blivet.formats import get_format
from blivet.devices import PartitionDevice
from blivet.size import Size

from pyanaconda.anaconda_loggers import get_module_logger
Expand Down Expand Up @@ -137,6 +138,9 @@ def _set_device_data(self, device, data):
data.attrs["wwn"] = self._get_attribute(device, "wwn")
data.attrs["uuid"] = self._get_attribute(device, "uuid")

if isinstance(device, PartitionDevice):
data.attrs["partition-label"] = self._get_attribute(device.parted_partition, "name")

def _set_device_data_dasd(self, device, data):
"""Set data for a DASD device."""
data.attrs["bus-id"] = self._get_attribute(device, "busid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from pyanaconda.modules.storage.devicetree.rescue import FindExistingSystemsTask, \
MountExistingSystemTask
from pyanaconda.modules.storage.devicetree.root import Root
from parted import PARTITION_NORMAL


class DeviceTreeInterfaceTestCase(unittest.TestCase):
Expand Down Expand Up @@ -341,6 +342,26 @@ def test_get_zfcp_device_data(self):
"path-id": "ccw-0.0.010a-fc-0x5005076300c18154-lun-0x5719000000000000"
})

def test_get_parted_device_data(self):
sda1 = PartitionDevice(
"dev1",
size=Size("500 MiB"),
fmt=get_format("ext4", exists=True)
)
attrs = {
'type': PARTITION_NORMAL,
'getLength.return_value': int(sda1.size),
'getFlag.return_value': 0,
'name': "Microsoft reserved partition",
'number': 1
}
sda1._parted_partition = Mock()
sda1._parted_partition.configure_mock(**attrs)
self._add_device(sda1)

data = self.interface.GetDeviceData("dev1")
assert data['attrs']['partition-label'] == "Microsoft reserved partition"

def test_get_format_data(self):
"""Test GetFormatData."""
fmt1 = get_format(
Expand Down

0 comments on commit d27cd3e

Please sign in to comment.