[PATCH 13/20] Use BlockDev's DM plugin to work with DM RAID sets

vpodzime installerbot-noreply at redhat.com
Fri Feb 27 15:31:52 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

That's the only remaining functionality we needed from pyblock so we can drop it
as a dependency, be grateful for it's years of service and put it into
retirement.
---
 blivet/devices/device.py |  2 +-
 blivet/devices/disk.py   | 16 +++++-----------
 blivet/devicetree.py     | 15 ++++++---------
 python-blivet.spec       |  2 --
 4 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/blivet/devices/device.py b/blivet/devices/device.py
index 313abf8..a23a74c 100644
--- a/blivet/devices/device.py
+++ b/blivet/devices/device.py
@@ -96,7 +96,7 @@ def __deepcopy__(self, memo):
             For these parted objects, we just do a shallow copy.
         """
         return util.variable_copy(self, memo,
-           omit=('_raidSet', 'node'),
+           omit=('node'),
            shallow=('_partedDevice', '_partedPartition'))
 
     def __repr__(self):
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
index f14638d..ec0ea7e 100644
--- a/blivet/devices/disk.py
+++ b/blivet/devices/disk.py
@@ -21,6 +21,7 @@
 #
 
 import os
+from gi.repository import BlockDev as blockdev
 
 from .. import errors
 from .. import util
@@ -172,7 +173,7 @@ class DMRaidArrayDevice(DMDevice, ContainerDevice):
     _formatClassName = property(lambda s: "dmraidmember")
     _formatUUIDAttr = property(lambda s: None)
 
-    def __init__(self, name, raidSet=None, fmt=None,
+    def __init__(self, name, fmt=None,
                  size=None, parents=None, sysfsPath=''):
         """
             :param name: the device name (generally a device node's basename)
@@ -185,8 +186,6 @@ def __init__(self, name, raidSet=None, fmt=None,
             :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
             :keyword sysfsPath: sysfs device path
             :type sysfsPath: str
-            :keyword raidSet: the RaidSet object from block
-            :type raidSet: :class:`block.RaidSet`
 
             DMRaidArrayDevices always exist. Blivet cannot create or destroy
             them.
@@ -195,11 +194,6 @@ def __init__(self, name, raidSet=None, fmt=None,
                                                 parents=parents, exists=True,
                                                 sysfsPath=sysfsPath)
 
-        self._raidSet = raidSet
-
-    @property
-    def raidSet(self):
-        return self._raidSet
 
     @property
     def devices(self):
@@ -210,13 +204,13 @@ def deactivate(self):
         """ Deactivate the raid set. """
         log_method_call(self, self.name, status=self.status)
         # This call already checks if the set is not active.
-        self._raidSet.deactivate()
+        blockdev.dm_deactivate_raid_set(self.name)
 
     def activate(self):
         """ Activate the raid set. """
         log_method_call(self, self.name, status=self.status)
         # This call already checks if the set is active.
-        self._raidSet.activate(mknod=True)
+        blockdev.dm_activate_raid_set(self.name)
         udev.settle()
 
     def _setup(self, orig=False):
@@ -242,7 +236,7 @@ def _remove(self, member):
 
     @property
     def description(self):
-        return "BIOS RAID set (%s)" % self._raidSet.rs.set_type
+        return "BIOS RAID set (%s)" % blockdev.dm_get_raid_set_type(self.name)
 
     @property
     def model(self):
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index df13c57..bb19e70 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -21,7 +21,6 @@
 #
 
 import os
-import block
 import re
 import shutil
 import pprint
@@ -1656,23 +1655,21 @@ def handleUdevDMRaidMemberFormat(self, info, device):
         minor = udev.device_get_minor(info)
 
         # Have we already created the DMRaidArrayDevice?
-        rss = block.getRaidSetFromRelatedMem(uuid=uuid, name=name,
-                                            major=major, minor=minor)
-        if len(rss) == 0:
+        rs_names = blockdev.dm_get_member_raid_sets(uuid, name, major, minor)
+        if len(rs_names) == 0:
             log.warning("dmraid member %s does not appear to belong to any "
                         "array", device.name)
             return
 
-        for rs in rss:
-            dm_array = self.getDeviceByName(rs.name, incomplete=True)
+        for rs_name in rs_names:
+            dm_array = self.getDeviceByName(rs_name, incomplete=True)
             if dm_array is not None:
                 # We add the new device.
                 dm_array.parents.append(device)
             else:
                 # Activate the Raid set.
-                rs.activate(mknod=True)
-                dm_array = DMRaidArrayDevice(rs.name,
-                                             raidSet=rs,
+                blockdev.dm_activate_raid_set(rs_name)
+                dm_array = DMRaidArrayDevice(rs_name,
                                              parents=[device])
 
                 self._addDevice(dm_array)
diff --git a/python-blivet.spec b/python-blivet.spec
index a41088e..7bf50ab 100644
--- a/python-blivet.spec
+++ b/python-blivet.spec
@@ -15,7 +15,6 @@ Source0: http://github.com/dwlehman/blivet/archive/%{realname}-%{version}.tar.gz
 %define pykickstartver 1.99.22
 %define partedver 1.8.1
 %define pypartedver 2.5-2
-%define pythonpyblockver 0.45
 %define e2fsver 1.41.0
 %define pythoncryptsetupver 0.1.1
 %define utillinuxver 2.15.1
@@ -41,7 +40,6 @@ Requires: lvm2 >= %{lvm2ver}
 Requires: dosfstools
 Requires: e2fsprogs >= %{e2fsver}
 Requires: btrfs-progs
-Requires: python-pyblock >= %{pythonpyblockver}
 Requires: device-mapper-multipath
 Requires: lsof
 Requires: libblockdev >= %{libblockdevver}


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/bae5a0ce94b6ac1716f5f8153bceee63aeada369


More information about the anaconda-patches mailing list