beaker-vagrant 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +17 -9
- data/.github/workflows/test.yml +40 -11
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +383 -0
- data/CHANGELOG.md +202 -0
- data/Gemfile +3 -24
- data/README.md +26 -9
- data/Rakefile +34 -120
- data/beaker-vagrant.gemspec +24 -24
- data/bin/beaker-vagrant +1 -3
- data/lib/beaker/hypervisor/vagrant/mount_folder.rb +1 -1
- data/lib/beaker/hypervisor/vagrant.rb +72 -83
- data/lib/beaker/hypervisor/vagrant_custom.rb +1 -1
- data/lib/beaker/hypervisor/vagrant_desktop.rb +9 -5
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +1 -7
- data/lib/beaker/hypervisor/vagrant_parallels.rb +2 -2
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +35 -32
- data/lib/beaker/hypervisor/vagrant_workstation.rb +9 -5
- data/lib/beaker-vagrant/version.rb +1 -1
- data/spec/beaker/hypervisor/vagrant_custom_spec.rb +14 -15
- data/spec/beaker/hypervisor/vagrant_desktop_spec.rb +20 -20
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +11 -11
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +23 -22
- data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +15 -15
- data/spec/beaker/hypervisor/vagrant_spec.rb +301 -309
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +50 -29
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -2
- metadata +69 -36
@@ -2,15 +2,14 @@ require 'open3'
|
|
2
2
|
|
3
3
|
module Beaker
|
4
4
|
class Vagrant < Beaker::Hypervisor
|
5
|
-
|
6
5
|
require 'beaker/hypervisor/vagrant/mount_folder'
|
7
6
|
require 'beaker/hypervisor/vagrant_virtualbox'
|
8
7
|
|
9
8
|
def rand_chunk
|
10
|
-
(2
|
9
|
+
rand(2..254).to_s # don't want a 0, 1, or a 255
|
11
10
|
end
|
12
11
|
|
13
|
-
def randip(hypervisor=nil)
|
12
|
+
def randip(hypervisor = nil)
|
14
13
|
case hypervisor
|
15
14
|
when /libvirt/
|
16
15
|
"10.254.#{rand_chunk}.#{rand_chunk}"
|
@@ -20,12 +19,12 @@ module Beaker
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def private_network_generator(host)
|
23
|
-
private_network_string = " v.vm.network :private_network, ip: \"#{host['ip'].to_s}\", :netmask => \"#{host['netmask'] ||=
|
24
|
-
if host['network_mac']
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
private_network_string = " v.vm.network :private_network, ip: \"#{host['ip'].to_s}\", :netmask => \"#{host['netmask'] ||= '255.255.0.0'}\""
|
23
|
+
private_network_string << if host['network_mac']
|
24
|
+
", :mac => \"#{host['network_mac']}\"\n"
|
25
|
+
else
|
26
|
+
"\n"
|
27
|
+
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def connection_preference(host)
|
@@ -33,34 +32,35 @@ module Beaker
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def shell_provisioner_generator(provisioner_config)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
shell_provisioner_string
|
35
|
+
if provisioner_config['path'].nil? || provisioner_config['path'].empty?
|
36
|
+
raise 'No path defined for shell_provisioner or path empty'
|
37
|
+
end
|
38
|
+
|
39
|
+
if provisioner_config['args'].nil?
|
40
|
+
" v.vm.provision 'shell', :path => '#{provisioner_config['path']}'\n"
|
43
41
|
else
|
44
|
-
|
42
|
+
" v.vm.provision 'shell', :path => '#{provisioner_config['path']}', :args => '#{provisioner_config['args']}' \n"
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
|
-
def make_vfile
|
49
|
-
#HACK HACK HACK - add checks here to ensure that we have box + box_url
|
50
|
-
#generate the VagrantFile
|
46
|
+
def make_vfile(hosts, options = {})
|
47
|
+
# HACK: HACK HACK - add checks here to ensure that we have box + box_url
|
48
|
+
# generate the VagrantFile
|
51
49
|
v_file = "Vagrant.configure(\"2\") do |c|\n"
|
52
50
|
v_file << " c.ssh.forward_agent = true\n" if options[:forward_ssh_agent] == true
|
53
51
|
v_file << " c.ssh.insert_key = false\n"
|
54
52
|
|
55
53
|
hosts.each do |host|
|
56
|
-
host.name.tr!('_','-') # Rewrite Hostname with hyphens instead of underscores to get legal hostname
|
54
|
+
host.name.tr!('_', '-') # Rewrite Hostname with hyphens instead of underscores to get legal hostname
|
57
55
|
set_host_default_ip(host)
|
58
56
|
v_file << " c.vm.define '#{host.name}' do |v|\n"
|
59
57
|
v_file << " v.vm.hostname = '#{host.name}'\n"
|
60
58
|
v_file << " v.vm.box = '#{host['box']}'\n"
|
61
59
|
v_file << " v.vm.box_url = '#{host['box_url']}'\n" unless host['box_url'].nil?
|
62
60
|
v_file << " v.vm.box_version = '#{host['box_version']}'\n" unless host['box_version'].nil?
|
63
|
-
|
61
|
+
unless host['box_download_insecure'].nil?
|
62
|
+
v_file << " v.vm.box_download_insecure = '#{host['box_download_insecure']}'\n"
|
63
|
+
end
|
64
64
|
v_file << " v.vm.box_check_update = '#{host['box_check_update'] ||= 'true'}'\n"
|
65
65
|
v_file << " v.vm.synced_folder '.', '/vagrant', disabled: true\n" if host['synced_folder'] == 'disabled'
|
66
66
|
v_file << shell_provisioner_generator(host['shell_provisioner']) if host['shell_provisioner']
|
@@ -79,7 +79,7 @@ module Beaker
|
|
79
79
|
|
80
80
|
unless host['forwarded_ports'].nil?
|
81
81
|
host['forwarded_ports'].each do |_name, port|
|
82
|
-
fwd =
|
82
|
+
fwd = ' v.vm.network :forwarded_port,'
|
83
83
|
fwd << " protocol: '#{port[:protocol]}'," unless port[:protocol].nil?
|
84
84
|
fwd << " guest_ip: '#{port[:to_ip]}'," unless port[:to_ip].nil?
|
85
85
|
fwd << " guest: #{port[:to]},"
|
@@ -92,9 +92,9 @@ module Beaker
|
|
92
92
|
end
|
93
93
|
|
94
94
|
if /windows/i.match(host['platform'])
|
95
|
-
#due to a regression bug in versions of vagrant 1.6.2, 1.6.3, 1.6.4, >= 1.7.3 ssh fails to forward
|
96
|
-
#automatically (note <=1.6.1, 1.6.5, 1.7.0 - 1.7.2 are uneffected)
|
97
|
-
#Explicitly setting SSH port forwarding due to this bug
|
95
|
+
# due to a regression bug in versions of vagrant 1.6.2, 1.6.3, 1.6.4, >= 1.7.3 ssh fails to forward
|
96
|
+
# automatically (note <=1.6.1, 1.6.5, 1.7.0 - 1.7.2 are uneffected)
|
97
|
+
# Explicitly setting SSH port forwarding due to this bug
|
98
98
|
v_file << " v.vm.network :forwarded_port, guest: 22, host: 2222, id: 'ssh', auto_correct: true\n"
|
99
99
|
v_file << " v.vm.network :forwarded_port, guest: 3389, host: 3389, id: 'rdp', auto_correct: true\n"
|
100
100
|
v_file << " v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true\n"
|
@@ -119,11 +119,11 @@ module Beaker
|
|
119
119
|
# http://www.secnetix.de/olli/FreeBSD/mnamelen.hawk
|
120
120
|
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=167105
|
121
121
|
#
|
122
|
-
if host['vagrant_freebsd_nfs'].nil?
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
v_file << if host['vagrant_freebsd_nfs'].nil?
|
123
|
+
" v.vm.synced_folder '.', '/vagrant', type: 'rsync'\n"
|
124
|
+
else
|
125
|
+
" v.vm.synced_folder '.', '/vagrant', :nfs => true\n"
|
126
|
+
end
|
127
127
|
end
|
128
128
|
|
129
129
|
v_file << self.class.provider_vfile_section(host, options)
|
@@ -135,18 +135,16 @@ module Beaker
|
|
135
135
|
|
136
136
|
# In case this is called directly
|
137
137
|
FileUtils.mkdir_p(@vagrant_path)
|
138
|
-
File.
|
139
|
-
f.write(v_file)
|
140
|
-
end
|
138
|
+
File.write(@vagrant_file, v_file)
|
141
139
|
end
|
142
140
|
|
143
|
-
def self.provider_vfile_section
|
141
|
+
def self.provider_vfile_section(host, options)
|
144
142
|
# Backwards compatibility; default to virtualbox
|
145
143
|
Beaker::VagrantVirtualbox.provider_vfile_section(host, options)
|
146
144
|
end
|
147
145
|
|
148
146
|
def set_all_ssh_config
|
149
|
-
@logger.debug
|
147
|
+
@logger.debug 'configure vagrant boxes (set ssh-config, switch to root user, hack etc/hosts)'
|
150
148
|
@hosts.each do |host|
|
151
149
|
if host[:platform] =~ /windows/
|
152
150
|
@logger.debug "skip ssh hacks on windows box #{host[:name]}"
|
@@ -158,16 +156,16 @@ module Beaker
|
|
158
156
|
|
159
157
|
set_ssh_config host, 'vagrant'
|
160
158
|
|
161
|
-
#copy vagrant's keys to roots home dir, to allow for login as root
|
159
|
+
# copy vagrant's keys to roots home dir, to allow for login as root
|
162
160
|
copy_ssh_to_root host, @options
|
163
|
-
#ensure that root login is enabled for this host
|
161
|
+
# ensure that root login is enabled for this host
|
164
162
|
enable_root_login host, @options
|
165
|
-
#shut down connection, will reconnect on next exec
|
163
|
+
# shut down connection, will reconnect on next exec
|
166
164
|
host.close
|
167
165
|
|
168
166
|
set_ssh_config host, default_user
|
169
167
|
|
170
|
-
#allow the user to set the env
|
168
|
+
# allow the user to set the env
|
171
169
|
begin
|
172
170
|
host.ssh_permit_user_environment
|
173
171
|
host.close
|
@@ -179,14 +177,12 @@ module Beaker
|
|
179
177
|
hack_etc_hosts @hosts, @options
|
180
178
|
end
|
181
179
|
|
182
|
-
def set_ssh_config
|
180
|
+
def set_ssh_config(host, user)
|
183
181
|
return unless Dir.exist?(@vagrant_path)
|
184
182
|
|
185
183
|
ssh_config = Dir.chdir(@vagrant_path) do
|
186
184
|
stdout, _, status = Open3.capture3(@vagrant_env, 'vagrant', 'ssh-config', host.name)
|
187
|
-
unless status.success?
|
188
|
-
raise "Failed to 'vagrant ssh-config' for #{host.name}"
|
189
|
-
end
|
185
|
+
raise "Failed to 'vagrant ssh-config' for #{host.name}" unless status.success?
|
190
186
|
|
191
187
|
Tempfile.create do |f|
|
192
188
|
f.write(stdout)
|
@@ -208,9 +204,10 @@ module Beaker
|
|
208
204
|
@options = options
|
209
205
|
@logger = options[:logger]
|
210
206
|
@hosts = vagrant_hosts
|
211
|
-
@vagrant_path = File.expand_path(File.join('.vagrant', 'beaker_vagrant_files',
|
212
|
-
|
213
|
-
@
|
207
|
+
@vagrant_path = File.expand_path(File.join('.vagrant', 'beaker_vagrant_files',
|
208
|
+
'beaker_' + File.basename(options[:hosts_file])))
|
209
|
+
@vagrant_file = File.expand_path(File.join(@vagrant_path, 'Vagrantfile'))
|
210
|
+
@vagrant_env = { 'RUBYLIB' => '', 'RUBYOPT' => '' }
|
214
211
|
end
|
215
212
|
|
216
213
|
def configure(opts = {})
|
@@ -227,13 +224,13 @@ module Beaker
|
|
227
224
|
def provision(provider = nil)
|
228
225
|
FileUtils.mkdir_p(@vagrant_path)
|
229
226
|
|
230
|
-
#setting up new vagrant hosts
|
231
|
-
#make sure that any old boxes are dead dead dead
|
227
|
+
# setting up new vagrant hosts
|
228
|
+
# make sure that any old boxes are dead dead dead
|
232
229
|
begin
|
233
|
-
vagrant_cmd(
|
230
|
+
vagrant_cmd('destroy --force') if File.file?(@vagrant_file)
|
234
231
|
rescue RuntimeError => e
|
235
232
|
# LATER: use <<~MESSAGE once we're on Ruby 2.3
|
236
|
-
@logger.debug(%
|
233
|
+
@logger.debug(%(
|
237
234
|
Beaker failed to destroy the existing VM's. If you think this is
|
238
235
|
an error or you upgraded from an older version of beaker try
|
239
236
|
verifying the VM exists and deleting the existing Vagrantfile if
|
@@ -243,7 +240,7 @@ module Beaker
|
|
243
240
|
vagrant status
|
244
241
|
vagrant destroy # only need to run this is a VM is not created
|
245
242
|
rm #{@vagrant_file} # only do this if all VM's are actually destroyed
|
246
|
-
|
243
|
+
).each_line.map(&:strip).join("\n"))
|
247
244
|
raise e
|
248
245
|
end
|
249
246
|
|
@@ -255,42 +252,37 @@ module Beaker
|
|
255
252
|
end
|
256
253
|
|
257
254
|
def cleanup
|
258
|
-
@logger.debug
|
259
|
-
@logger.notify
|
260
|
-
vagrant_cmd(
|
255
|
+
@logger.debug 'removing temporary ssh-config files per-vagrant box'
|
256
|
+
@logger.notify 'Destroying vagrant boxes'
|
257
|
+
vagrant_cmd('destroy --force')
|
261
258
|
FileUtils.rm_rf(@vagrant_path)
|
262
259
|
end
|
263
260
|
|
264
261
|
def vagrant_cmd(args)
|
265
262
|
Dir.chdir(@vagrant_path) do
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
@logger.info(line)
|
271
|
-
end
|
272
|
-
|
273
|
-
unless wait_thr.value.success?
|
274
|
-
raise "Failed to exec 'vagrant #{args}'. Error was #{stderr.read}"
|
275
|
-
end
|
276
|
-
}
|
277
|
-
rescue => e
|
278
|
-
if e.to_s =~ /WinRM/m
|
279
|
-
sleep(10)
|
280
|
-
|
281
|
-
retry if (retries += 1) < 6
|
263
|
+
retries ||= 0
|
264
|
+
Open3.popen3(@vagrant_env, "vagrant #{args}") do |stdin, stdout, stderr, wait_thr|
|
265
|
+
while line = stdout.gets
|
266
|
+
@logger.info(line)
|
282
267
|
end
|
283
268
|
|
284
|
-
raise
|
269
|
+
raise "Failed to exec 'vagrant #{args}'. Error was #{stderr.read}" unless wait_thr.value.success?
|
285
270
|
end
|
271
|
+
rescue StandardError => e
|
272
|
+
if e.to_s =~ /WinRM/m
|
273
|
+
sleep(10)
|
274
|
+
|
275
|
+
retry if (retries += 1) < 6
|
276
|
+
end
|
277
|
+
|
278
|
+
raise e
|
286
279
|
end
|
287
280
|
end
|
288
281
|
|
289
282
|
def self.cpus(host, options)
|
290
|
-
|
291
|
-
when host['vagrant_cpus']
|
283
|
+
if host['vagrant_cpus']
|
292
284
|
host['vagrant_cpus']
|
293
|
-
|
285
|
+
elsif options['vagrant_cpus']
|
294
286
|
options['vagrant_cpus']
|
295
287
|
else
|
296
288
|
'1'
|
@@ -298,17 +290,14 @@ module Beaker
|
|
298
290
|
end
|
299
291
|
|
300
292
|
def self.memsize(host, options)
|
301
|
-
|
302
|
-
when host['vagrant_memsize']
|
293
|
+
if host['vagrant_memsize']
|
303
294
|
host['vagrant_memsize']
|
304
|
-
|
295
|
+
elsif options['vagrant_memsize']
|
305
296
|
options['vagrant_memsize']
|
297
|
+
elsif host['platform'] =~ /windows/
|
298
|
+
'2048'
|
306
299
|
else
|
307
|
-
|
308
|
-
'2048'
|
309
|
-
else
|
310
|
-
'1024'
|
311
|
-
end
|
300
|
+
'1024'
|
312
301
|
end
|
313
302
|
end
|
314
303
|
|
@@ -5,13 +5,17 @@ class Beaker::VagrantDesktop < Beaker::Vagrant
|
|
5
5
|
super
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.provider_vfile_section(host, options)
|
8
|
+
def self.provider_vfile_section(host, options)
|
9
9
|
v_provider = " v.vm.provider :vmware_desktop do |v|\n"
|
10
10
|
v_provider << " v.vmx['gui'] = true\n" if host['gui'] == true
|
11
|
-
v_provider << " v.vmx['memsize'] = '#{memsize(host,options)}'\n"
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
v_provider << " v.vmx['memsize'] = '#{memsize(host, options)}'\n"
|
12
|
+
unless host['whitelist_verified'].nil?
|
13
|
+
v_provider << " v.vmx['whitelist_verified'] = '#{host['whitelist_verified']}'\n"
|
14
|
+
end
|
15
|
+
v_provider << " v.vmx['functional_hgfs'] = '#{host['functional_hgfs']}'\n" unless host['functional_hgfs'].nil?
|
16
|
+
unless host['unmount_default_hgfs'].nil?
|
17
|
+
v_provider << " v.vmx['unmount_default_hgfs'] = '#{host['unmount_default_hgfs']}'\n"
|
18
|
+
end
|
15
19
|
v_provider << " v.vmx['utility_port'] = '#{host['utility_port']}'\n" unless host['utility_port'].nil?
|
16
20
|
v_provider << " end\n"
|
17
21
|
end
|
@@ -8,7 +8,7 @@ class Beaker::VagrantLibvirt < Beaker::Vagrant
|
|
8
8
|
# not affect VirtualBox
|
9
9
|
vagrant_path_digest = Digest::SHA256.hexdigest(@vagrant_path)
|
10
10
|
@vagrant_path += '_' + vagrant_path_digest[0..2] + vagrant_path_digest[-3..-1]
|
11
|
-
@vagrant_file = File.expand_path(File.join(@vagrant_path,
|
11
|
+
@vagrant_file = File.expand_path(File.join(@vagrant_path, 'Vagrantfile'))
|
12
12
|
end
|
13
13
|
|
14
14
|
def provision(provider = 'libvirt')
|
@@ -29,10 +29,4 @@ class Beaker::VagrantLibvirt < Beaker::Vagrant
|
|
29
29
|
|
30
30
|
options['libvirt'].map { |k, v| " node.#{k} = '#{v}'" }
|
31
31
|
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def set_host_default_ip(host)
|
36
|
-
# In vagrant-libvirt hosts get a management IP, no need for a default
|
37
|
-
end
|
38
32
|
end
|
@@ -6,10 +6,10 @@ class Beaker::VagrantParallels < Beaker::Vagrant
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.provider_vfile_section(host, options)
|
9
|
-
provider_section =
|
9
|
+
provider_section = ''
|
10
10
|
provider_section << " v.vm.provider :parallels do |prl|\n"
|
11
11
|
provider_section << " prl.optimize_power_consumption = false\n"
|
12
|
-
provider_section << " prl.memory = '#{memsize(host,options)}'\n"
|
12
|
+
provider_section << " prl.memory = '#{memsize(host, options)}'\n"
|
13
13
|
provider_section << " prl.update_guest_tools = false\n" if options[:prl_update_guest_tools] == 'disable'
|
14
14
|
provider_section << " end\n"
|
15
15
|
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'beaker/hypervisor/vagrant'
|
2
2
|
|
3
3
|
class Beaker::VagrantVirtualbox < Beaker::Vagrant
|
4
|
-
|
5
4
|
CONTROLLER_OPTIONS = {
|
6
|
-
LSILogic: [
|
7
|
-
IntelAHCI: [
|
8
|
-
PIIX4: [
|
9
|
-
USB: [
|
5
|
+
LSILogic: ['--add', 'scsi', '--portcount', '16', '--controller', 'LSILogic', '--bootable', 'off'],
|
6
|
+
IntelAHCI: ['--add', 'sata', '--portcount', '2', '--controller', 'IntelAHCI', '--bootable', 'off'],
|
7
|
+
PIIX4: ['--add', 'ide', '--portcount', '2', '--controller', 'PIIX4', '--bootable', 'off'],
|
8
|
+
USB: ['--add', 'usb', '--portcount', '8', '--controller', 'USB', '--bootable', 'off']
|
10
9
|
}.freeze
|
11
10
|
|
12
11
|
def provision(provider = 'virtualbox')
|
@@ -15,21 +14,24 @@ class Beaker::VagrantVirtualbox < Beaker::Vagrant
|
|
15
14
|
|
16
15
|
# Generate a VM customization string
|
17
16
|
def self.vb_customize(command, args)
|
18
|
-
" vb.customize ['#{command}', #{args.map{|a| "'#{a.to_s}'"}.join(
|
17
|
+
" vb.customize ['#{command}', #{args.map { |a| "'#{a.to_s}'" }.join(', ')}]\n"
|
19
18
|
end
|
20
19
|
|
21
20
|
# Generate a VM customization string for the current VM
|
22
21
|
def self.vb_customize_vm(command, args)
|
23
|
-
" vb.customize ['#{command}', :id, #{args.map{|a| "'#{a.to_s}'"}.join(
|
22
|
+
" vb.customize ['#{command}', :id, #{args.map { |a| "'#{a.to_s}'" }.join(', ')}]\n"
|
24
23
|
end
|
25
24
|
|
26
25
|
def self.provider_vfile_section(host, options)
|
27
26
|
# Allow memory and CPUs to be set at a per node level or overall, and take the most specific setting
|
28
27
|
# Removing audio is a workaround of a virtualbox bug that gives error message : "The specified string / bytes buffer was to small"
|
29
|
-
provider_section =
|
28
|
+
provider_section = ''
|
30
29
|
provider_section << " v.vm.provider :virtualbox do |vb|\n"
|
31
|
-
provider_section << " vb.customize ['modifyvm', :id, '--memory', '#{memsize(host,
|
32
|
-
|
30
|
+
provider_section << " vb.customize ['modifyvm', :id, '--memory', '#{memsize(host,
|
31
|
+
options)}', '--cpus', '#{cpus(
|
32
|
+
host, options
|
33
|
+
)}', '--audio', 'none']\n"
|
34
|
+
provider_section << ' vb.vbguest.auto_update = false' if options[:vbguest_plugin] == 'disable'
|
33
35
|
|
34
36
|
# Guest volume support
|
35
37
|
# - Creates a new controller (AHCI by default)
|
@@ -38,40 +40,41 @@ class Beaker::VagrantVirtualbox < Beaker::Vagrant
|
|
38
40
|
# as 2:0:0:0, 3:0:0:0 ... much like you'd see on commercial storage boxes
|
39
41
|
if host['volumes']
|
40
42
|
controller = host['volume_storage_controller'].nil? ? 'IntelAHCI' : host['volume_storage_controller']
|
41
|
-
unless CONTROLLER_OPTIONS.keys.include? controller.to_sym
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
provider_section << self.vb_customize_vm('storagectl', [
|
48
|
-
'--name', "Beaker #{controller} Controller" ] + CONTROLLER_OPTIONS[controller.to_sym]
|
49
|
-
)
|
43
|
+
raise "Unknown controller type #{controller}" unless CONTROLLER_OPTIONS.keys.include? controller.to_sym
|
44
|
+
|
45
|
+
provider_section << vb_customize_vm('modifyvm', ['--usb', 'on']) if controller == 'USB'
|
46
|
+
provider_section << vb_customize_vm('storagectl', [
|
47
|
+
'--name', "Beaker #{controller} Controller"
|
48
|
+
] + CONTROLLER_OPTIONS[controller.to_sym])
|
50
49
|
host['volumes'].keys.each_with_index do |volume, index|
|
51
50
|
volume_path = "#{host.name}-#{volume}.vdi"
|
52
|
-
provider_section <<
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
provider_section <<
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
provider_section << vb_customize('createhd', [
|
52
|
+
'--filename', volume_path,
|
53
|
+
'--size', host['volumes'][volume]['size'],
|
54
|
+
])
|
55
|
+
provider_section << vb_customize_vm('storageattach', [
|
56
|
+
'--storagectl', "Beaker #{controller} Controller",
|
57
|
+
'--port', index,
|
58
|
+
'--device', 0,
|
59
|
+
'--type', 'hdd',
|
60
|
+
'--medium', volume_path,
|
61
|
+
])
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
provider_section << " vb.customize ['modifyvm', :id, '--ioapic', 'on']\n" unless host['ioapic'].nil?
|
67
66
|
|
68
|
-
|
67
|
+
unless host['natdns'].nil?
|
68
|
+
provider_section << " vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']\n"
|
69
|
+
end
|
69
70
|
|
70
71
|
provider_section << " vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']\n" unless host['natdns'].nil?
|
71
72
|
|
72
73
|
provider_section << " vb.gui = true\n" unless host['vb_gui'].nil?
|
73
74
|
|
74
|
-
|
75
|
+
if /osx/i.match(host['platform'])
|
76
|
+
provider_section << " vb.customize ['modifyvm', :id, '--cpuidset', '1','000206a7','02100800','1fbae3bf','bfebfbff']\n"
|
77
|
+
end
|
75
78
|
|
76
79
|
if host['disk_path']
|
77
80
|
unless File.exist?(host['disk_path'])
|
@@ -5,13 +5,17 @@ class Beaker::VagrantWorkstation < Beaker::Vagrant
|
|
5
5
|
super
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.provider_vfile_section(host, options)
|
8
|
+
def self.provider_vfile_section(host, options)
|
9
9
|
v_provider = " v.vm.provider :vmware_workstation do |v|\n"
|
10
10
|
v_provider << " v.vmx['gui'] = true\n" if host['gui'] == true
|
11
|
-
v_provider << " v.vmx['memsize'] = '#{memsize(host,options)}'\n"
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
v_provider << " v.vmx['memsize'] = '#{memsize(host, options)}'\n"
|
12
|
+
unless host['whitelist_verified'].nil?
|
13
|
+
v_provider << " v.vmx['whitelist_verified'] = '#{host['whitelist_verified']}'\n"
|
14
|
+
end
|
15
|
+
v_provider << " v.vmx['functional_hgfs'] = '#{host['functional_hgfs']}'\n" unless host['functional_hgfs'].nil?
|
16
|
+
unless host['unmount_default_hgfs'].nil?
|
17
|
+
v_provider << " v.vmx['unmount_default_hgfs'] = '#{host['unmount_default_hgfs']}'\n"
|
18
|
+
end
|
15
19
|
v_provider << " v.vmx['utility_port'] = '#{host['utility_port']}'\n" unless host['utility_port'].nil?
|
16
20
|
v_provider << " end\n"
|
17
21
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Beaker::VagrantCustom do
|
4
|
-
let(
|
5
|
-
let(
|
4
|
+
let(:options) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double.as_null_object }) }
|
5
|
+
let(:vagrant) { Beaker::VagrantCustom.new(@hosts, options) }
|
6
6
|
|
7
7
|
let(:test_dir) { 'tmp/tests' }
|
8
|
-
let(:custom_vagrant_file_path)
|
8
|
+
let(:custom_vagrant_file_path) { File.expand_path(test_dir + '/CustomVagrantfile') }
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@hosts = make_hosts
|
11
|
+
@hosts = make_hosts
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'uses the vagrant_custom provider for provisioning' do
|
15
15
|
@hosts.each do |host|
|
16
16
|
host_prev_name = host['user']
|
17
|
-
expect(
|
18
|
-
expect(
|
19
|
-
expect(
|
17
|
+
expect(vagrant).to receive(:set_ssh_config).with(host, 'vagrant').once
|
18
|
+
expect(vagrant).to receive(:copy_ssh_to_root).with(host, options).once
|
19
|
+
expect(vagrant).to receive(:set_ssh_config).with(host, host_prev_name).once
|
20
20
|
end
|
21
|
-
expect(
|
22
|
-
expect(
|
21
|
+
expect(vagrant).to receive(:hack_etc_hosts).with(@hosts, options).once
|
22
|
+
expect(vagrant).to receive(:vagrant_cmd).with('up').once
|
23
23
|
FakeFS do
|
24
24
|
vagrant.provision
|
25
25
|
end
|
@@ -27,14 +27,14 @@ describe Beaker::VagrantCustom do
|
|
27
27
|
|
28
28
|
context 'takes vagrant configuration from existing file' do
|
29
29
|
it 'writes the vagrant file to the correct location' do
|
30
|
-
options.merge!({ :
|
30
|
+
options.merge!({ vagrantfile_path: custom_vagrant_file_path })
|
31
31
|
|
32
32
|
create_files([custom_vagrant_file_path])
|
33
33
|
|
34
|
-
vagrant_file_contents =
|
35
|
-
FOO
|
34
|
+
vagrant_file_contents = <<~EOF
|
35
|
+
FOO
|
36
36
|
EOF
|
37
|
-
File.
|
37
|
+
File.write(custom_vagrant_file_path, vagrant_file_contents)
|
38
38
|
|
39
39
|
vagrant_copy_location = "#{test_dir}/NewVagrantLocation"
|
40
40
|
vagrant.instance_variable_set(:@vagrant_file, vagrant_copy_location)
|
@@ -42,6 +42,5 @@ FOO
|
|
42
42
|
vagrant_copy_file = File.open(vagrant_copy_location, 'r')
|
43
43
|
expect(vagrant_copy_file.read).to be === vagrant_file_contents
|
44
44
|
end
|
45
|
-
|
46
45
|
end
|
47
46
|
end
|