Revision 67fc3042 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
453 | 453 |
|
454 | 454 |
|
455 | 455 |
def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status, |
456 |
memory, vcpus, nics, disk_template, disks): |
|
456 |
memory, vcpus, nics, disk_template, disks, |
|
457 |
bep, hvp, hypervisor): |
|
457 | 458 |
"""Builds instance related env variables for hooks |
458 | 459 |
|
459 | 460 |
This builds the hook environment from individual variables. |
... | ... | |
479 | 480 |
@param disk_template: the distk template of the instance |
480 | 481 |
@type disks: list |
481 | 482 |
@param disks: the list of (size, mode) pairs |
483 |
@type bep: dict |
|
484 |
@param bep: the backend parameters for the instance |
|
485 |
@type hvp: dict |
|
486 |
@param hvp: the hypervisor parameters for the instance |
|
487 |
@type hypervisor: string |
|
488 |
@param hypervisor: the hypervisor for the instance |
|
482 | 489 |
@rtype: dict |
483 | 490 |
@return: the hook environment for this instance |
484 | 491 |
|
... | ... | |
497 | 504 |
"INSTANCE_MEMORY": memory, |
498 | 505 |
"INSTANCE_VCPUS": vcpus, |
499 | 506 |
"INSTANCE_DISK_TEMPLATE": disk_template, |
507 |
"INSTANCE_HYPERVISOR": hypervisor, |
|
500 | 508 |
} |
501 | 509 |
|
502 | 510 |
if nics: |
... | ... | |
522 | 530 |
|
523 | 531 |
env["INSTANCE_DISK_COUNT"] = disk_count |
524 | 532 |
|
533 |
for source, kind in [(bep, "BE"), (hvp, "HV")]: |
|
534 |
for key, value in source.items(): |
|
535 |
env["INSTANCE_%s_%s" % (kind, key)] = value |
|
536 |
|
|
525 | 537 |
return env |
526 | 538 |
|
527 | 539 |
|
... | ... | |
540 | 552 |
@return: the hook environment dictionary |
541 | 553 |
|
542 | 554 |
""" |
543 |
bep = lu.cfg.GetClusterInfo().FillBE(instance) |
|
555 |
cluster = lu.cfg.GetClusterInfo() |
|
556 |
bep = cluster.FillBE(instance) |
|
557 |
hvp = cluster.FillHV(instance) |
|
544 | 558 |
args = { |
545 | 559 |
'name': instance.name, |
546 | 560 |
'primary_node': instance.primary_node, |
... | ... | |
552 | 566 |
'nics': [(nic.ip, nic.bridge, nic.mac) for nic in instance.nics], |
553 | 567 |
'disk_template': instance.disk_template, |
554 | 568 |
'disks': [(disk.size, disk.mode) for disk in instance.disks], |
569 |
'bep': bep, |
|
570 |
'hvp': hvp, |
|
571 |
'hypervisor': instance.hypervisor, |
|
555 | 572 |
} |
556 | 573 |
if override: |
557 | 574 |
args.update(override) |
... | ... | |
4341 | 4358 |
self.op.hvparams) |
4342 | 4359 |
hv_type = hypervisor.GetHypervisor(self.op.hypervisor) |
4343 | 4360 |
hv_type.CheckParameterSyntax(filled_hvp) |
4361 |
self.hv_full = filled_hvp |
|
4344 | 4362 |
|
4345 | 4363 |
# fill and remember the beparams dict |
4346 | 4364 |
utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES) |
... | ... | |
4518 | 4536 |
nics=[(n.ip, n.bridge, n.mac) for n in self.nics], |
4519 | 4537 |
disk_template=self.op.disk_template, |
4520 | 4538 |
disks=[(d["size"], d["mode"]) for d in self.disks], |
4539 |
bep=self.be_full, |
|
4540 |
hvp=self.hv_full, |
|
4541 |
hypervisor=self.op.hypervisor, |
|
4521 | 4542 |
)) |
4522 | 4543 |
|
4523 | 4544 |
nl = ([self.cfg.GetMasterNode(), self.op.pnode] + |
Also available in: Unified diff