diff options
-rwxr-xr-x | morphlib/exts/kvm.write | 9 | ||||
-rwxr-xr-x | morphlib/writeexts.py | 8 |
2 files changed, 16 insertions, 1 deletions
diff --git a/morphlib/exts/kvm.write b/morphlib/exts/kvm.write index 1579dc1f..c491f206 100755 --- a/morphlib/exts/kvm.write +++ b/morphlib/exts/kvm.write @@ -99,11 +99,18 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension): '''Create the libvirt virtual machine.''' self.status(msg='Creating libvirt/kvm virtual machine') + + attach_disks = self.parse_attach_disks() + attach_opts = [] + for disk in attach_disks: + attach_opts.extend(['--disk', 'path=%s' % disk]) + cliapp.runcmd( ['ssh', ssh_host, 'virt-install', '--connect qemu:///system', '--import', '--name', vm_name, '--ram', '1024', '--vnc', '--noreboot', - '--disk path=%s,bus=ide' % vm_path]) + '--disk path=%s,bus=ide' % vm_path] + + attach_opts) KvmPlusSshWriteExtension().run() diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index a479f3cb..469b8557 100755 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -184,3 +184,11 @@ class WriteExtension(cliapp.Application): cliapp.runcmd(['sync']) time.sleep(2) + def parse_attach_disks(self): + '''Parse $ATTACH_DISKS into list of disks to attach.''' + + if 'ATTACH_DISKS' in os.environ: + s = os.environ['ATTACH_DISKS'] + return s.split(':') + else: + return [] |