diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2014-01-28 13:48:52 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-01-28 14:35:02 +0000 |
commit | 39e489827b8923014606cbf87ed576cfef85363c (patch) | |
tree | c6ea3342208335f5804e5f7a356456e9a818f221 /morphlib/exts | |
parent | 5190c0ef482a4e67b14464d0a6fa267a937c7e46 (diff) | |
parent | 027bd21376e252b6239e13293cec2234815c39bf (diff) | |
download | morph-39e489827b8923014606cbf87ed576cfef85363c.tar.gz |
Merge branch 'baserock/richardmaw/S10140/vbox-3.4.0-deploy'
Reviewed-by: Pedro Alvarez, Lars Wirzenius and Rob Taylor
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-x | morphlib/exts/virtualbox-ssh.write | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write index f18ef804..369c0d61 100755 --- a/morphlib/exts/virtualbox-ssh.write +++ b/morphlib/exts/virtualbox-ssh.write @@ -106,6 +106,19 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): str(os.path.getsize(raw_disk))], stdin=f) + def virtualbox_version(self, ssh_host): + 'Get the version number of the VirtualBox running on the remote host.' + + # --version gives a build id, which looks something like + # 1.2.3r456789, so we need to strip the suffix off and get a tuple + # of the (major, minor, patch) version, since comparing with a + # tuple is more reliable than a string and more convenient than + # comparing against the major, minor and patch numbers directly + self.status(msg='Checking version of remote VirtualBox') + build_id = cliapp.ssh_runcmd(ssh_host, ['VBoxManage', '--version']) + version_string = re.match(r"^([0-9\.])+.*$", build_id.strip()).group(1) + return tuple(int(s or '0') for s in version_string.split('.')) + def create_virtualbox_guest(self, ssh_host, vm_name, vdi_path, autostart): '''Create the VirtualBox virtual machine.''' @@ -117,6 +130,11 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): hostonly_iface = self.get_host_interface(ssh_host) + if self.virtualbox_version(ssh_host) < (4, 3): + sataportcount_option = '--sataportcount' + else: + sataportcount_option = '--portcount' + commands = [ ['createvm', '--name', vm_name, '--ostype', 'Linux26_64', '--register'], @@ -125,7 +143,7 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): '--nic1', 'hostonly', '--hostonlyadapter1', hostonly_iface, '--nic2', 'nat', '--natnet2', 'default'], ['storagectl', vm_name, '--name', 'SATA Controller', - '--add', 'sata', '--bootable', 'on', '--sataportcount', '2'], + '--add', 'sata', '--bootable', 'on', sataportcount_option, '2'], ['storageattach', vm_name, '--storagectl', 'SATA Controller', '--port', '0', '--device', '0', '--type', 'hdd', '--medium', vdi_path], |