from ganeti import utils
from ganeti import bootstrap
from ganeti import ssh
+from ganeti import objects
@UsesRPC
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
+ nicparams = opts.nicparams
# prepare beparams dict
- for parameter in constants.BES_PARAMETERS:
- if parameter not in beparams:
- beparams[parameter] = constants.BEC_DEFAULTS[parameter]
+ beparams = objects.FillDict(constants.BEC_DEFAULTS, beparams)
utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
+ # prepare nicparams dict
+ nicparams = objects.FillDict(constants.NICC_DEFAULTS, nicparams)
+ utils.ForceDictType(nicparams, constants.NICS_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]
+ hvparams[hv] = objects.FillDict(constants.HVC_DEFAULTS[hv], hvparams[hv])
utils.ForceDictType(hvparams[hv], constants.HVS_PARAMETER_TYPES)
for hv in hvlist:
default_hypervisor=opts.default_hypervisor,
hvparams=hvparams,
beparams=beparams,
+ nicparams=nicparams,
candidate_pool_size=opts.candidate_pool_size,
+ modify_etc_hosts=opts.modify_etc_hosts,
)
return 0
@return: the desired exit code
"""
- ToStdout("%s", GetClient().QueryConfigValues(["master_node"])[0])
+ master = bootstrap.GetMaster()
+ ToStdout(master)
return 0
ToStdout("Cluster parameters:")
ToStdout(" - candidate pool size: %s", result["candidate_pool_size"])
+ ToStdout(" - master netdev: %s", result["master_netdev"])
+ ToStdout(" - default bridge: %s", result["default_bridge"])
+ ToStdout(" - lvm volume group: %s", result["volume_group_name"])
+ ToStdout(" - file storage path: %s", result["file_storage_dir"])
ToStdout("Default instance parameters:")
for gr_name, gr_dict in result["beparams"].items():
"""
if not (not opts.lvm_storage or opts.vg_name or
opts.enabled_hypervisors or opts.hvparams or
- opts.beparams or opts.candidate_pool_size is not None):
+ opts.beparams or opts.nicparams or
+ opts.candidate_pool_size is not None):
ToStderr("Please give at least one of the parameters.")
return 1
if not opts.lvm_storage and opts.vg_name:
ToStdout("Options --no-lvm-storage and --vg-name conflict.")
return 1
+ elif not opts.lvm_storage:
+ vg_name = ''
hvlist = opts.enabled_hypervisors
if hvlist is not None:
beparams = opts.beparams
utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
- op = opcodes.OpSetClusterParams(vg_name=opts.vg_name,
+ nicparams = opts.nicparams
+ utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
+
+ op = opcodes.OpSetClusterParams(vg_name=vg_name,
enabled_hypervisors=hvlist,
hvparams=hvparams,
beparams=beparams,
+ nicparams=nicparams,
candidate_pool_size=opts.candidate_pool_size)
SubmitOpCode(op)
return 0
help="No support for lvm based instances"
" (cluster-wide)",
action="store_false", default=True,),
+ make_option("--no-etc-hosts", dest="modify_etc_hosts",
+ help="Don't modify /etc/hosts"
+ " (cluster-wide)",
+ action="store_false", default=True,),
make_option("--enabled-hypervisors", dest="enabled_hypervisors",
help="Comma-separated list of hypervisors",
type="string", default=None),
keyval_option("-B", "--backend-parameters", dest="beparams",
type="keyval", default={},
help="Backend parameters"),
+ keyval_option("-N", "--nic-parameters", dest="nicparams",
+ type="keyval", default={},
+ help="NIC parameters"),
make_option("-C", "--candidate-pool-size",
default=constants.MASTER_POOL_SIZE_DEFAULT,
help="Set the candidate pool size",
keyval_option("-B", "--backend-parameters", dest="beparams",
type="keyval", default={},
help="Backend parameters"),
+ keyval_option("-N", "--nic-parameters", dest="nicparams",
+ type="keyval", default={},
+ help="NIC parameters"),
make_option("-C", "--candidate-pool-size", default=None,
help="Set the candidate pool size",
dest="candidate_pool_size", type="int"),