Revision bf4af505
b/lib/bootstrap.py | ||
---|---|---|
218 | 218 |
nicparams=None, hvparams=None, enabled_hypervisors=None, |
219 | 219 |
modify_etc_hosts=True, modify_ssh_setup=True, |
220 | 220 |
maintain_node_health=False, drbd_helper=None, |
221 |
uid_pool=None): |
|
221 |
uid_pool=None, default_iallocator=None):
|
|
222 | 222 |
"""Initialise the cluster. |
223 | 223 |
|
224 | 224 |
@type candidate_pool_size: int |
... | ... | |
333 | 333 |
if modify_ssh_setup: |
334 | 334 |
_InitSSHSetup() |
335 | 335 |
|
336 |
if default_iallocator is not None: |
|
337 |
alloc_script = utils.FindFile(default_iallocator, |
|
338 |
constants.IALLOCATOR_SEARCH_PATH, |
|
339 |
os.path.isfile) |
|
340 |
if alloc_script is None: |
|
341 |
raise errors.OpPrereqError("Invalid default iallocator script '%s'" |
|
342 |
" specified" % default_iallocator, |
|
343 |
errors.ECODE_INVAL) |
|
344 |
|
|
336 | 345 |
now = time.time() |
337 | 346 |
|
338 | 347 |
# init of cluster config file |
... | ... | |
361 | 370 |
uuid=utils.NewUUID(), |
362 | 371 |
maintain_node_health=maintain_node_health, |
363 | 372 |
drbd_usermode_helper=drbd_helper, |
373 |
default_iallocator=default_iallocator, |
|
364 | 374 |
) |
365 | 375 |
master_node_config = objects.Node(name=hostname.name, |
366 | 376 |
primary_ip=hostname.ip, |
b/lib/cli.py | ||
---|---|---|
75 | 75 |
"HVOPTS_OPT", |
76 | 76 |
"HYPERVISOR_OPT", |
77 | 77 |
"IALLOCATOR_OPT", |
78 |
"DEFAULT_IALLOCATOR_OPT", |
|
78 | 79 |
"IDENTIFY_DEFAULTS_OPT", |
79 | 80 |
"IGNORE_CONSIST_OPT", |
80 | 81 |
"IGNORE_FAILURES_OPT", |
... | ... | |
615 | 616 |
default=None, type="string", |
616 | 617 |
completion_suggest=OPT_COMPL_ONE_IALLOCATOR) |
617 | 618 |
|
619 |
DEFAULT_IALLOCATOR_OPT = cli_option("-I", "--default-iallocator", |
|
620 |
metavar="<NAME>", |
|
621 |
help="Set the default instance allocator plugin", |
|
622 |
default=None, type="string", |
|
623 |
completion_suggest=OPT_COMPL_ONE_IALLOCATOR) |
|
624 |
|
|
618 | 625 |
OS_OPT = cli_option("-o", "--os-type", dest="os", help="What OS to run", |
619 | 626 |
metavar="<os>", |
620 | 627 |
completion_suggest=OPT_COMPL_ONE_OS) |
b/lib/cmdlib.py | ||
---|---|---|
2562 | 2562 |
("maintain_node_health", None, _TMaybeBool), |
2563 | 2563 |
("nicparams", None, _TOr(_TDict, _TNone)), |
2564 | 2564 |
("drbd_helper", None, _TOr(_TString, _TNone)), |
2565 |
("default_iallocator", None, _TMaybeString), |
|
2565 | 2566 |
] |
2566 | 2567 |
REQ_BGL = False |
2567 | 2568 |
|
... | ... | |
2767 | 2768 |
hv_class.CheckParameterSyntax(new_osp) |
2768 | 2769 |
_CheckHVParams(self, node_list, hv_name, new_osp) |
2769 | 2770 |
|
2771 |
if self.op.default_iallocator: |
|
2772 |
alloc_script = utils.FindFile(self.op.default_iallocator, |
|
2773 |
constants.IALLOCATOR_SEARCH_PATH, |
|
2774 |
os.path.isfile) |
|
2775 |
if alloc_script is None: |
|
2776 |
raise errors.OpPrereqError("Invalid default iallocator script '%s'" |
|
2777 |
" specified" % self.op.default_iallocator, |
|
2778 |
errors.ECODE_INVAL) |
|
2770 | 2779 |
|
2771 | 2780 |
def Exec(self, feedback_fn): |
2772 | 2781 |
"""Change the parameters of the cluster. |
... | ... | |
2821 | 2830 |
if self.op.uid_pool is not None: |
2822 | 2831 |
self.cluster.uid_pool = self.op.uid_pool |
2823 | 2832 |
|
2833 |
if self.op.default_iallocator is not None: |
|
2834 |
self.cluster.default_iallocator = self.op.default_iallocator |
|
2835 |
|
|
2824 | 2836 |
self.cfg.Update(self.cluster, feedback_fn) |
2825 | 2837 |
|
2826 | 2838 |
|
... | ... | |
4083 | 4095 |
"uuid": cluster.uuid, |
4084 | 4096 |
"tags": list(cluster.GetTags()), |
4085 | 4097 |
"uid_pool": cluster.uid_pool, |
4098 |
"default_iallocator": cluster.default_iallocator, |
|
4086 | 4099 |
} |
4087 | 4100 |
|
4088 | 4101 |
return result |
b/lib/config.py | ||
---|---|---|
816 | 816 |
""" |
817 | 817 |
return self._config_data.cluster.rsahostkeypub |
818 | 818 |
|
819 |
@locking.ssynchronized(_config_lock, shared=1) |
|
820 |
def GetDefaultIAllocator(self): |
|
821 |
"""Get the default instance allocator for this cluster. |
|
822 |
|
|
823 |
""" |
|
824 |
return self._config_data.cluster.default_iallocator |
|
825 |
|
|
819 | 826 |
@locking.ssynchronized(_config_lock) |
820 | 827 |
def AddInstance(self, instance, ec_id): |
821 | 828 |
"""Add an instance to the config. |
b/lib/objects.py | ||
---|---|---|
917 | 917 |
"modify_ssh_setup", |
918 | 918 |
"maintain_node_health", |
919 | 919 |
"uid_pool", |
920 |
"default_iallocator", |
|
920 | 921 |
] + _TIMESTAMPS + _UUID |
921 | 922 |
|
922 | 923 |
def UpgradeConfig(self): |
... | ... | |
975 | 976 |
if self.uid_pool is None: |
976 | 977 |
self.uid_pool = [] |
977 | 978 |
|
979 |
if self.default_iallocator is None: |
|
980 |
self.default_iallocator = "" |
|
981 |
|
|
978 | 982 |
def ToDict(self): |
979 | 983 |
"""Custom function for cluster. |
980 | 984 |
|
b/lib/opcodes.py | ||
---|---|---|
311 | 311 |
"uid_pool", |
312 | 312 |
"add_uids", |
313 | 313 |
"remove_uids", |
314 |
"default_iallocator", |
|
314 | 315 |
] |
315 | 316 |
|
316 | 317 |
|
b/scripts/gnt-cluster | ||
---|---|---|
121 | 121 |
maintain_node_health=opts.maintain_node_health, |
122 | 122 |
drbd_helper=drbd_helper, |
123 | 123 |
uid_pool=uid_pool, |
124 |
default_iallocator=opts.default_iallocator, |
|
124 | 125 |
) |
125 | 126 |
op = opcodes.OpPostInitCluster() |
126 | 127 |
SubmitOpCode(op, opts=opts) |
... | ... | |
302 | 303 |
ToStdout(" - uid pool: %s", |
303 | 304 |
uidpool.FormatUidPool(result["uid_pool"], |
304 | 305 |
roman=opts.roman_integers)) |
306 |
ToStdout(" - default instance allocator: %s", result["default_iallocator"]) |
|
305 | 307 |
|
306 | 308 |
ToStdout("Default instance parameters:") |
307 | 309 |
_PrintGroupedParams(result["beparams"], roman=opts.roman_integers) |
... | ... | |
660 | 662 |
opts.uid_pool is not None or |
661 | 663 |
opts.maintain_node_health is not None or |
662 | 664 |
opts.add_uids is not None or |
663 |
opts.remove_uids is not None): |
|
665 |
opts.remove_uids is not None or |
|
666 |
opts.default_iallocator is not None): |
|
664 | 667 |
ToStderr("Please give at least one of the parameters.") |
665 | 668 |
return 1 |
666 | 669 |
|
... | ... | |
721 | 724 |
maintain_node_health=mnh, |
722 | 725 |
uid_pool=uid_pool, |
723 | 726 |
add_uids=add_uids, |
724 |
remove_uids=remove_uids) |
|
727 |
remove_uids=remove_uids, |
|
728 |
default_iallocator=opts.default_iallocator) |
|
725 | 729 |
SubmitOpCode(op, opts=opts) |
726 | 730 |
return 0 |
727 | 731 |
|
... | ... | |
804 | 808 |
HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT, NIC_PARAMS_OPT, |
805 | 809 |
NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT, |
806 | 810 |
SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, |
807 |
UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT], |
|
811 |
UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, |
|
812 |
DEFAULT_IALLOCATOR_OPT], |
|
808 | 813 |
"[opts...] <cluster_name>", "Initialises a new cluster configuration"), |
809 | 814 |
'destroy': ( |
810 | 815 |
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT], |
... | ... | |
875 | 880 |
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, |
876 | 881 |
NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, |
877 | 882 |
UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT, |
878 |
NODRBD_STORAGE_OPT], |
|
883 |
NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT],
|
|
879 | 884 |
"[opts...]", |
880 | 885 |
"Alters the parameters of the cluster"), |
881 | 886 |
"renew-crypto": ( |
Also available in: Unified diff