Implement grow dry-run at RPC level
authorIustin Pop <iustin@google.com>
Mon, 9 May 2011 15:01:23 +0000 (17:01 +0200)
committerIustin Pop <iustin@google.com>
Tue, 10 May 2011 14:37:49 +0000 (16:37 +0200)
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/backend.py
lib/cmdlib.py
lib/rpc.py
lib/server/noded.py

index b598af6..fdd6ad4 100644 (file)
@@ -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)
 
index fbb5b04..b8f423f 100644 (file)
@@ -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
index 2eeec06..ddaaad7 100644 (file)
@@ -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,
index 0090efb..2cbefaf 100644 (file)
@@ -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):