From 1df4d430da99f0c7b0fe0fdbce92c6acd1a0870c Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 21 Aug 2012 16:52:07 +0200
Subject: [PATCH] Change node parameter oob_program to VTYPE_STRING
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Since this is an inheritable parameter, having it as a MABYE_STRING
creates only problems (per our derivation rules). We change it to
STRING, with the default "", meaning no program. Note that most of the
code already accepts this as valid for "no program", and some comments
even say that this is the expected value.

We have some other parameters like this, I'll have to investigate
whether they need to be changed too. But right now I need this for the
hconfd changes (it's a prerequisite for them, I forgot to send it in
that patch series).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/constants.py | 4 ++--
 lib/objects.py   | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index af3df19d0..5187c9993 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -974,7 +974,7 @@ ND_OOB_PROGRAM = "oob_program"
 ND_SPINDLE_COUNT = "spindle_count"
 
 NDS_PARAMETER_TYPES = {
-  ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
+  ND_OOB_PROGRAM: VTYPE_STRING,
   ND_SPINDLE_COUNT: VTYPE_INT,
   }
 
@@ -1842,7 +1842,7 @@ BEC_DEFAULTS = {
   }
 
 NDC_DEFAULTS = {
-  ND_OOB_PROGRAM: None,
+  ND_OOB_PROGRAM: "",
   ND_SPINDLE_COUNT: 1,
   }
 
diff --git a/lib/objects.py b/lib/objects.py
index 74526d338..a852593e4 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -173,6 +173,10 @@ def UpgradeNDParams(ndparams):
   if ndparams is None:
     ndparams = {}
 
+  if (constants.ND_OOB_PROGRAM in ndparams and
+      ndparams[constants.ND_OOB_PROGRAM] is None):
+    # will be reset by the line below
+    del ndparams[constants.ND_OOB_PROGRAM]
   return FillDict(constants.NDC_DEFAULTS, ndparams)
 
 
-- 
GitLab