Commits

Albert Hopkins committed 828b3e3 Merge

Merged head of external-kernel branch

  • Participants
  • Parent commits 13c23a2, e6b449b
  • Tags 0.4.8

Comments (0)

Files changed (1)

File hemp/hemp.py

 
 import settings
 
-__version__ = '0.4.7'
+__version__ = '0.4.8'
 __revision__ = '$Revision$'
 
 DIRS = ('images',)
 FILES = ('fabfile.py', 'helpers.py', 'settings.py', 'custom.py')
 BASE_IMG = '.base.qcow2'
+KERNEL_IMG = '.kernel'
+INITRD_IMG = '.initrd'
 CLOUD_FILE_SIGNATURE = '\x08\x05\x13\x16'
 CLOUD_FILE_FORMAT = 2
 
 def copy_image(domtree, basedir):
     """Copy the base image to basedir (as BASE_IMG)"""
 
-
     disk = domtree.find('devices/disk/source')
     assert (disk is not None)
     filename = disk.get('file')
     return
 
 
+def copy_ext_kernel(domtree, basedir):
+    """Copy the external kernel and initrd (if defined in the xml)"""
+
+    kernel = domtree.find('os/kernel')
+    if kernel is not None:
+        kernel_fn = kernel.text
+        shutil.copy(kernel_fn, os.path.join(basedir, 'images', KERNEL_IMG))
+
+    initrd = domtree.find('os/initrd')
+    if initrd is not None:
+        initrd_fn = initrd.text
+        shutil.copy(initrd_fn, os.path.join(basedir, 'images', INITRD_IMG))
+    return
+
+
 def create_xml_template(domtree):
     """From existing xml (Elementree) dom description, make necessary
     edits. Return new domtree"""
         # try to make compatible with older versions of qemu than the source
         os_type.set('machine', 'pc')
 
+    kernel = domtree.find('os/kernel')
+    if kernel is not None:
+        kernel.text = '%(dirname)s/images/' + KERNEL_IMG
+
+    initrd = domtree.find('os/initrd')
+    if initrd is not None:
+        initrd.text = '%(dirname)s/images/' + INITRD_IMG
+
     # change <emulator>
     emulator = domtree.find('devices/emulator')
     if emulator is not None:
     mkdirs(basedir)
     install_files(basedir)
     copy_image(domtree, basedir)
+    copy_ext_kernel(domtree, basedir)
     dump_template(domtree, basedir)
 
     # set default cluster