From f8e7ddca9de5f8eda5fcdb390e3b574fe48b034e Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 11 Feb 2009 10:20:13 +0000
Subject: [PATCH] gnt-cluster, pass hvparams directly to dict()

If hvparams is not set it will be [], so dict() will transform it to an
empty dict, which is safe in all cases.

Reviewed-by: iustinp
---
 scripts/gnt-cluster | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index d137d8076..928e0ac04 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -69,13 +69,7 @@ def InitCluster(opts, args):
              (opts.default_hypervisor, hvlist))
     return 1
 
-  hvparams = opts.hvparams
-  if hvparams:
-    # a list of (name, dict) we can pass directly to dict()
-    hvparams = dict(opts.hvparams)
-  else:
-    # otherwise init as empty dict
-    hvparams = {}
+  hvparams = dict(opts.hvparams)
 
   beparams = opts.beparams
   # check for invalid parameters
@@ -473,10 +467,8 @@ def SetClusterParams(opts, args):
   if hvlist is not None:
     hvlist = hvlist.split(",")
 
-  hvparams = opts.hvparams
-  if hvparams:
-    # a list of (name, dict) we can pass directly to dict()
-    hvparams = dict(opts.hvparams)
+  # a list of (name, dict) we can pass directly to dict() (or [])
+  hvparams = dict(opts.hvparams)
   for hv, hv_params in hvparams.iteritems():
     utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
 
-- 
GitLab