From 8edcd61118bf7cbaaf5b10872ca7385280144185 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Tue, 2 Dec 2008 10:25:48 +0000
Subject: [PATCH] Handle default/none values in hv/be params

When a value is set to constants.VALUE_DEFAULT we have to remove it from
the specific instance dict, as this way it will be populated from the
cluster before. If instead it's specified as constants.VALUE_NONE we'll
explicitely set it to None, to override its presence with a different
values in such defaults. However, currently, we handle None values only
for hvparams, that have a real use case for them.

Reviewed-by: imsnah
---
 lib/cmdlib.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 6d4c0598b..bd54c28fe 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5000,11 +5000,13 @@ class LUSetInstanceParams(LogicalUnit):
     if self.op.hvparams:
       i_hvdict = copy.deepcopy(instance.hvparams)
       for key, val in self.op.hvparams.iteritems():
-        if val is None:
+        if val == constants.VALUE_DEFAULT:
           try:
             del i_hvdict[key]
           except KeyError:
             pass
+        elif val == constants.VALUE_NONE:
+          i_hvdict[key] = None
         else:
           i_hvdict[key] = val
       cluster = self.cfg.GetClusterInfo()
@@ -5023,7 +5025,7 @@ class LUSetInstanceParams(LogicalUnit):
     if self.op.beparams:
       i_bedict = copy.deepcopy(instance.beparams)
       for key, val in self.op.beparams.iteritems():
-        if val is None:
+        if val == constants.VALUE_DEFAULT:
           try:
             del i_bedict[key]
           except KeyError:
-- 
GitLab