Commit 03abdbe8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change the Xen PVM to use the new kernel options

This patch changes the hypervisor to use the new kernel and initrd
instance attributes. They kernel is handled as expected (use the custom
or the default one), but the initrd is treated a little bit special, in
order to keep compatibility with previous behaviour:
  - if customized and not found, raise an error
  - if default and not found, do not use one

Reviewed-by: imsnah
parent 71aa8f73
......@@ -136,7 +136,7 @@ class XenHypervisor(BaseHypervisor):
@staticmethod
def _WriteConfigFile(instance, block_devices, extra_args):
"""A Xen instance config file.
"""Write the Xen config file for the instance.
"""
raise NotImplementedError
......@@ -316,14 +316,42 @@ class XenPvmHypervisor(XenHypervisor):
@staticmethod
def _WriteConfigFile(instance, block_devices, extra_args):
"""Create a Xen instance config file.
"""Write the Xen config file for the instance.
"""
config = StringIO()
config.write("# this is autogenerated by Ganeti, please do not edit\n#\n")
config.write("kernel = '%s'\n" % constants.XEN_KERNEL)
if os.path.exists(constants.XEN_INITRD):
config.write("ramdisk = '%s'\n" % constants.XEN_INITRD)
# kernel handling
if instance.kernel_path in (None, constants.VALUE_DEFAULT):
kpath = constants.XEN_KERNEL
else:
if not os.path.exists(instance.kernel_path):
raise errors.HypervisorError("The kernel %s for instance %s is"
" missing" % (instance.kernel_path,
instance.name))
kpath = instance.kernel_path
config.write("kernel = '%s'\n" % kpath)
# initrd handling
if instance.initrd_path in (None, constants.VALUE_DEFAULT):
if os.path.exists(constants.XEN_INITRD):
initrd_path = constants.XEN_INITRD
else:
initrd_path = None
elif instance.initrd_path == constants.VALUE_NONE:
initrd_path = None
else:
if not os.path.exists(instance.initrd_path):
raise errors.HypervisorError("The initrd %s for instance %s is"
" missing" % (instance.initrd_path,
instance.name))
initrd_path = instance.initrd_path
if initrd_path:
config.write("ramdisk = '%s'\n" % initrd_path)
# rest of the settings
config.write("memory = %d\n" % instance.memory)
config.write("vcpus = %d\n" % instance.vcpus)
config.write("name = '%s'\n" % instance.name)
......
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