[master 3/3] Treat existing md arrays whose members are all disks like disks.

dwlehman installerbot-noreply at redhat.com
Thu May 28 18:06:32 UTC 2015


From: David Lehman <dlehman at redhat.com>

Similarly, if all members of an existing array are partitionable
the array is also partitionable.

Resolves: rhbz#1197582
---
 blivet/devices/md.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/blivet/devices/md.py b/blivet/devices/md.py
index d81f058..70cab0b 100644
--- a/blivet/devices/md.py
+++ b/blivet/devices/md.py
@@ -78,6 +78,19 @@ def __init__(self, name, level=None, major=None, minor=None, size=None,
             :type metadataVersion: str (eg: "0.90")
             :keyword minor: the device minor (obsolete?)
             :type minor: int
+
+            .. note::
+
+                An instance of this class whose :attr:'exists' attribute is
+                True and whose parent/member devices are all partitionable is
+                also considered to be partitionable.
+
+            .. note::
+
+                An instance of this class whose :attr:'exists' attribute is
+                True and whose parent/member devices are all disks is also
+                treated like a disk.
+
         """
         # pylint: disable=unused-argument
 
@@ -323,6 +336,13 @@ def _addParent(self, member):
             self._totalDevices += 1
             self.memberDevices += 1
 
+        # The new member hasn't been added yet, so account for it explicitly.
+        is_disk = self.isDisk and member.isDisk
+        for p in self.parents:
+            p.format._hidden = is_disk
+
+        member.format._hidden = is_disk
+
     def _removeParent(self, member):
         error_msg = self._validateParentRemoval(self.level, member)
         if error_msg:
@@ -447,6 +467,10 @@ def teardown(self, recursive=None):
         # see comment just above md_deactivate call
         self._preTeardown(recursive=recursive)
 
+        if self.isDisk:
+            # treat arrays whose members are disks as partitionable disks
+            return
+
         # We don't really care what the array's state is. If the device
         # file exists, we want to deactivate it. mdraid has too many
         # states.
@@ -535,6 +559,14 @@ def formatArgs(self):
     def model(self):
         return self.description
 
+    @property
+    def partitionable(self):
+        return self.exists and all(p.partitionable for p in self.parents)
+
+    @property
+    def isDisk(self):
+        return self.exists and all(p.isDisk for p in self.parents)
+
     def dracutSetupArgs(self):
         return set(["rd.md.uuid=%s" % self.mdadmFormatUUID])
 


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


More information about the anaconda-patches mailing list