diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-09 21:04:46 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-09 23:10:54 +0000 |
commit | e4f27e978c28c73040c356a497df1c4180edc60f (patch) | |
tree | 4ae1bb00ec84190c07f727f5211a29ac702a105e /kvm.write | |
parent | 10c0308d43de8e857bd3b82dcc028fd23b4dbfc1 (diff) | |
download | definitions-e4f27e978c28c73040c356a497df1c4180edc60f.tar.gz |
Sync write extensions with morph
This adds improved autostart logic for kvm, the new filesystem layout,
a working tar.write, network config for virtualbox and allowing paths
with spaces in.
Diffstat (limited to 'kvm.write')
-rwxr-xr-x | kvm.write | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -94,7 +94,7 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension): self.status(msg='Transferring disk image') target = '%s:%s' % (ssh_host, vm_path) with open(raw_disk, 'rb') as f: - cliapp.runcmd(['rsync', '-zS', raw_disk, target]) + cliapp.runcmd(['rsync', '-szS', raw_disk, target]) def create_libvirt_guest(self, ssh_host, vm_name, vm_path, autostart): '''Create the libvirt virtual machine.''' @@ -106,16 +106,23 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension): for disk in attach_disks: attach_opts.extend(['--disk', 'path=%s' % disk]) + if 'NIC_CONFIG' in os.environ: + nics = os.environ['NIC_CONFIG'].split() + for nic in nics: + attach_opts.extend(['--network', nic]) + ram_mebibytes = str(self.get_ram_size() / (1024**2)) - cmdline = ['ssh', ssh_host, - 'virt-install', '--connect qemu:///system', '--import', + cmdline = ['virt-install', '--connect', 'qemu:///system', '--import', '--name', vm_name, '--vnc', '--ram=%s' % ram_mebibytes, - '--disk path=%s,bus=ide' % vm_path] + attach_opts + '--disk', 'path=%s,bus=ide' % vm_path] + attach_opts if not autostart: cmdline += ['--noreboot'] - cliapp.runcmd(cmdline) + cliapp.ssh_runcmd(ssh_host, cmdline) + if autostart: + cliapp.ssh_runcmd(ssh_host, + ['virsh', '--connect', 'qemu:///system', 'autostart', vm_name]) KvmPlusSshWriteExtension().run() |