Пример #1
0
class TestImage:
    def launch(self):
        install = [VIRT_INST_BIN, '--connect', 'qemu:///system',
                                  '--name', self.name, '--ram', '1024',
                                  '--vcpus', '1', '--accelerate',
                                  '--boot', 'hd', '--import']

        for ovl in self._ovls:
            install.append('--disk')
            install.append(ovl.name)

        run_cmd(install)

        return TestInstance(name, self)

    def guestfs_handle(self):
        h = guestfs.GuestFS(python_return_dict=True)
        for ovl in self._ovls:
            h.add_drive(ovl.name)
        return h

    def inspect(self):
        return self.converter.inspect()

    def list_kernels(self):
        with RootMounted(self.converter._h, '/dev/VolGroup00/LogVol00'):
            grub = redhat.Grub2BIOS(
                self.converter._h, '/dev/VolGroup00/LogVol00', logger)
            return grub.list_kernels()

    def __init__(self, name, *images):
        self.name = name
        self.converter = Converter(['%s/conf/guestconv.db' % env.topdir],
                                   logger)

        # We store a reference to the overlays to ensure they aren't garbage
        # collected before the TestImage
        self._ovls = []

        # Create a qcow2 overlay for each image and add it to the converter
        for img in images:
            ovl = tempfile.NamedTemporaryFile(prefix='guestconv-test.')
            run_cmd([QEMU_IMG_BIN, 'create', '-f', 'qcow2',
                                   '-o', 'backing_file='+img, ovl.name])
            self._ovls.append(ovl)

            self.converter.add_drive(ovl.name)
Пример #2
0
    def __init__(self, name, *images):
        self.name = name
        self.converter = Converter(['%s/conf/guestconv.db' % env.topdir],
                                   logger)

        # We store a reference to the overlays to ensure they aren't garbage
        # collected before the TestImage
        self._ovls = []

        # Create a qcow2 overlay for each image and add it to the converter
        for img in images:
            ovl = tempfile.NamedTemporaryFile(prefix='guestconv-test.')
            run_cmd([QEMU_IMG_BIN, 'create', '-f', 'qcow2',
                                   '-o', 'backing_file='+img, ovl.name])
            self._ovls.append(ovl)

            self.converter.add_drive(ovl.name)