From 3c8954ad6215df25b75360292f3ad11ad013d15b Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 9 Apr 2010 11:50:51 +0200 Subject: [PATCH] Export more instance parameters in instance export Currently the backend parameters are not exported automatically, but only a few directly in the '[instance]' section. Hypervisor type and hypervisor parameters are not exported at all. This patch creates two separate sections for the be and hv parameters, and stores the parameters (including ones that come from the cluster defaults, but not the hypervisor globals for example) in the export. The import code is not changed yet. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 12 ++++++++++++ lib/constants.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/lib/backend.py b/lib/backend.py index 326d0f8f8..db0ec8c52 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2086,6 +2086,7 @@ def FinalizeExport(instance, snap_disks): config.set(constants.INISECT_INS, 'vcpus', '%d' % instance.beparams[constants.BE_VCPUS]) config.set(constants.INISECT_INS, 'disk_template', instance.disk_template) + config.set(constants.INISECT_INS, 'hypervisor', instance.hypervisor) nic_total = 0 for nic_count, nic in enumerate(instance.nics): @@ -2112,6 +2113,17 @@ def FinalizeExport(instance, snap_disks): config.set(constants.INISECT_INS, 'disk_count' , '%d' % disk_total) + # New-style hypervisor/backend parameters + + config.add_section(constants.INISECT_HYP) + for name, value in instance.hvparams.items(): + if name not in constants.HVC_GLOBALS: + config.set(constants.INISECT_HYP, name, str(value)) + + config.add_section(constants.INISECT_BEP) + for name, value in instance.beparams.items(): + config.set(constants.INISECT_BEP, name, str(value)) + utils.WriteFile(utils.PathJoin(destdir, constants.EXPORT_CONF_FILE), data=config.Dumps()) shutil.rmtree(finaldestdir, ignore_errors=True) diff --git a/lib/constants.py b/lib/constants.py index 5c447018a..f8010655c 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -313,6 +313,8 @@ FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP]) # import/export config options INISECT_EXP = "export" INISECT_INS = "instance" +INISECT_HYP = "hypervisor" +INISECT_BEP = "backend" # dynamic device modification -- GitLab