Revision 1d5f1b4c lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
6527 | 6527 |
|
6528 | 6528 |
""" |
6529 | 6529 |
node = instance.primary_node |
6530 |
for idx, device in enumerate(instance.disks): |
|
6531 |
lu.LogInfo("* Wiping disk %d", idx) |
|
6532 |
logging.info("Wiping disk %d for instance %s", idx, instance.name) |
|
6533 |
|
|
6534 |
# The wipe size is MIN_WIPE_CHUNK_PERCENT % of the instance disk but |
|
6535 |
# MAX_WIPE_CHUNK at max |
|
6536 |
wipe_chunk_size = min(constants.MAX_WIPE_CHUNK, device.size / 100.0 * |
|
6537 |
constants.MIN_WIPE_CHUNK_PERCENT) |
|
6538 |
|
|
6539 |
offset = 0 |
|
6540 |
size = device.size |
|
6541 |
last_output = 0 |
|
6542 |
start_time = time.time() |
|
6543 |
|
|
6544 |
while offset < size: |
|
6545 |
wipe_size = min(wipe_chunk_size, size - offset) |
|
6546 |
result = lu.rpc.call_blockdev_wipe(node, device, offset, wipe_size) |
|
6547 |
result.Raise("Could not wipe disk %d at offset %d for size %d" % |
|
6548 |
(idx, offset, wipe_size)) |
|
6549 |
now = time.time() |
|
6550 |
offset += wipe_size |
|
6551 |
if now - last_output >= 60: |
|
6552 |
eta = _CalcEta(now - start_time, offset, size) |
|
6553 |
lu.LogInfo(" - done: %.1f%% ETA: %s" % |
|
6554 |
(offset / float(size) * 100, utils.FormatSeconds(eta))) |
|
6555 |
last_output = now |
|
6530 |
logging.info("Pause sync of instance %s disks", instance.name) |
|
6531 |
result = lu.rpc.call_blockdev_pause_resume_sync(node, instance.disks, True) |
|
6532 |
|
|
6533 |
for idx, success in enumerate(result.payload): |
|
6534 |
if not success: |
|
6535 |
logging.warn("pause-sync of instance %s for disks %d failed", |
|
6536 |
instance.name, idx) |
|
6537 |
|
|
6538 |
try: |
|
6539 |
for idx, device in enumerate(instance.disks): |
|
6540 |
lu.LogInfo("* Wiping disk %d", idx) |
|
6541 |
logging.info("Wiping disk %d for instance %s", idx, instance.name) |
|
6542 |
|
|
6543 |
# The wipe size is MIN_WIPE_CHUNK_PERCENT % of the instance disk but |
|
6544 |
# MAX_WIPE_CHUNK at max |
|
6545 |
wipe_chunk_size = min(constants.MAX_WIPE_CHUNK, device.size / 100.0 * |
|
6546 |
constants.MIN_WIPE_CHUNK_PERCENT) |
|
6547 |
|
|
6548 |
offset = 0 |
|
6549 |
size = device.size |
|
6550 |
last_output = 0 |
|
6551 |
start_time = time.time() |
|
6552 |
|
|
6553 |
while offset < size: |
|
6554 |
wipe_size = min(wipe_chunk_size, size - offset) |
|
6555 |
result = lu.rpc.call_blockdev_wipe(node, device, offset, wipe_size) |
|
6556 |
result.Raise("Could not wipe disk %d at offset %d for size %d" % |
|
6557 |
(idx, offset, wipe_size)) |
|
6558 |
now = time.time() |
|
6559 |
offset += wipe_size |
|
6560 |
if now - last_output >= 60: |
|
6561 |
eta = _CalcEta(now - start_time, offset, size) |
|
6562 |
lu.LogInfo(" - done: %.1f%% ETA: %s" % |
|
6563 |
(offset / float(size) * 100, utils.FormatSeconds(eta))) |
|
6564 |
last_output = now |
|
6565 |
finally: |
|
6566 |
logging.info("Resume sync of instance %s disks", instance.name) |
|
6567 |
|
|
6568 |
result = lu.rpc.call_blockdev_pause_resume_sync(node, instance.disks, False) |
|
6569 |
|
|
6570 |
for idx, success in enumerate(result.payload): |
|
6571 |
if not success: |
|
6572 |
lu.LogWarning("Warning: Resume sync of disk %d failed. Please have a" |
|
6573 |
" look at the status and troubleshoot the issue.", idx) |
|
6574 |
logging.warn("resume-sync of instance %s for disks %d failed", |
|
6575 |
instance.name, idx) |
|
6556 | 6576 |
|
6557 | 6577 |
|
6558 | 6578 |
def _CreateDisks(lu, instance, to_skip=None, target_node=None): |
Also available in: Unified diff