From 8e8092cc55fbd49d391b1246e20e3ea155fcdb3f Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Wed, 12 Dec 2012 13:17:29 +0100 Subject: [PATCH] Fix TypeError when unsetting OS parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lib/cmdlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) -- 1.7.10.4