Revision 7736a5f2 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
500 | 500 |
setattr(op, name, val) |
501 | 501 |
|
502 | 502 |
|
503 |
def _CheckGlobalHvParams(params): |
|
504 |
"""Validates that given hypervisor params are not global ones. |
|
505 |
|
|
506 |
This will ensure that instances don't get customised versions of |
|
507 |
global params. |
|
508 |
|
|
509 |
""" |
|
510 |
used_globals = constants.HVC_GLOBALS.intersection(params) |
|
511 |
if used_globals: |
|
512 |
msg = ("The following hypervisor parameters are global and cannot" |
|
513 |
" be customized at instance level, please modify them at" |
|
514 |
" cluster level: %s" % ", ".join(used_globals)) |
|
515 |
raise errors.OpPrereqError(msg, errors.ECODE_INVAL) |
|
516 |
|
|
517 |
|
|
503 | 518 |
def _CheckNodeOnline(lu, node): |
504 | 519 |
"""Ensure that a given node is online. |
505 | 520 |
|
... | ... | |
4200 | 4215 |
"hvparams", |
4201 | 4216 |
] + _SIMPLE_FIELDS + |
4202 | 4217 |
["hv/%s" % name |
4203 |
for name in constants.HVS_PARAMETERS] + |
|
4218 |
for name in constants.HVS_PARAMETERS |
|
4219 |
if name not in constants.HVC_GLOBALS] + |
|
4204 | 4220 |
["be/%s" % name |
4205 | 4221 |
for name in constants.BES_PARAMETERS]) |
4206 | 4222 |
_FIELDS_DYNAMIC = utils.FieldSet("oper_state", "oper_ram", "status") |
... | ... | |
4295 | 4311 |
cluster = self.cfg.GetClusterInfo() |
4296 | 4312 |
for instance in instance_list: |
4297 | 4313 |
iout = [] |
4298 |
i_hv = cluster.FillHV(instance) |
|
4314 |
i_hv = cluster.FillHV(instance, skip_globals=True)
|
|
4299 | 4315 |
i_be = cluster.FillBE(instance) |
4300 | 4316 |
i_nicp = [objects.FillDict(cluster.nicparams[constants.PP_DEFAULT], |
4301 | 4317 |
nic.nicparams) for nic in instance.nics] |
... | ... | |
4382 | 4398 |
elif field == "hvparams": |
4383 | 4399 |
val = i_hv |
4384 | 4400 |
elif (field.startswith(HVPREFIX) and |
4385 |
field[len(HVPREFIX):] in constants.HVS_PARAMETERS): |
|
4401 |
field[len(HVPREFIX):] in constants.HVS_PARAMETERS and |
|
4402 |
field[len(HVPREFIX):] not in constants.HVC_GLOBALS): |
|
4386 | 4403 |
val = i_hv.get(field[len(HVPREFIX):], None) |
4387 | 4404 |
elif field == "beparams": |
4388 | 4405 |
val = i_be |
... | ... | |
5599 | 5616 |
hv_type = hypervisor.GetHypervisor(self.op.hypervisor) |
5600 | 5617 |
hv_type.CheckParameterSyntax(filled_hvp) |
5601 | 5618 |
self.hv_full = filled_hvp |
5619 |
# check that we don't specify global parameters on an instance |
|
5620 |
_CheckGlobalHvParams(self.op.hvparams) |
|
5602 | 5621 |
|
5603 | 5622 |
# fill and remember the beparams dict |
5604 | 5623 |
utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES) |
... | ... | |
7292 | 7311 |
"hypervisor": instance.hypervisor, |
7293 | 7312 |
"network_port": instance.network_port, |
7294 | 7313 |
"hv_instance": instance.hvparams, |
7295 |
"hv_actual": cluster.FillHV(instance), |
|
7314 |
"hv_actual": cluster.FillHV(instance, skip_globals=True),
|
|
7296 | 7315 |
"be_instance": instance.beparams, |
7297 | 7316 |
"be_actual": cluster.FillBE(instance), |
7298 | 7317 |
"serial_no": instance.serial_no, |
... | ... | |
7329 | 7348 |
self.op.hvparams or self.op.beparams): |
7330 | 7349 |
raise errors.OpPrereqError("No changes submitted", errors.ECODE_INVAL) |
7331 | 7350 |
|
7351 |
if self.op.hvparams: |
|
7352 |
_CheckGlobalHvParams(self.op.hvparams) |
|
7353 |
|
|
7332 | 7354 |
# Disk validation |
7333 | 7355 |
disk_addremove = 0 |
7334 | 7356 |
for disk_op, disk_dict in self.op.disks: |
Also available in: Unified diff