Revision 9b221ea4 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
9340 | 9340 |
@type excl_stor: boolean |
9341 | 9341 |
@param excl_stor: Whether exclusive_storage is active for the node |
9342 | 9342 |
|
9343 |
@return: list of created devices |
|
9343 | 9344 |
""" |
9344 |
if device.CreateOnSecondary(): |
|
9345 |
force_create = True |
|
9345 |
created_devices = [] |
|
9346 |
try: |
|
9347 |
if device.CreateOnSecondary(): |
|
9348 |
force_create = True |
|
9346 | 9349 |
|
9347 |
if device.children: |
|
9348 |
for child in device.children: |
|
9349 |
_CreateBlockDevInner(lu, node, instance, child, force_create, |
|
9350 |
info, force_open, excl_stor) |
|
9350 |
if device.children: |
|
9351 |
for child in device.children: |
|
9352 |
devs = _CreateBlockDevInner(lu, node, instance, child, force_create, |
|
9353 |
info, force_open, excl_stor) |
|
9354 |
created_devices.extend(devs) |
|
9351 | 9355 |
|
9352 |
if not force_create: |
|
9353 |
return |
|
9356 |
if not force_create: |
|
9357 |
return created_devices |
|
9358 |
|
|
9359 |
_CreateSingleBlockDev(lu, node, instance, device, info, force_open, |
|
9360 |
excl_stor) |
|
9361 |
# The device has been completely created, so there is no point in keeping |
|
9362 |
# its subdevices in the list. We just add the device itself instead. |
|
9363 |
created_devices = [(node, device)] |
|
9364 |
return created_devices |
|
9354 | 9365 |
|
9355 |
_CreateSingleBlockDev(lu, node, instance, device, info, force_open, |
|
9356 |
excl_stor) |
|
9366 |
except errors.DeviceCreationError, e: |
|
9367 |
e.created_devices.extend(created_devices) |
|
9368 |
raise e |
|
9369 |
except errors.OpExecError, e: |
|
9370 |
raise errors.DeviceCreationError(str(e), created_devices) |
|
9357 | 9371 |
|
9358 | 9372 |
|
9359 | 9373 |
def _CreateSingleBlockDev(lu, node, instance, device, info, force_open, |
... | ... | |
9716 | 9730 |
except errors.OpExecError: |
9717 | 9731 |
logging.warning("Creating disk %s for instance '%s' failed", |
9718 | 9732 |
idx, instance.name) |
9733 |
except errors.DeviceCreationError, e: |
|
9734 |
logging.warning("Creating disk %s for instance '%s' failed", |
|
9735 |
idx, instance.name) |
|
9736 |
disks_created.extend(e.created_devices) |
|
9719 | 9737 |
for (node, disk) in disks_created: |
9720 | 9738 |
lu.cfg.SetDiskID(disk, node) |
9721 | 9739 |
result = lu.rpc.call_blockdev_remove(node, disk) |
9722 | 9740 |
if result.fail_msg: |
9723 | 9741 |
logging.warning("Failed to remove newly-created disk %s on node %s:" |
9724 | 9742 |
" %s", device, node, result.fail_msg) |
9725 |
raise |
|
9743 |
raise errors.OpExecError(e.message)
|
|
9726 | 9744 |
|
9727 | 9745 |
|
9728 | 9746 |
def _RemoveDisks(lu, instance, target_node=None, ignore_failures=False): |
Also available in: Unified diff