Commit a59faf4b authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement grow dry-run at RPC level


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 7fe23d47
......@@ -2226,7 +2226,7 @@ def OSEnvironment(instance, inst_os, debug=0):
return result
def BlockdevGrow(disk, amount):
def BlockdevGrow(disk, amount, dryrun):
"""Grow a stack of block devices.
This function is called recursively, with the childrens being the
......@@ -2234,10 +2234,14 @@ def BlockdevGrow(disk, amount):
@type disk: L{objects.Disk}
@param disk: the disk to be grown
@type amount: integer
@param amount: the amount (in mebibytes) to grow with
@type dryrun: boolean
@param dryrun: whether to execute the operation in simulation mode
only, without actually increasing the size
@rtype: (status, result)
@return: a tuple with the status of the operation
(True/False), and the errors message if status
is False
@return: a tuple with the status of the operation (True/False), and
the errors message if status is False
"""
r_dev = _RecursiveFindBD(disk)
......@@ -2245,7 +2249,7 @@ def BlockdevGrow(disk, amount):
_Fail("Cannot find block device %s", disk)
try:
r_dev.Grow(amount, False)
r_dev.Grow(amount, dryrun)
except errors.BlockDeviceError, err:
_Fail("Failed to grow block device: %s", err, exc=True)
......
......@@ -9519,7 +9519,7 @@ class LUInstanceGrowDisk(LogicalUnit):
for node in instance.all_nodes:
self.cfg.SetDiskID(disk, node)
result = self.rpc.call_blockdev_grow(node, disk, self.op.amount)
result = self.rpc.call_blockdev_grow(node, disk, self.op.amount, False)
result.Raise("Grow request failed to node %s" % node)
# TODO: Rewrite code to work properly
......
......@@ -1261,14 +1261,14 @@ class RpcRunner(object):
return self._SingleNodeCall(node, "iallocator_runner", [name, idata])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_grow(self, node, cf_bdev, amount):
def call_blockdev_grow(self, node, cf_bdev, amount, dryrun):
"""Request a snapshot of the given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_grow",
[cf_bdev.ToDict(), amount])
[cf_bdev.ToDict(), amount, dryrun])
@_RpcTimeout(_TMO_1DAY)
def call_blockdev_export(self, node, cf_bdev,
......
......@@ -336,7 +336,8 @@ class NodeHttpServer(http.server.HttpServer):
"""
cfbd = objects.Disk.FromDict(params[0])
amount = params[1]
return backend.BlockdevGrow(cfbd, amount)
dryrun = params[2]
return backend.BlockdevGrow(cfbd, amount, dryrun)
@staticmethod
def perspective_blockdev_close(params):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment