Revision 57dc299a
b/lib/bootstrap.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2010, 2011 Google Inc. |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
414 | 414 |
objects.UpgradeBeParams(beparams) |
415 | 415 |
utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES) |
416 | 416 |
utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES) |
417 |
for key, val in ipolicy.items(): |
|
418 |
if key not in constants.IPOLICY_PARAMETERS: |
|
419 |
raise errors.OpPrereqError("'%s' is not a valid key for instance policy" |
|
420 |
" description", key) |
|
421 |
utils.ForceDictType(val, constants.ISPECS_PARAMETER_TYPES) |
|
422 | 417 |
|
423 | 418 |
objects.NIC.CheckParameterSyntax(nicparams) |
419 |
|
|
424 | 420 |
full_ipolicy = objects.FillIPolicy(constants.IPOLICY_DEFAULTS, ipolicy) |
425 |
objects.InstancePolicy.CheckParameterSyntax(full_ipolicy) |
|
426 | 421 |
|
427 | 422 |
if ndparams is not None: |
428 | 423 |
utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES) |
... | ... | |
430 | 425 |
ndparams = dict(constants.NDC_DEFAULTS) |
431 | 426 |
|
432 | 427 |
# This is ugly, as we modify the dict itself |
433 |
# FIXME: Make utils.ForceDictType pure functional or write a wrapper around it |
|
428 |
# FIXME: Make utils.ForceDictType pure functional or write a wrapper |
|
429 |
# around it |
|
434 | 430 |
if hv_state: |
435 | 431 |
for hvname, hvs_data in hv_state.items(): |
436 | 432 |
utils.ForceDictType(hvs_data, constants.HVSTS_PARAMETER_TYPES) |
... | ... | |
526 | 522 |
primary_ip_family=ipcls.family, |
527 | 523 |
prealloc_wipe_disks=prealloc_wipe_disks, |
528 | 524 |
use_external_mip_script=use_external_mip_script, |
529 |
ipolicy=ipolicy, |
|
525 |
ipolicy=full_ipolicy,
|
|
530 | 526 |
hv_state_static=hv_state, |
531 | 527 |
disk_state_static=disk_state, |
532 | 528 |
) |
b/lib/client/gnt_cluster.py | ||
---|---|---|
149 | 149 |
ispecs_disk_templates=ispecs_dts, |
150 | 150 |
fill_all=True) |
151 | 151 |
ipolicy = objects.FillIPolicy(constants.IPOLICY_DEFAULTS, ipolicy_raw) |
152 |
for value in ipolicy.values(): |
|
153 |
utils.ForceDictType(value, constants.ISPECS_PARAMETER_TYPES) |
|
154 | 152 |
|
155 | 153 |
if opts.candidate_pool_size is None: |
156 | 154 |
opts.candidate_pool_size = constants.MASTER_POOL_SIZE_DEFAULT |
b/lib/client/gnt_group.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010, 2011 Google Inc. |
|
4 |
# Copyright (C) 2010, 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
55 | 55 |
ispecs_disk_size=opts.ispecs_disk_size, |
56 | 56 |
ispecs_nic_count=opts.ispecs_nic_count, |
57 | 57 |
group_ipolicy=True) |
58 |
for key in ipolicy.keys(): |
|
59 |
utils.ForceDictType(ipolicy[key], constants.ISPECS_PARAMETER_TYPES) |
|
60 | 58 |
|
61 | 59 |
(group_name,) = args |
62 | 60 |
diskparams = dict(opts.diskparams) |
b/lib/cmdlib.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc. |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
731 | 731 |
use_none = use_default = group_policy |
732 | 732 |
ipolicy = copy.deepcopy(old_ipolicy) |
733 | 733 |
for key, value in new_ipolicy.items(): |
734 |
if key not in constants.IPOLICY_ALL_KEYS: |
|
735 |
raise errors.OpPrereqError("Invalid key in new ipolicy: %s" % key, |
|
736 |
errors.ECODE_INVAL) |
|
734 | 737 |
if key in constants.IPOLICY_PARAMETERS: |
735 | 738 |
utils.ForceDictType(value, constants.ISPECS_PARAMETER_TYPES) |
736 | 739 |
ipolicy[key] = _GetUpdatedParams(old_ipolicy.get(key, {}), value, |
... | ... | |
747 | 750 |
" on the cluster'" % key, |
748 | 751 |
errors.ECODE_INVAL) |
749 | 752 |
else: |
750 |
logging.info("Setting %s to %s", key, value) |
|
751 | 753 |
ipolicy[key] = list(value) |
752 | 754 |
try: |
753 | 755 |
objects.InstancePolicy.CheckParameterSyntax(ipolicy) |
b/lib/objects.py | ||
---|---|---|
224 | 224 |
if ispecs_disk_templates is not None: |
225 | 225 |
ipolicy_out[constants.ISPECS_DTS] = list(ispecs_disk_templates) |
226 | 226 |
|
227 |
assert not (frozenset(ipolicy_out.keys()) - constants.IPOLICY_ALL_KEYS) |
|
228 |
|
|
227 | 229 |
return ipolicy_out |
228 | 230 |
|
229 | 231 |
|
... | ... | |
884 | 886 |
InstancePolicy.CheckISpecSyntax(ipolicy, param) |
885 | 887 |
if constants.ISPECS_DTS in ipolicy: |
886 | 888 |
InstancePolicy.CheckDiskTemplates(ipolicy[constants.ISPECS_DTS]) |
889 |
wrong_keys = frozenset(ipolicy.keys()) - constants.IPOLICY_ALL_KEYS |
|
890 |
if wrong_keys: |
|
891 |
raise errors.ConfigurationError("Invalid keys in ipolicy: %s" % |
|
892 |
utils.CommaJoin(wrong_keys)) |
|
887 | 893 |
|
888 | 894 |
@classmethod |
889 | 895 |
def CheckISpecSyntax(cls, ipolicy, name): |
Also available in: Unified diff