Skip to content

Commit

Permalink
Store disklabel and partition UUIDs when available.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlehman committed Feb 1, 2016
1 parent 50a74ce commit 851a49d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions blivet/devices/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PartitionDevice(StorageDevice):
_resizable = True
default_size = DEFAULT_PART_SIZE

def __init__(self, name, fmt=None,
def __init__(self, name, fmt=None, uuid=None,
size=None, grow=False, maxsize=None, start=None, end=None,
major=None, minor=None, bootable=None,
sysfs_path='', parents=None, exists=False,
Expand All @@ -85,6 +85,7 @@ def __init__(self, name, fmt=None,
For existing partitions only:
:keyword str uuid: partition UUID (not filesystem UUID)
:keyword major: the device major
:type major: long
:keyword minor: the device minor
Expand Down Expand Up @@ -142,7 +143,7 @@ def __init__(self, name, fmt=None,
else:
size = self.default_size

StorageDevice.__init__(self, name, fmt=fmt, size=size,
StorageDevice.__init__(self, name, fmt=fmt, uuid=uuid, size=size,
major=major, minor=minor, exists=exists,
sysfs_path=sysfs_path, parents=parents)

Expand Down
1 change: 1 addition & 0 deletions blivet/formats/disklabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, **kwargs):
"""
:keyword device: full path to the block device node
:type device: str
:keyword str uuid: disklabel UUID
:keyword label_type: type of disklabel to create
:type label_type: str
:keyword exists: whether the formatting exists
Expand Down
1 change: 1 addition & 0 deletions blivet/populator/helpers/disklabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def run(self):
try:
fmt = formats.get_format("disklabel",
device=self.device.path,
uuid=udev.device_get_disklabel_uuid(self.data),
exists=True)
except InvalidDiskLabelError as e:
log.info("no usable disklabel on %s", self.device.name)
Expand Down
1 change: 1 addition & 0 deletions blivet/populator/helpers/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def run(self):
device = None
try:
device = PartitionDevice(name, sysfs_path=sysfs_path,
uuid=udev.device_get_partition_uuid(self.data),
major=udev.device_get_major(self.data),
minor=udev.device_get_minor(self.data),
exists=True, parents=[disk])
Expand Down
8 changes: 8 additions & 0 deletions blivet/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@ def device_get_disklabel_type(info):

return info.get("ID_PART_TABLE_TYPE")


def device_get_disklabel_uuid(info):
return info.get("ID_PART_TABLE_UUID")


def device_get_partition_uuid(info):
return info.get("ID_PART_ENTRY_UUID")

# iscsi disks' ID_PATH form depends on the driver:
# for software iscsi:
# ip-${iscsi_address}:${iscsi_port}-iscsi-${iscsi_tgtname}-lun-${lun}
Expand Down

0 comments on commit 851a49d

Please sign in to comment.