Skip to content

Commit

Permalink
Treat existing md arrays whose members are all disks like disks.
Browse files Browse the repository at this point in the history
Similarly, if all members of an existing array are partitionable
the array is also partitionable.

Resolves: rhbz#1197582
  • Loading branch information
dwlehman committed May 28, 2015
1 parent 0bd1e23 commit a3c1269
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions blivet/devices/md.py
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit a3c1269

Please sign in to comment.