Revision f87548b5 lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
87 | 87 |
def Assemble(self): |
88 | 88 |
"""Assemble the device from its components. |
89 | 89 |
|
90 |
If this is a plain block device (e.g. LVM) than assemble does
|
|
91 |
nothing, as the LVM has no children and we don't put logical
|
|
92 |
volumes offline.
|
|
93 |
|
|
94 |
One guarantee is that after the device has been assembled, it
|
|
95 |
knows its major/minor numbers. This allows other devices (usually
|
|
96 |
parents) to probe correctly for their children.
|
|
90 |
Implementations of this method by child classes must ensure that:
|
|
91 |
- after the device has been assembled, it knows its major/minor
|
|
92 |
numbers; this allows other devices (usually parents) to probe
|
|
93 |
correctly for their children |
|
94 |
- calling this method on an existing, in-use device is safe
|
|
95 |
- if the device is already configured (and in an OK state),
|
|
96 |
this method is idempotent
|
|
97 | 97 |
|
98 | 98 |
""" |
99 |
status = True |
|
100 |
for child in self._children: |
|
101 |
if not isinstance(child, BlockDev): |
|
102 |
raise TypeError("Invalid child passed of type '%s'" % type(child)) |
|
103 |
if not status: |
|
104 |
break |
|
105 |
status = status and child.Assemble() |
|
106 |
if not status: |
|
107 |
break |
|
108 |
|
|
109 |
try: |
|
110 |
child.Open() |
|
111 |
except errors.BlockDeviceError: |
|
112 |
for child in self._children: |
|
113 |
child.Shutdown() |
|
114 |
raise |
|
115 |
|
|
116 |
if not status: |
|
117 |
for child in self._children: |
|
118 |
child.Shutdown() |
|
119 |
return status |
|
99 |
return True |
|
120 | 100 |
|
121 | 101 |
def Attach(self): |
122 | 102 |
"""Find a device which matches our config and attach to it. |
Also available in: Unified diff