[rhel7-branch 1/1] Mock up a parted.Device for openlmi-storage.
dwlehman
installerbot-noreply at redhat.com
Tue Sep 15 15:53:55 UTC 2015
From: David Lehman <dlehman at redhat.com>
StorageDevice.partedDevice was removed because instantiating parted.Device
generates uevents, but openlmi-storage depends on some of the information
it contains. To preserve API, we add these bits back.
Resolves: rhbz#1238581
---
blivet/devices/storage.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index add18e6..02b8268 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -38,6 +38,15 @@
from .device import Device
from .lib import LINUX_SECTOR_SIZE
+# openlmi-storage was using StorageDevice.partedDevice, which I invited by
+# naming it as a public attribute. We have removed it, and aren't bringing it
+# back, so this allows us to put back just the bits that openlmi-storage expects
+# to find.
+from collections import namedtuple
+PartedAlignment = namedtuple('PartedAlignment', ['grainSize'])
+PartedDevice = namedtuple('PartedDevice',
+ ['length', 'sectorSize', 'optimumAlignment'])
+
class StorageDevice(Device):
""" A generic storage device.
@@ -99,7 +108,6 @@ def __init__(self, name, fmt=None, uuid=None,
# Set these fields before super call as MDRaidArrayDevice._addParent()
# reads them, through calls to status() and partedDevice().
self.sysfsPath = sysfsPath
- self._partedDevice = None
self._format = None
@@ -127,6 +135,7 @@ def __init__(self, name, fmt=None, uuid=None,
self.deviceLinks = []
+ self.partedDevice = None
if self.exists and self.status:
self.updateSize()
@@ -572,6 +581,18 @@ def readCurrentSize(self):
blocks = int(util.get_sysfs_attr(self.sysfsPath, "size"))
size = Size(blocks * LINUX_SECTOR_SIZE)
+ # mock up a partedDevice for openlmi-storage
+ sector_size = int(util.get_sysfs_attr(self.sysfsPath,
+ "queue/logical_block_size"))
+ length = size // sector_size
+ optimum_io_size = (int(util.get_sysfs_attr(self.sysfsPath,
+ "queue/optimal_io_size"))
+ or int(Size("1 MiB")))
+ alignment = PartedAlignment(optimum_io_size // sector_size)
+ self.partedDevice = PartedDevice(length=length,
+ sectorSize=sector_size,
+ optimalAlignment=alignment)
+
return size
@property
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/d4d2ff1576bef7235eec79ce3694d53eb3e0d539
More information about the anaconda-patches
mailing list