Revision 6ef8077e
b/lib/backend.py | ||
---|---|---|
2149 | 2149 |
return rbd.GetSyncStatus() |
2150 | 2150 |
|
2151 | 2151 |
|
2152 |
def BlockdevGetsize(disks):
|
|
2152 |
def BlockdevGetdimensions(disks):
|
|
2153 | 2153 |
"""Computes the size of the given disks. |
2154 | 2154 |
|
2155 | 2155 |
If a disk is not found, returns None instead. |
... | ... | |
2158 | 2158 |
@param disks: the list of disk to compute the size for |
2159 | 2159 |
@rtype: list |
2160 | 2160 |
@return: list with elements None if the disk cannot be found, |
2161 |
otherwise the size |
|
2161 |
otherwise the pair (size, spindles), where spindles is None if the |
|
2162 |
device doesn't support that |
|
2162 | 2163 |
|
2163 | 2164 |
""" |
2164 | 2165 |
result = [] |
... | ... | |
2171 | 2172 |
if rbd is None: |
2172 | 2173 |
result.append(None) |
2173 | 2174 |
else: |
2174 |
result.append(rbd.GetActualSize())
|
|
2175 |
result.append(rbd.GetActualDimensions())
|
|
2175 | 2176 |
return result |
2176 | 2177 |
|
2177 | 2178 |
|
b/lib/cmdlib/cluster.py | ||
---|---|---|
533 | 533 |
newl = [v[2].Copy() for v in dskl] |
534 | 534 |
for dsk in newl: |
535 | 535 |
self.cfg.SetDiskID(dsk, node) |
536 |
result = self.rpc.call_blockdev_getsize(node, newl)
|
|
536 |
result = self.rpc.call_blockdev_getdimensions(node, newl)
|
|
537 | 537 |
if result.fail_msg: |
538 |
self.LogWarning("Failure in blockdev_getsize call to node"
|
|
538 |
self.LogWarning("Failure in blockdev_getdimensions call to node"
|
|
539 | 539 |
" %s, ignoring", node) |
540 | 540 |
continue |
541 | 541 |
if len(result.payload) != len(dskl): |
... | ... | |
544 | 544 |
self.LogWarning("Invalid result from node %s, ignoring node results", |
545 | 545 |
node) |
546 | 546 |
continue |
547 |
for ((instance, idx, disk), size) in zip(dskl, result.payload):
|
|
548 |
if size is None:
|
|
547 |
for ((instance, idx, disk), dimensions) in zip(dskl, result.payload):
|
|
548 |
if dimensions is None:
|
|
549 | 549 |
self.LogWarning("Disk %d of instance %s did not return size" |
550 | 550 |
" information, ignoring", idx, instance.name) |
551 | 551 |
continue |
552 |
if not isinstance(dimensions, (tuple, list)): |
|
553 |
self.LogWarning("Disk %d of instance %s did not return valid" |
|
554 |
" dimension information, ignoring", idx, |
|
555 |
instance.name) |
|
556 |
continue |
|
557 |
(size, _) = dimensions |
|
552 | 558 |
if not isinstance(size, (int, long)): |
553 | 559 |
self.LogWarning("Disk %d of instance %s did not return valid" |
554 | 560 |
" size information, ignoring", idx, instance.name) |
b/lib/cmdlib/instance_storage.py | ||
---|---|---|
1440 | 1440 |
|
1441 | 1441 |
if wipe_disks: |
1442 | 1442 |
# Get disk size from primary node for wiping |
1443 |
result = self.rpc.call_blockdev_getsize(instance.primary_node, [disk]) |
|
1443 |
result = self.rpc.call_blockdev_getdimensions(instance.primary_node, |
|
1444 |
[disk]) |
|
1444 | 1445 |
result.Raise("Failed to retrieve disk size from node '%s'" % |
1445 | 1446 |
instance.primary_node) |
1446 | 1447 |
|
1447 |
(disk_size_in_bytes, ) = result.payload
|
|
1448 |
(disk_dimensions, ) = result.payload
|
|
1448 | 1449 |
|
1449 |
if disk_size_in_bytes is None:
|
|
1450 |
if disk_dimensions is None:
|
|
1450 | 1451 |
raise errors.OpExecError("Failed to retrieve disk size from primary" |
1451 | 1452 |
" node '%s'" % instance.primary_node) |
1453 |
(disk_size_in_bytes, _) = disk_dimensions |
|
1452 | 1454 |
|
1453 | 1455 |
old_disk_size = _DiskSizeInBytesToMebibytes(self, disk_size_in_bytes) |
1454 | 1456 |
|
b/lib/rpc_defs.py | ||
---|---|---|
384 | 384 |
("instance_name", None, None), |
385 | 385 |
("disks", ED_OBJECT_DICT_LIST, None), |
386 | 386 |
], None, None, "Closes the given block devices"), |
387 |
("blockdev_getsize", SINGLE, None, constants.RPC_TMO_NORMAL, [
|
|
387 |
("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [
|
|
388 | 388 |
("disks", ED_OBJECT_DICT_LIST, None), |
389 |
], None, None, "Returns the size of the given disks"),
|
|
389 |
], None, None, "Returns size and spindles of the given disks"),
|
|
390 | 390 |
("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [ |
391 | 391 |
("nodes_ip", None, None), |
392 | 392 |
("disks", ED_OBJECT_DICT_LIST, None), |
b/lib/server/noded.py | ||
---|---|---|
379 | 379 |
return backend.BlockdevClose(params[0], disks) |
380 | 380 |
|
381 | 381 |
@staticmethod |
382 |
def perspective_blockdev_getsize(params):
|
|
382 |
def perspective_blockdev_getdimensions(params):
|
|
383 | 383 |
"""Compute the sizes of the given block devices. |
384 | 384 |
|
385 | 385 |
""" |
386 | 386 |
disks = [objects.Disk.FromDict(cf) for cf in params[0]] |
387 |
return backend.BlockdevGetsize(disks)
|
|
387 |
return backend.BlockdevGetdimensions(disks)
|
|
388 | 388 |
|
389 | 389 |
@staticmethod |
390 | 390 |
def perspective_blockdev_export(params): |
Also available in: Unified diff