Skip to content
Snippets Groups Projects
Commit f87548b5 authored by Iustin Pop's avatar Iustin Pop
Browse files

bdev: Do not call Assemble() on children

The caller of dev.Assemble() (backend._RecursiveAssembleBD) is doing an
explicit recursion over all the children of the device, with better
error reporting. As such, we don't need this repeated assembly inside
the base BlockDev class.

Reviewed-by: ultrotter
parent ea33068f
No related branches found
No related tags found
No related merge requests found
...@@ -87,36 +87,16 @@ class BlockDev(object): ...@@ -87,36 +87,16 @@ class BlockDev(object):
def Assemble(self): def Assemble(self):
"""Assemble the device from its components. """Assemble the device from its components.
If this is a plain block device (e.g. LVM) than assemble does Implementations of this method by child classes must ensure that:
nothing, as the LVM has no children and we don't put logical - after the device has been assembled, it knows its major/minor
volumes offline. numbers; this allows other devices (usually parents) to probe
correctly for their children
One guarantee is that after the device has been assembled, it - calling this method on an existing, in-use device is safe
knows its major/minor numbers. This allows other devices (usually - if the device is already configured (and in an OK state),
parents) to probe correctly for their children. this method is idempotent
""" """
status = True return True
for child in self._children:
if not isinstance(child, BlockDev):
raise TypeError("Invalid child passed of type '%s'" % type(child))
if not status:
break
status = status and child.Assemble()
if not status:
break
try:
child.Open()
except errors.BlockDeviceError:
for child in self._children:
child.Shutdown()
raise
if not status:
for child in self._children:
child.Shutdown()
return status
def Attach(self): def Attach(self):
"""Find a device which matches our config and attach to it. """Find a device which matches our config and attach to it.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment