- op = opcodes.OpInitCluster(cluster_name=args[0],
- secondary_ip=opts.secondary_ip,
- hypervisor_type=opts.hypervisor_type,
- vg_name=opts.vg_name,
- mac_prefix=opts.mac_prefix,
- def_bridge=opts.def_bridge,
- master_netdev=opts.master_netdev,
- file_storage_dir=opts.file_storage_dir)
- SubmitOpCode(op)
+ if not opts.lvm_storage and opts.vg_name:
+ ToStderr("Options --no-lvm-storage and --vg-name conflict.")
+ return 1
+
+ vg_name = opts.vg_name
+ if opts.lvm_storage and not opts.vg_name:
+ vg_name = constants.DEFAULT_VG
+
+ hvlist = opts.enabled_hypervisors
+ if hvlist is not None:
+ hvlist = hvlist.split(",")
+ else:
+ hvlist = [opts.default_hypervisor]
+
+ # avoid an impossible situation
+ if opts.default_hypervisor not in hvlist:
+ ToStderr("The default hypervisor requested (%s) is not"
+ " within the enabled hypervisor list (%s)" %
+ (opts.default_hypervisor, hvlist))
+ return 1
+
+ hvparams = dict(opts.hvparams)
+
+ beparams = opts.beparams
+ # check for invalid parameters
+ for parameter in beparams:
+ if parameter not in constants.BES_PARAMETERS:
+ ToStderr("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]
+ utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
+
+ # 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]
+ utils.ForceDictType(hvparams[hv], constants.HVS_PARAMETER_TYPES)
+
+ for hv in hvlist:
+ if hv not in constants.HYPER_TYPES:
+ ToStderr("invalid hypervisor: %s", hv)
+ return 1
+
+ bootstrap.InitCluster(cluster_name=args[0],
+ secondary_ip=opts.secondary_ip,
+ vg_name=vg_name,
+ mac_prefix=opts.mac_prefix,
+ def_bridge=opts.def_bridge,
+ master_netdev=opts.master_netdev,
+ file_storage_dir=opts.file_storage_dir,
+ enabled_hypervisors=hvlist,
+ default_hypervisor=opts.default_hypervisor,
+ hvparams=hvparams,
+ beparams=beparams,
+ candidate_pool_size=opts.candidate_pool_size,
+ )