Пример #1
0
            help=
            'Desired disk format. Valid options are: vdi vmdk. [default: %default]'
        )
        self.vm.register_setting_group(group)

    def finalize(self):
        self.imgs = []
        for disk in self.vm.disks:
            img_path = disk.convert(self.vm.destdir, self.vm.vbox_disk_format)
            self.imgs.append(img_path)
            self.vm.result_files.append(img_path)

    def deploy(self):
        vm_deploy_script = VMBuilder.util.render_template(
            'virtualbox', self.vm, 'vm_deploy_script', {
                'os_type': self.vm.distro.__class__.__name__,
                'vm_name': self.vm.hostname,
                'vm_disks': self.imgs,
                'memory': self.vm.mem
            })

        script_file = '%s/deploy_%s.sh' % (self.vm.destdir, self.vm.hostname)
        fp = open(script_file, 'w')
        fp.write(vm_deploy_script)
        fp.close()
        os.chmod(script_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
        self.vm.result_files.append(script_file)


register_hypervisor(VirtualBox)
Пример #2
0
kernel = '%s'
ramdisk = '%s'
memory = %d

root = '/dev/xvda1 ro'
disk = [
%s
]

name = '%s'

dhcp    = 'dhcp'
vif = ['']

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

extra = 'xencons=tty console=tty1 console=hvc0'

""" % (self.vm.name, self.vm.xen_kernel, self.vm.xen_ramdisk, self.vm.mem,
        ',\n'.join([
           "'tap:aio:%s,xvda%d,w'" % (os.path.abspath(img), id + 1)
           for (img, id) in zip(destimages, range(len(destimages)))
        ]), self.vm.name))
        fp.close()
        self.vm.result_files.append(xenconf)


register_hypervisor(Xen)
Пример #3
0
            self.imgs.append(img_path)
            self.call_hooks('fix_ownership', img_path)
            self.cmdline += ['-drive', 'file=%s' % os.path.basename(img_path)]

        self.cmdline += ['"$@"']

    def deploy(self, destdir):
        # No need create run script if vm is registered with libvirt
        if self.context.get_setting('libvirt'):
            return
        
        script = '%s/run.sh' % destdir
        fp = open(script, 'w')
        fp.write("#!/bin/sh\n\nexec %s\n" % ' '.join(self.cmdline))
        fp.close()
        os.chmod(script, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH)
        self.call_hooks('fix_ownership', script)

    def libvirt_domain_type_name(self):
        return 'kvm'

class QEMu(KVM):
    name = 'QEMu'
    arg = 'qemu'

    def libvirt_domain_type_name(self):
        return 'qemu'

register_hypervisor(KVM)
register_hypervisor(QEMu)
Пример #4
0
            if '.' in diskfilename:
                diskfilename = diskfilename[:diskfilename.rindex('.')]

            flat = '%s/%s-flat.vmdk' % (destdir, diskfilename)
            self.vmdks.append(diskfilename)

            move(disk.filename, flat)

            self.call_hooks('fix_ownership', flat)

            # Create disk descriptor file
            sectorTotal = disk.size * 2048
            sector = int(floor(sectorTotal / 16065)) # pseudo geometry

            diskdescriptor = VMBuilder.util.render_template('vmware', self.context, 'flat.vmdk',  { 'adaptertype' : self.adaptertype, 'sectors' : sector, 'diskname' : os.path.basename(flat), 'disksize' : sectorTotal })
            vmdk = '%s/%s.vmdk' % (destdir, diskfilename)

            fp = open(vmdk, 'w')
            fp.write(diskdescriptor)
            fp.close()
            os.chmod(vmdk, stat.S_IRWXU | stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH)

            self.call_hooks('fix_ownership', vmdk)

    def get_disks(self):
        return self.vmdks

register_hypervisor(VMWareServer)
register_hypervisor(VMWareWorkstation6)
register_hypervisor(VMWareEsxi)
Пример #5
0
kernel = '%s'
ramdisk = '%s'
memory = %d

root = '/dev/xvda1 ro'
disk = [
%s
]

name = '%s'

dhcp    = 'dhcp'
vif = ['']

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

extra = 'xencons=tty console=tty1 console=hvc0'

"""  %   (self.vm.name,
          self.vm.xen_kernel,
          self.vm.xen_ramdisk,
          self.vm.mem,
          ',\n'.join(["'tap:aio:%s,xvda%d,w'" % (os.path.abspath(img), id+1) for (img, id) in zip(destimages, range(len(destimages)))]),
          self.vm.name))
        fp.close()
        self.vm.result_files.append(xenconf)

register_hypervisor(Xen)
Пример #6
0
class VirtualBox(Hypervisor):
    preferred_storage = VMBuilder.hypervisor.STORAGE_DISK_IMAGE
    needs_bootloader = True
    name = 'VirtualBox'
    arg = 'vbox'

    def register_options(self):
        group = self.vm.setting_group('VirtualBox options')
        group.add_option('--vbox-disk-format', metavar='FORMAT', default='vdi', help='Desired disk format. Valid options are: vdi vmdk. [default: %default]')
        self.vm.register_setting_group(group)

    def finalize(self):
        self.imgs = []
        for disk in self.vm.disks:
            img_path = disk.convert(self.vm.destdir, self.vm.vbox_disk_format)
            self.imgs.append(img_path)
            self.vm.result_files.append(img_path)

    def deploy(self):
        vm_deploy_script = VMBuilder.util.render_template('virtualbox', self.vm, 'vm_deploy_script', { 'os_type' : self.vm.distro.__class__.__name__, 'vm_name' : self.vm.hostname, 'vm_disks' : self.imgs, 'memory' : self.vm.mem })

        script_file = '%s/deploy_%s.sh' % (self.vm.destdir, self.vm.hostname)
        fp = open(script_file, 'w')
        fp.write(vm_deploy_script)
        fp.close()
        os.chmod(script_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
        self.vm.result_files.append(script_file)

register_hypervisor(VirtualBox)
Пример #7
0
            self.call_hooks('fix_ownership', flat)

            # Create disk descriptor file
            sectorTotal = disk.size * 2048
            sector = int(floor(sectorTotal / 16065))  # pseudo geometry

            diskdescriptor = VMBuilder.util.render_template(
                'vmware', self.context, 'flat.vmdk', {
                    'adaptertype': self.adaptertype,
                    'sectors': sector,
                    'diskname': os.path.basename(flat),
                    'disksize': sectorTotal
                })
            vmdk = '%s/%s.vmdk' % (destdir, diskfilename)

            fp = open(vmdk, 'w')
            fp.write(diskdescriptor)
            fp.close()
            os.chmod(vmdk,
                     stat.S_IRWXU | stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH)

            self.call_hooks('fix_ownership', vmdk)

    def get_disks(self):
        return self.vmdks


register_hypervisor(VMWareServer)
register_hypervisor(VMWareWorkstation6)
register_hypervisor(VMWareEsxi)