+ hvlist = opts.enabled_hypervisors
+ if hvlist is not None:
+ hvlist = hvlist.split(",")
+ else:
+ hvlist = constants.DEFAULT_ENABLED_HYPERVISOR
+
+ 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 = {}
+
+ beparams = opts.beparams
+ # check for invalid parameters
+ for parameter in beparams:
+ if parameter not in constants.BES_PARAMETERS:
+ print "Invalid backend parameter: %s" % parameter
+ return 1
+
+ # prepare beparams dict
+ for parameter in constants.BES_PARAMETERS:
+ if parameter not in beparams:
+ beparams[parameter] = constants.BEC_DEFAULTS[parameter]
+
+ # type wrangling
+ try:
+ beparams[constants.BE_VCPUS] = int(beparams[constants.BE_VCPUS])
+ except ValueError:
+ print "%s must be an integer" % constants.BE_VCPUS
+ return 1
+
+ beparams[constants.BE_MEMORY] = utils.ParseUnit(beparams[constants.BE_MEMORY])
+
+ # prepare hvparams dict
+ for hv in constants.HYPER_TYPES:
+ if hv not in hvparams:
+ hvparams[hv] = {}
+ for parameter in constants.HVC_DEFAULTS[hv]:
+ if parameter not in hvparams[hv]:
+ hvparams[hv][parameter] = constants.HVC_DEFAULTS[hv][parameter]
+
+ for hv in hvlist:
+ if hv not in constants.HYPER_TYPES:
+ print "invalid hypervisor: %s" % hv
+ return 1
+