Revision c6a9dffa
b/lib/backend.py | ||
---|---|---|
1539 | 1539 |
@type disks: list of L{objects.Disk} |
1540 | 1540 |
@param disks: the list of disks which we should query |
1541 | 1541 |
@rtype: disk |
1542 |
@return: |
|
1543 |
a list of (mirror_done, estimated_time) tuples, which |
|
1544 |
are the result of L{bdev.BlockDev.CombinedSyncStatus} |
|
1542 |
@return: List of L{objects.BlockDevStatus}, one for each disk |
|
1545 | 1543 |
@raise errors.BlockDeviceError: if any of the disks cannot be |
1546 | 1544 |
found |
1547 | 1545 |
|
... | ... | |
1557 | 1555 |
return stats |
1558 | 1556 |
|
1559 | 1557 |
|
1558 |
def BlockdevGetmirrorstatusMulti(disks): |
|
1559 |
"""Get the mirroring status of a list of devices. |
|
1560 |
|
|
1561 |
@type disks: list of L{objects.Disk} |
|
1562 |
@param disks: the list of disks which we should query |
|
1563 |
@rtype: disk |
|
1564 |
@return: List of tuples, (bool, status), one for each disk; bool denotes |
|
1565 |
success/failure, status is L{objects.BlockDevStatus} on success, string |
|
1566 |
otherwise |
|
1567 |
|
|
1568 |
""" |
|
1569 |
result = [] |
|
1570 |
for disk in disks: |
|
1571 |
try: |
|
1572 |
rbd = _RecursiveFindBD(disk) |
|
1573 |
if rbd is None: |
|
1574 |
result.append((False, "Can't find device %s" % disk)) |
|
1575 |
continue |
|
1576 |
|
|
1577 |
status = rbd.CombinedSyncStatus() |
|
1578 |
except errors.BlockDeviceError, err: |
|
1579 |
logging.exception("Error while getting disk status") |
|
1580 |
result.append((False, str(err))) |
|
1581 |
else: |
|
1582 |
result.append((True, status)) |
|
1583 |
|
|
1584 |
assert len(disks) == len(result) |
|
1585 |
|
|
1586 |
return result |
|
1587 |
|
|
1588 |
|
|
1560 | 1589 |
def _RecursiveFindBD(disk): |
1561 | 1590 |
"""Check if a device is activated. |
1562 | 1591 |
|
b/lib/cmdlib.py | ||
---|---|---|
1539 | 1539 |
_ErrorIf(test, self.EINSTANCEWRONGNODE, instance, |
1540 | 1540 |
"instance should not run on node %s", node) |
1541 | 1541 |
|
1542 |
diskdata = [(nname, disk, idx)
|
|
1542 |
diskdata = [(nname, success, status, idx)
|
|
1543 | 1543 |
for (nname, disks) in diskstatus.items() |
1544 |
for idx, disk in enumerate(disks)]
|
|
1544 |
for idx, (success, status) in enumerate(disks)]
|
|
1545 | 1545 |
|
1546 |
for nname, bdev_status, idx in diskdata: |
|
1547 |
_ErrorIf(not bdev_status,
|
|
1546 |
for nname, success, bdev_status, idx in diskdata:
|
|
1547 |
_ErrorIf(instanceconfig.admin_up and not success,
|
|
1548 | 1548 |
self.EINSTANCEFAULTYDISK, instance, |
1549 |
"couldn't retrieve status for disk/%s on %s", idx, nname) |
|
1550 |
_ErrorIf(bdev_status and bdev_status.ldisk_status == constants.LDS_FAULTY, |
|
1549 |
"couldn't retrieve status for disk/%s on %s: %s", |
|
1550 |
idx, nname, bdev_status) |
|
1551 |
_ErrorIf((instanceconfig.admin_up and success and |
|
1552 |
bdev_status.ldisk_status == constants.LDS_FAULTY), |
|
1551 | 1553 |
self.EINSTANCEFAULTYDISK, instance, |
1552 | 1554 |
"disk/%s on %s is faulty", idx, nname) |
1553 | 1555 |
|
b/lib/rpc.py | ||
---|---|---|
1057 | 1057 |
[dict((name, [dsk.ToDict() for dsk in disks]) |
1058 | 1058 |
for name, disks in node_disks.items())]) |
1059 | 1059 |
for nres in result.values(): |
1060 |
if not nres.fail_msg: |
|
1061 |
nres.payload = [objects.BlockDevStatus.FromDict(i) |
|
1062 |
for i in nres.payload] |
|
1060 |
if nres.fail_msg: |
|
1061 |
continue |
|
1062 |
|
|
1063 |
for idx, (success, status) in enumerate(nres.payload): |
|
1064 |
if success: |
|
1065 |
nres.payload[idx] = (success, objects.BlockDevStatus.FromDict(status)) |
|
1066 |
|
|
1063 | 1067 |
return result |
1064 | 1068 |
|
1065 | 1069 |
@_RpcTimeout(_TMO_NORMAL) |
b/lib/server/noded.py | ||
---|---|---|
283 | 283 |
disks = [objects.Disk.FromDict(dsk_s) |
284 | 284 |
for dsk_s in node_disks.get(node_name, [])] |
285 | 285 |
|
286 |
return [status.ToDict() |
|
287 |
for status in backend.BlockdevGetmirrorstatus(disks)] |
|
286 |
result = [] |
|
287 |
|
|
288 |
for (success, status) in backend.BlockdevGetmirrorstatusMulti(disks): |
|
289 |
if success: |
|
290 |
result.append((success, status.ToDict())) |
|
291 |
else: |
|
292 |
result.append((success, status)) |
|
293 |
|
|
294 |
return result |
|
288 | 295 |
|
289 | 296 |
@staticmethod |
290 | 297 |
def perspective_blockdev_find(params): |
Also available in: Unified diff