diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-05-08 17:04:45 +0100 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2013-05-08 16:54:17 +0000 |
commit | 1b2f2013bb85769352e82cfd55a3179fe16ccce2 (patch) | |
tree | d967860c2601d32c67f415fb8f8a310d18364306 /morphlib/exts/virtualbox-ssh.write | |
parent | be72eb1771b0d83bf3a48ac2e59255dc8644e665 (diff) | |
download | morph-1b2f2013bb85769352e82cfd55a3179fe16ccce2.tar.gz |
Add AUTOSTART to kvm and libvirt write extensions
If AUTOSTART is 'yes' then the VM will be started once it is
created. If it is 'no' or undefined, then it will need to be manually
started. If it is any other value, then an exception is raised.
Diffstat (limited to 'morphlib/exts/virtualbox-ssh.write')
-rwxr-xr-x | morphlib/exts/virtualbox-ssh.write | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write index 37f56524..cb17b69b 100755 --- a/morphlib/exts/virtualbox-ssh.write +++ b/morphlib/exts/virtualbox-ssh.write @@ -62,6 +62,7 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): temp_root, location = args ssh_host, vm_name, vdi_path = self.parse_location(location) + autostart = self.parse_autostart() fd, raw_disk = tempfile.mkstemp() os.close(fd) @@ -70,7 +71,8 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): try: self.transfer_and_convert_to_vdi( raw_disk, ssh_host, vdi_path) - self.create_virtualbox_guest(ssh_host, vm_name, vdi_path) + self.create_virtualbox_guest(ssh_host, vm_name, vdi_path, + autostart) except BaseException: sys.stderr.write('Error deploying to VirtualBox') os.remove(raw_disk) @@ -105,7 +107,7 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): str(os.path.getsize(raw_disk))], stdin=f) - def create_virtualbox_guest(self, ssh_host, vm_name, vdi_path): + def create_virtualbox_guest(self, ssh_host, vm_name, vdi_path, autostart): '''Create the VirtualBox virtual machine.''' self.status(msg='Create VirtualBox virtual machine') @@ -134,6 +136,9 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): '--medium', disk] commands.append(cmd) + if autostart: + commands.append(['startvm', vm_name]) + for command in commands: argv = ['ssh', ssh_host, 'VBoxManage'] + command cliapp.runcmd(argv) |