Beispiel #1
0
def _rewrite_grub_conf(mount_point, distro):

    latest_rmdisk, rmdisk_version = get_latest_ramdisk(mount_point, distro)

    new_grub_conf = """default=0
timeout=3
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Atmosphere VM (%s)
    root (hd0,0)
    kernel /boot/vmlinuz-%s root=/dev/sda1 ro enforcing=0
    initrd /boot/%s
""" % (rmdisk_version, rmdisk_version, latest_rmdisk)

    with open(os.path.join(mount_point, 'boot/grub/grub.conf'),
              'w') as grub_file:
        grub_file.write(new_grub_conf)

    run_command([
        '/bin/bash', '-c',
        'cd %s/boot/grub/;ln -s grub.conf grub.cfg' % mount_point
    ])
    run_command([
        '/bin/bash', '-c',
        'cd %s/boot/grub/;ln -s grub.conf menu.lst' % mount_point
    ])
Beispiel #2
0
    def _prepare_kvm_export(self, image_path, download_dir):
        """
        Prepare a KVM export (For OpenStack)
        Will also remove Euca-Specific files and add OS-Specific files
        """
        (kernel_dir, ramdisk_dir, mount_point) = self._export_dirs(download_dir)

        #Labeling the image as 'root' allows for less reliance on UUID
        run_command(['e2label', image_path, 'root'])

        out, err = mount_image(image_path, mount_point)
        if err:
            raise Exception("Encountered errors mounting the image: %s" % err)

        xen_to_kvm_centos(mount_point)

        #Determine the latest (KVM) ramdisk to use
        latest_rmdisk, rmdisk_version = get_latest_ramdisk(mount_point)

        #Copy new kernel & ramdisk to the folder
        local_ramdisk_path = _copy_ramdisk(mount_point, rmdisk_version, ramdisk_dir)
        local_kernel_path = _copy_kernel(mount_point, rmdisk_version, kernel_dir)

        run_command(["umount", mount_point])

        #Your new image is ready for upload to OpenStack
        return (image_path, local_kernel_path, local_ramdisk_path)
Beispiel #3
0
def _rewrite_grub_conf(mount_point, distro):

    latest_rmdisk, rmdisk_version = get_latest_ramdisk(mount_point, distro)

    new_grub_conf = """default=0
timeout=3
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Atmosphere VM (%s)
    root (hd0,0)
    kernel /boot/vmlinuz-%s root=/dev/sda1 ro enforcing=0
    initrd /boot/%s
""" % (rmdisk_version, rmdisk_version, latest_rmdisk)

    with open(os.path.join(
            mount_point,'boot/grub/grub.conf'), 'w') as grub_file:
        grub_file.write(new_grub_conf)

    run_command(['/bin/bash','-c', 'cd %s/boot/grub/;ln -s grub.conf grub.cfg'
                 % mount_point])
    run_command(['/bin/bash','-c', 'cd %s/boot/grub/;ln -s grub.conf menu.lst'
                 % mount_point])