summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-05-16 09:39:37 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-05-16 09:39:37 +0000
commitd8436a55926b6445d3afaa96546a485896291ab7 (patch)
treecec17c4060e3ba694f525654c5200b623289c23a
parent06b61dd0344d8e3bf1039dffc964e1e58556e75d (diff)
downloadmorph-d8436a55926b6445d3afaa96546a485896291ab7.tar.gz
VirtualBox Write Extension: Vagrant support
Add support to the VirtualBox write extension to notice if we are doing a Vagrant Basebox installation and not do the clever network setup we normally do to allow machines to talk to one another since this confuses Vagrant quite a bit if it is left in.
-rwxr-xr-xmorphlib/exts/virtualbox-ssh.write22
1 files changed, 15 insertions, 7 deletions
diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write
index b9d53579..47584b83 100755
--- a/morphlib/exts/virtualbox-ssh.write
+++ b/morphlib/exts/virtualbox-ssh.write
@@ -63,7 +63,9 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
temp_root, location = args
ssh_host, vm_name, vdi_path = self.parse_location(location)
autostart = self.get_environment_boolean('AUTOSTART')
-
+
+ vagrant = self.get_environment_boolean('VAGRANT')
+
fd, raw_disk = tempfile.mkstemp()
os.close(fd)
self.create_local_system(temp_root, raw_disk)
@@ -72,7 +74,7 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
self.transfer_and_convert_to_vdi(
raw_disk, ssh_host, vdi_path)
self.create_virtualbox_guest(ssh_host, vm_name, vdi_path,
- autostart)
+ autostart, vagrant)
except BaseException:
sys.stderr.write('Error deploying to VirtualBox')
os.remove(raw_disk)
@@ -119,7 +121,7 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
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):
+ def create_virtualbox_guest(self, ssh_host, vm_name, vdi_path, autostart, vagrant):
'''Create the VirtualBox virtual machine.'''
self.status(msg='Create VirtualBox virtual machine')
@@ -128,7 +130,8 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
vcpu_count = str(self.get_vcpu_count())
- hostonly_iface = self.get_host_interface(ssh_host)
+ if not vagrant:
+ hostonly_iface = self.get_host_interface(ssh_host)
if self.virtualbox_version(ssh_host) < (4, 3, 0):
sataportcount_option = '--sataportcount'
@@ -139,15 +142,20 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
['createvm', '--name', vm_name, '--ostype', 'Linux26_64',
'--register'],
['modifyvm', vm_name, '--ioapic', 'on',
- '--memory', ram_mebibytes, '--cpus', vcpu_count,
- '--nic1', 'hostonly', '--hostonlyadapter1', hostonly_iface,
- '--nic2', 'nat', '--natnet2', 'default'],
+ '--memory', ram_mebibytes, '--cpus', vcpu_count],
['storagectl', vm_name, '--name', 'SATA Controller',
'--add', 'sata', '--bootable', 'on', sataportcount_option, '2'],
['storageattach', vm_name, '--storagectl', 'SATA Controller',
'--port', '0', '--device', '0', '--type', 'hdd', '--medium',
vdi_path],
]
+ if vagrant:
+ commands[1].extend(['--nic1', 'nat',
+ '--natnet1', 'default'])
+ else:
+ commands[1].extend(['--nic1', 'hostonly',
+ '--hostonlyadapter1', hostonly_iface,
+ '--nic2', 'nat', '--natnet2', 'default'])
attach_disks = self.parse_attach_disks()
for device_no, disk in enumerate(attach_disks, 1):