Merge lp:~woggle/vmbuilder/vbox-update into lp:vmbuilder

Proposed by Charles Reiss
Status: Needs review
Proposed branch: lp:~woggle/vmbuilder/vbox-update
Merge into: lp:vmbuilder
Diff against target: 104 lines (+24/-29)
2 files modified
VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl (+22/-28)
VMBuilder/plugins/virtualbox/vm.py (+2/-1)
To merge this branch: bzr merge lp:~woggle/vmbuilder/vbox-update
Reviewer Review Type Date Requested Status
VMBuilder Pending
Review via email: mp+230927@code.launchpad.net

Description of the change

Update virtualbox template to support what VirtualBox > 4.0's VBoxManage expects. (The command-line interface apparently changed substantially.) Also, default to creating 64-bit VMs and add a command-line option to create 32-bit ones.

To post a comment you must log in.
lp:~woggle/vmbuilder/vbox-update updated
491. By Charles Reiss

Missed a few command-line syntax differences.

Unmerged revisions

491. By Charles Reiss

Missed a few command-line syntax differences.

490. By Charles Reiss

Update VirtualBox support to default to 64-bit VMs and use command-line:wqa
from VirtualBox 4.0.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl'
2--- VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl 2010-02-24 22:16:46 +0000
3+++ VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl 2014-08-15 17:47:49 +0000
4@@ -2,7 +2,7 @@
5 #! /usr/bin/env bash
6 ###############################################################################
7 #
8-# This script is used to create und register a new VM
9+# This script is used to create and register a new VM
10 # in VirtualBox
11 #
12 ###############################################################################
13@@ -17,20 +17,20 @@
14 os_type="Other"
15 #end if
16
17+#if $is32
18+os_64=""
19+#else
20+os_64="_64"
21+#end if
22+
23 disk_path="#echo os.path.abspath(os.path.dirname($vm_disks[0]))#"
24
25
26-VBoxManage createvm -name $vm_name -ostype \$os_type -register
27-
28-VBoxManage openmedium #slurp
29-#set $i = 0
30-#for $disk in $vm_disks
31- #set $i = $i + 1
32- #set $disk = os.path.basename(disk)
33-disk \${disk_path}/$disk -type normal #slurp
34-#end for
35-
36-VBoxManage modifyvm $vm_name -memory $memory -cpus $cpus -sata on #slurp
37+VBoxManage createvm --name $vm_name --ostype \$os_type\$os_64 --register
38+
39+VBoxManage modifyvm $vm_name --memory $memory --cpus $cpus
40+VBoxManage storagectl $vm_name --name sata --add sata --bootable on
41+
42 #set $i = 0
43 #for $disk in $vm_disks
44 #set $i = $i + 1
45@@ -38,28 +38,22 @@
46 #if $i >= 31
47 #break
48 #end if
49- #if $i == 1
50- -hda \${disk_path}/$disk #slurp
51- #else if $i == 2
52- -hdb \${disk_path}/$disk #slurp
53- #else if $i == 3
54- -hdd \${disk_path}/$disk #slurp
55- #else
56- -sataport${i} \${disk_path}/$disk #slurp
57- #end if
58+
59+ VBoxManage storageattach $vm_name --storagectl sata --port $i --device 0 --type hdd --medium \${disk_path}/$disk
60 #end for
61
62-#if $mac
63-VBoxManage modifyvm $vm_name -macaddress1 $mac
64-#end if
65
66 #if $ip
67 #if $ip == "dhcp"
68-VBoxManage modifyvm $vm_name -nic1 nat
69+VBoxManage modifyvm $vm_name --nic1 nat
70 #else
71-VBoxManage modifyvm $vm_name -nic1 intnet
72-#end if
73+VBoxManage modifyvm $vm_name --nic1 intnet
74+#end if
75+#end if
76+
77+#if $mac
78+VBoxManage modifyvm $vm_name --macaddress1 $mac
79 #end if
80
81 #activating PAE support for the CPU because some OS (e.g. ubuntu server ) won't boot in a virtual machine without it
82-VBoxManage modifyvm $vm_name -pae on
83+VBoxManage modifyvm $vm_name --pae on
84
85=== modified file 'VMBuilder/plugins/virtualbox/vm.py'
86--- VMBuilder/plugins/virtualbox/vm.py 2011-08-16 14:00:21 +0000
87+++ VMBuilder/plugins/virtualbox/vm.py 2014-08-15 17:47:49 +0000
88@@ -36,6 +36,7 @@
89 group.add_setting('mem', extra_args=['-m'], type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')
90 group.add_setting('cpus', type='int', default=1, help='Assign NUM cpus to the guest vm. [default: %default]')
91 group.add_setting('vbox-disk-format', metavar='FORMAT', default='vdi', help='Desired disk format. Valid options are: vdi vmdk. [default: %default]')
92+ group.add_setting('vbox-32bit', default=False, action='store_true', help='Create a 32-bit VM.')
93
94 def convert(self, disks, destdir):
95 self.imgs = []
96@@ -47,7 +48,7 @@
97 hostname = self.context.distro.get_setting('hostname')
98 mac = self.context.get_setting('mac')
99 ip = self.context.get_setting('ip')
100- vm_deploy_script = VMBuilder.util.render_template('virtualbox', self.context, 'vm_deploy_script', { 'os_type' : self.context.distro.__class__.__name__, 'vm_name' : hostname, 'vm_disks' : self.imgs, 'memory' : self.context.get_setting('mem'), 'cpus' : self.context.get_setting('cpus') })
101+ vm_deploy_script = VMBuilder.util.render_template('virtualbox', self.context, 'vm_deploy_script', { 'os_type' : self.context.distro.__class__.__name__, 'vm_name' : hostname, 'vm_disks' : self.imgs, 'memory' : self.context.get_setting('mem'), 'cpus' : self.context.get_setting('cpus'), 'mac': mac, 'ip': ip, 'is32': self.context.get_setting('vbox-32bit') })
102
103 script_file = '%s/deploy_%s.sh' % (destdir, hostname)
104 fp = open(script_file, 'w')

Subscribers

People subscribed via source and target branches