From: Michael Hanselmann Date: Wed, 12 Dec 2012 12:17:29 +0000 (+0100) Subject: Fix TypeError when unsetting OS parameters X-Git-Tag: v2.6.2~8 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/8e8092cc55fbd49d391b1246e20e3ea155fcdb3f Fix TypeError when unsetting OS parameters 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 Reviewed-by: Iustin Pop --- diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 0da8edf..8e91029 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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)