Add exclusive_storage to blockdev_grow RPC
authorBernardo Dal Seno <bdalseno@google.com>
Thu, 27 Jun 2013 15:06:44 +0000 (17:06 +0200)
committerBernardo Dal Seno <bdalseno@google.com>
Fri, 28 Jun 2013 12:37:52 +0000 (14:37 +0200)
The flag is passed to the RPC, but it's still ignored by noded.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/cmdlib/instance_storage.py
lib/rpc_defs.py
lib/server/noded.py

index d159187..7a4933a 100644 (file)
@@ -1394,6 +1394,7 @@ class LUInstanceGrowDisk(LogicalUnit):
     node_uuids = list(self.instance.all_nodes)
     for node_uuid in node_uuids:
       CheckNodeOnline(self, node_uuid)
+    self.node_es_flags = rpc.GetExclusiveStorageForNodes(self.cfg, node_uuids)
 
     if self.instance.disk_template not in constants.DTS_GROWABLE:
       raise errors.OpPrereqError("Instance's disk layout does not support"
@@ -1425,10 +1426,7 @@ class LUInstanceGrowDisk(LogicalUnit):
     if template not in (constants.DTS_NO_FREE_SPACE_CHECK):
       # TODO: check the free disk space for file, when that feature will be
       # supported
-      nodes = map(self.cfg.GetNodeInfo, node_uuids)
-      es_nodes = filter(lambda n: IsExclusiveStorageEnabledNode(self.cfg, n),
-                        nodes)
-      if es_nodes:
+      if any(self.node_es_flags.values()):
         # With exclusive storage we need to something smarter than just looking
         # at free space; for now, let's simply abort the operation.
         raise errors.OpPrereqError("Cannot grow disks when exclusive_storage"
@@ -1459,7 +1457,8 @@ class LUInstanceGrowDisk(LogicalUnit):
       self.cfg.SetDiskID(self.disk, node_uuid)
       result = self.rpc.call_blockdev_grow(node_uuid,
                                            (self.disk, self.instance),
-                                           self.delta, True, True)
+                                           self.delta, True, True,
+                                           self.node_es_flags[node_uuid])
       result.Raise("Dry-run grow request failed to node %s" %
                    self.cfg.GetNodeName(node_uuid))
 
@@ -1492,7 +1491,8 @@ class LUInstanceGrowDisk(LogicalUnit):
       self.cfg.SetDiskID(self.disk, node_uuid)
       result = self.rpc.call_blockdev_grow(node_uuid,
                                            (self.disk, self.instance),
-                                           self.delta, False, True)
+                                           self.delta, False, True,
+                                           self.node_es_flags[node_uuid])
       result.Raise("Grow request failed to node %s" %
                    self.cfg.GetNodeName(node_uuid))
 
@@ -1500,7 +1500,8 @@ class LUInstanceGrowDisk(LogicalUnit):
     node_uuid = self.instance.primary_node
     self.cfg.SetDiskID(self.disk, node_uuid)
     result = self.rpc.call_blockdev_grow(node_uuid, (self.disk, self.instance),
-                                         self.delta, False, False)
+                                         self.delta, False, False,
+                                         self.node_es_flags[node_uuid])
     result.Raise("Grow request failed to node %s" %
                  self.cfg.GetNodeName(node_uuid))
 
index 07b4645..31acf65 100644 (file)
@@ -417,6 +417,7 @@ _BLOCKDEV_CALLS = [
     ("amount", None, None),
     ("dryrun", None, None),
     ("backingstore", None, None),
+    ("es_flag", None, None),
     ], None, None, "Request growing of the given block device by a"
    " given amount"),
   ("blockdev_export", SINGLE, None, constants.RPC_TMO_1DAY, [
index 386e568..861e01c 100644 (file)
@@ -361,9 +361,9 @@ class NodeRequestHandler(http.server.HttpServerHandler):
     """Grow a stack of devices.
 
     """
-    if len(params) < 4:
-      raise ValueError("Received only 3 parameters in blockdev_grow,"
-                       " old master?")
+    if len(params) < 5:
+      raise ValueError("Received only %s parameters in blockdev_grow,"
+                       " old master?" % len(params))
     cfbd = objects.Disk.FromDict(params[0])
     amount = params[1]
     dryrun = params[2]