Commit 535b49cb authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for OS parameters during import/export



Nothing special here, just copy/adjust the beparams code.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 1052d622
......@@ -2150,6 +2150,10 @@ def FinalizeExport(instance, snap_disks):
for name, value in instance.beparams.items():
config.set(constants.INISECT_BEP, name, str(value))
config.add_section(constants.INISECT_OSP)
for name, value in instance.osparams.items():
config.set(constants.INISECT_OSP, name, str(value))
utils.WriteFile(utils.PathJoin(destdir, constants.EXPORT_CONF_FILE),
data=config.Dumps())
shutil.rmtree(finaldestdir, ignore_errors=True)
......
......@@ -6553,6 +6553,12 @@ class LUCreateInstance(LogicalUnit):
einfo.has_option(constants.INISECT_INS, name)):
self.op.beparams[name] = einfo.get(constants.INISECT_INS, name)
if einfo.has_section(constants.INISECT_OSP):
# use the parameters, without overriding
for name, value in einfo.items(constants.INISECT_OSP):
if name not in self.op.osparams:
self.op.osparams[name] = value
def _RevertToDefaults(self, cluster):
"""Revert the instance parameters to the default values.
......@@ -6573,6 +6579,11 @@ class LUCreateInstance(LogicalUnit):
for name in constants.NICS_PARAMETERS:
if name in nic and name in nic_defs and nic[name] == nic_defs[name]:
del nic[name]
# osparams
os_defs = cluster.SimpleFillOS(self.op.os_type, {})
for name in self.op.osparams.keys():
if name in os_defs and os_defs[name] == self.op.osparams[name]:
del self.op.osparams[name]
def CheckPrereq(self):
"""Check prerequisites.
......
......@@ -396,6 +396,7 @@ INISECT_EXP = "export"
INISECT_INS = "instance"
INISECT_HYP = "hypervisor"
INISECT_BEP = "backend"
INISECT_OSP = "os"
# dynamic device modification
DDM_ADD = 'add'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment