Fix TypeError when unsetting OS parameters
authorMichael Hanselmann <hansmi@google.com>
Wed, 12 Dec 2012 12:17:29 +0000 (13:17 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 12 Dec 2012 13:21:29 +0000 (14:21 +0100)
When all OS parameters should be unset (“gnt-os modify -H -xen-pvm
foo”), a TypeError was raised. This fixes issue 311.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cmdlib.py

index 0da8edf..8e91029 100644 (file)
@@ -4085,7 +4085,10 @@ class LUClusterSetParams(LogicalUnit):
           self.new_os_hvp[os_name] = hvs
         else:
           for hv_name, hv_dict in hvs.items():
-            if hv_name not in self.new_os_hvp[os_name]:
+            if hv_dict is None:
+              # Delete if it exists
+              self.new_os_hvp[os_name].pop(hv_name, None)
+            elif hv_name not in self.new_os_hvp[os_name]:
               self.new_os_hvp[os_name][hv_name] = hv_dict
             else:
               self.new_os_hvp[os_name][hv_name].update(hv_dict)