Support reseting arbitrary params of ext disks
authorDimitris Aragiorgis <dimara@grnet.gr>
Tue, 10 Dec 2013 09:14:54 +0000 (11:14 +0200)
committerMichele Tartara <mtartara@google.com>
Wed, 11 Dec 2013 11:27:53 +0000 (12:27 +0100)
If param=default and the param already exists then we remove
it from params dict. This is stolen by GetUpdatedParams() which
is used for hvparams modification/inheritance.

This means that 'default' value is not accepted for an arbitrary
param of an ext disk.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/cmdlib/instance.py

index 5041dcb..007f989 100644 (file)
@@ -3200,7 +3200,14 @@ class LUInstanceSetParams(LogicalUnit):
     for key, value in params.iteritems():
       if (key not in constants.MODIFIABLE_IDISK_PARAMS and
           self.instance.disk_template == constants.DT_EXT):
-        disk.params[key] = value
+        # stolen from GetUpdatedParams: default means reset/delete
+        if value.lower() == constants.VALUE_DEFAULT:
+          try:
+            del disk.params[key]
+          except KeyError:
+            pass
+        else:
+          disk.params[key] = value
         changes.append(("disk.params:%s/%d" % (key, idx), value))
 
     return changes