vagrant-libvirt 0.1.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +530 -100
  3. data/lib/vagrant-libvirt/action.rb +7 -1
  4. data/lib/vagrant-libvirt/action/clean_machine_folder.rb +28 -0
  5. data/lib/vagrant-libvirt/action/create_domain.rb +78 -22
  6. data/lib/vagrant-libvirt/action/create_domain_volume.rb +57 -57
  7. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -3
  8. data/lib/vagrant-libvirt/action/create_networks.rb +11 -4
  9. data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
  10. data/lib/vagrant-libvirt/action/forward_ports.rb +40 -40
  11. data/lib/vagrant-libvirt/action/halt_domain.rb +25 -9
  12. data/lib/vagrant-libvirt/action/handle_box_image.rb +163 -72
  13. data/lib/vagrant-libvirt/action/is_running.rb +1 -3
  14. data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
  15. data/lib/vagrant-libvirt/action/package_domain.rb +10 -4
  16. data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
  17. data/lib/vagrant-libvirt/action/wait_till_up.rb +8 -52
  18. data/lib/vagrant-libvirt/cap/{mount_p9.rb → mount_9p.rb} +2 -2
  19. data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +37 -0
  20. data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
  21. data/lib/vagrant-libvirt/cap/{synced_folder.rb → synced_folder_9p.rb} +4 -5
  22. data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +109 -0
  23. data/lib/vagrant-libvirt/config.rb +257 -34
  24. data/lib/vagrant-libvirt/driver.rb +49 -32
  25. data/lib/vagrant-libvirt/errors.rb +24 -1
  26. data/lib/vagrant-libvirt/plugin.rb +19 -5
  27. data/lib/vagrant-libvirt/provider.rb +2 -9
  28. data/lib/vagrant-libvirt/templates/domain.xml.erb +40 -10
  29. data/lib/vagrant-libvirt/templates/private_network.xml.erb +1 -1
  30. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
  31. data/lib/vagrant-libvirt/util.rb +1 -0
  32. data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
  33. data/lib/vagrant-libvirt/util/network_util.rb +21 -3
  34. data/lib/vagrant-libvirt/util/ui.rb +23 -0
  35. data/lib/vagrant-libvirt/version +1 -0
  36. data/lib/vagrant-libvirt/version.rb +72 -1
  37. data/locales/en.yml +12 -0
  38. data/spec/spec_helper.rb +37 -3
  39. data/spec/support/binding_proc.rb +24 -0
  40. data/spec/support/libvirt_context.rb +3 -1
  41. data/spec/support/matchers/have_file_content.rb +63 -0
  42. data/spec/support/sharedcontext.rb +7 -3
  43. data/spec/unit/action/clean_machine_folder_spec.rb +48 -0
  44. data/spec/unit/action/create_domain_spec.rb +166 -0
  45. data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
  46. data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
  47. data/spec/unit/action/create_domain_volume_spec.rb +102 -0
  48. data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +21 -0
  49. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +21 -0
  50. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +21 -0
  51. data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +21 -0
  52. data/spec/unit/action/destroy_domain_spec.rb +3 -3
  53. data/spec/unit/action/forward_ports_spec.rb +202 -0
  54. data/spec/unit/action/halt_domain_spec.rb +90 -0
  55. data/spec/unit/action/handle_box_image_spec.rb +363 -0
  56. data/spec/unit/action/set_name_of_domain_spec.rb +2 -2
  57. data/spec/unit/action/start_domain_spec.rb +231 -0
  58. data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
  59. data/spec/unit/action/start_domain_spec/default.xml +48 -0
  60. data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
  61. data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
  62. data/spec/unit/action/wait_till_up_spec.rb +22 -21
  63. data/spec/unit/config_spec.rb +438 -0
  64. data/spec/unit/provider_spec.rb +11 -0
  65. data/spec/unit/templates/domain_all_settings.xml +16 -3
  66. data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
  67. data/spec/unit/templates/domain_defaults.xml +4 -1
  68. data/spec/unit/templates/domain_spec.rb +102 -3
  69. data/spec/unit/templates/tpm/version_1.2.xml +54 -0
  70. data/spec/unit/templates/tpm/version_2.0.xml +53 -0
  71. metadata +108 -16
  72. data/lib/vagrant-libvirt/action/halt_confirm.rb +0 -20
@@ -10,12 +10,12 @@ describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
10
10
  dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
11
11
  first = dmn.build_domain_name(@env)
12
12
  second = dmn.build_domain_name(@env)
13
- first.should_not eq(second)
13
+ expect(first).to_not eq(second)
14
14
  end
15
15
 
16
16
  it 'builds simple domain name' do
17
17
  @env.default_prefix = 'pre_'
18
18
  dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
19
- dmn.build_domain_name(@env).should eq('pre_')
19
+ expect(dmn.build_domain_name(@env)).to eq('pre_')
20
20
  end
21
21
  end
@@ -0,0 +1,231 @@
1
+ require 'spec_helper'
2
+ require 'support/sharedcontext'
3
+ require 'support/libvirt_context'
4
+
5
+ require 'vagrant-libvirt/errors'
6
+ require 'vagrant-libvirt/action/start_domain'
7
+
8
+ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
9
+ subject { described_class.new(app, env) }
10
+
11
+ include_context 'unit'
12
+ include_context 'libvirt'
13
+
14
+ let(:libvirt_domain) { double('libvirt_domain') }
15
+ let(:libvirt_client) { double('libvirt_client') }
16
+ let(:servers) { double('servers') }
17
+
18
+ let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), test_file)) }
19
+ let(:updated_domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), updated_test_file)) }
20
+
21
+ describe '#call' do
22
+ before do
23
+ allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
24
+ .to receive(:connection).and_return(connection)
25
+ allow(connection).to receive(:client).and_return(libvirt_client)
26
+ allow(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
27
+
28
+ allow(connection).to receive(:servers).and_return(servers)
29
+ allow(servers).to receive(:get).and_return(domain)
30
+
31
+ expect(logger).to receive(:info)
32
+ expect(ui).to_not receive(:error)
33
+ end
34
+
35
+ context 'default config' do
36
+ let(:test_file) { 'default.xml' }
37
+
38
+ before do
39
+ allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
40
+
41
+ allow(libvirt_domain).to receive(:max_memory).and_return(512*1024)
42
+ allow(libvirt_domain).to receive(:num_vcpus).and_return(1)
43
+ end
44
+
45
+ it 'should execute without changing' do
46
+ allow(libvirt_domain).to receive(:undefine)
47
+ expect(logger).to_not receive(:debug)
48
+ expect(libvirt_domain).to receive(:autostart=)
49
+ expect(domain).to receive(:start)
50
+
51
+ expect(subject.call(env)).to be_nil
52
+ end
53
+ end
54
+
55
+ context 'tpm' do
56
+ let(:test_file) { 'default.xml' }
57
+
58
+ before do
59
+ allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
60
+
61
+ allow(libvirt_domain).to receive(:max_memory).and_return(512*1024)
62
+ allow(libvirt_domain).to receive(:num_vcpus).and_return(1)
63
+ end
64
+
65
+ context 'passthrough tpm added' do
66
+ let(:updated_test_file) { 'default_added_tpm_path.xml' }
67
+ let(:vagrantfile_providerconfig) do
68
+ <<-EOF
69
+ libvirt.tpm_path = '/dev/tpm0'
70
+ libvirt.tpm_type = 'passthrough'
71
+ libvirt.tpm_model = 'tpm-tis'
72
+ EOF
73
+ end
74
+
75
+ it 'should modify the domain tpm_path' do
76
+ expect(libvirt_domain).to receive(:undefine)
77
+ expect(logger).to receive(:debug).with('tpm config changed')
78
+ expect(servers).to receive(:create).with(xml: updated_domain_xml)
79
+ expect(libvirt_domain).to receive(:autostart=)
80
+ expect(domain).to receive(:start)
81
+
82
+ expect(subject.call(env)).to be_nil
83
+ end
84
+ end
85
+
86
+ context 'emulated tpm added' do
87
+ let(:updated_test_file) { 'default_added_tpm_version.xml' }
88
+ let(:vagrantfile_providerconfig) do
89
+ <<-EOF
90
+ libvirt.tpm_type = 'emulator'
91
+ libvirt.tpm_model = 'tpm-crb'
92
+ libvirt.tpm_version = '2.0'
93
+ EOF
94
+ end
95
+
96
+ it 'should modify the domain tpm_path' do
97
+ expect(libvirt_domain).to receive(:undefine)
98
+ expect(logger).to receive(:debug).with('tpm config changed')
99
+ expect(servers).to receive(:create).with(xml: updated_domain_xml)
100
+ expect(libvirt_domain).to receive(:autostart=)
101
+ expect(domain).to receive(:start)
102
+
103
+ expect(subject.call(env)).to be_nil
104
+ end
105
+ end
106
+
107
+ context 'same passthrough tpm config' do
108
+ let(:test_file) { 'default_added_tpm_path.xml' }
109
+ let(:updated_test_file) { 'default_added_tpm_path.xml' }
110
+ let(:vagrantfile_providerconfig) do
111
+ <<-EOF
112
+ libvirt.tpm_path = '/dev/tpm0'
113
+ libvirt.tpm_type = 'passthrough'
114
+ libvirt.tpm_model = 'tpm-tis'
115
+ EOF
116
+ end
117
+
118
+ it 'should execute without changing' do
119
+ expect(logger).to_not receive(:debug)
120
+ expect(libvirt_domain).to receive(:autostart=)
121
+ expect(domain).to receive(:start)
122
+
123
+ expect(subject.call(env)).to be_nil
124
+ end
125
+ end
126
+
127
+ context 'same emulated tpm config' do
128
+ let(:test_file) { 'default_added_tpm_version.xml' }
129
+ let(:updated_test_file) { 'default_added_tpm_version.xml' }
130
+ let(:vagrantfile_providerconfig) do
131
+ <<-EOF
132
+ libvirt.tpm_type = 'emulator'
133
+ libvirt.tpm_model = 'tpm-crb'
134
+ libvirt.tpm_version = '2.0'
135
+ EOF
136
+ end
137
+
138
+ it 'should execute without changing' do
139
+ expect(logger).to_not receive(:debug)
140
+ expect(libvirt_domain).to receive(:autostart=)
141
+ expect(domain).to receive(:start)
142
+
143
+ expect(subject.call(env)).to be_nil
144
+ end
145
+ end
146
+
147
+ context 'change from passthrough to emulated' do
148
+ let(:test_file) { 'default_added_tpm_path.xml' }
149
+ let(:updated_test_file) { 'default_added_tpm_version.xml' }
150
+ let(:vagrantfile_providerconfig) do
151
+ <<-EOF
152
+ libvirt.tpm_type = 'emulator'
153
+ libvirt.tpm_model = 'tpm-crb'
154
+ libvirt.tpm_version = '2.0'
155
+ EOF
156
+ end
157
+
158
+ it 'should modify the domain' do
159
+ expect(libvirt_domain).to receive(:undefine)
160
+ expect(logger).to receive(:debug).with('tpm config changed')
161
+ expect(servers).to receive(:create).with(xml: updated_domain_xml)
162
+ expect(libvirt_domain).to receive(:autostart=)
163
+ expect(domain).to receive(:start)
164
+
165
+ expect(subject.call(env)).to be_nil
166
+ end
167
+ end
168
+ end
169
+
170
+ context 'clock_timers' do
171
+ let(:test_file) { 'clock_timer_rtc.xml' }
172
+
173
+ before do
174
+ allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
175
+
176
+ allow(libvirt_domain).to receive(:max_memory).and_return(512*1024)
177
+ allow(libvirt_domain).to receive(:num_vcpus).and_return(1)
178
+ end
179
+
180
+ context 'timers unchanged' do
181
+ let(:vagrantfile_providerconfig) do
182
+ <<-EOF
183
+ libvirt.clock_timer(:name => "rtc")
184
+ EOF
185
+ end
186
+
187
+ it 'should not modify the domain' do
188
+ expect(logger).to_not receive(:debug).with('clock timers config changed')
189
+ expect(servers).to_not receive(:create)
190
+ expect(libvirt_domain).to receive(:autostart=)
191
+ expect(domain).to receive(:start)
192
+
193
+ expect(subject.call(env)).to be_nil
194
+ end
195
+ end
196
+
197
+ context 'timers added' do
198
+ let(:vagrantfile_providerconfig) do
199
+ <<-EOF
200
+ libvirt.clock_timer(:name => "rtc")
201
+ libvirt.clock_timer(:name => "tsc")
202
+ EOF
203
+ end
204
+
205
+ it 'should modify the domain' do
206
+ expect(libvirt_domain).to receive(:undefine)
207
+ expect(logger).to receive(:debug).with('clock timers config changed')
208
+ expect(servers).to receive(:create).with(xml: match(/<clock offset='utc'>\s*<timer name='rtc'\/>\s*<timer name='tsc'\/>\s*<\/clock>/))
209
+ expect(libvirt_domain).to receive(:autostart=)
210
+ expect(domain).to receive(:start)
211
+
212
+ expect(subject.call(env)).to be_nil
213
+ end
214
+ end
215
+
216
+ context 'timers removed' do
217
+ let(:updated_test_file) { 'default.xml' }
218
+
219
+ it 'should modify the domain' do
220
+ expect(libvirt_domain).to receive(:undefine)
221
+ expect(logger).to receive(:debug).with('clock timers config changed')
222
+ expect(servers).to receive(:create).with(xml: match(/<clock offset='utc'>\s*<\/clock>/))
223
+ expect(libvirt_domain).to receive(:autostart=)
224
+ expect(domain).to receive(:start)
225
+
226
+ expect(subject.call(env)).to be_nil
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
@@ -0,0 +1,50 @@
1
+ <domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
2
+ <name/>
3
+ <title/>
4
+ <description/>
5
+ <uuid/>
6
+ <memory/>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'/>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel/>
18
+ <initrd/>
19
+ <cmdline/>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'>
27
+ <timer name='rtc'/>
28
+ </clock>
29
+ <devices>
30
+
31
+
32
+ <serial type='pty'>
33
+ <target port='0'/>
34
+ </serial>
35
+ <console type='pty'>
36
+ <target port='0'/>
37
+ </console>
38
+
39
+
40
+ <input bus='ps2' type='mouse'/>
41
+
42
+ <graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
43
+ <video>
44
+ <model heads='1' type='cirrus' vram='9216'/>
45
+ </video>
46
+
47
+
48
+ </devices>
49
+
50
+ </domain>
@@ -0,0 +1,48 @@
1
+ <domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
2
+ <name/>
3
+ <title/>
4
+ <description/>
5
+ <uuid/>
6
+ <memory/>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'/>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel/>
18
+ <initrd/>
19
+ <cmdline/>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'/>
27
+ <devices>
28
+
29
+
30
+ <serial type='pty'>
31
+ <target port='0'/>
32
+ </serial>
33
+ <console type='pty'>
34
+ <target port='0'/>
35
+ </console>
36
+
37
+
38
+ <input bus='ps2' type='mouse'/>
39
+
40
+ <graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
41
+ <video>
42
+ <model heads='1' type='cirrus' vram='9216'/>
43
+ </video>
44
+
45
+
46
+ </devices>
47
+
48
+ </domain>
@@ -0,0 +1,48 @@
1
+ <domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
2
+ <name/>
3
+ <title/>
4
+ <description/>
5
+ <uuid/>
6
+ <memory/>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'/>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel/>
18
+ <initrd/>
19
+ <cmdline/>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'/>
27
+ <devices>
28
+
29
+
30
+ <serial type='pty'>
31
+ <target port='0'/>
32
+ </serial>
33
+ <console type='pty'>
34
+ <target port='0'/>
35
+ </console>
36
+
37
+
38
+ <input bus='ps2' type='mouse'/>
39
+
40
+ <graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
41
+ <video>
42
+ <model heads='1' type='cirrus' vram='9216'/>
43
+ </video>
44
+
45
+
46
+ <tpm model='tpm-tis'><backend type='passthrough'><device path='/dev/tpm0'/></backend></tpm></devices>
47
+
48
+ </domain>
@@ -0,0 +1,48 @@
1
+ <domain xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' type=''>
2
+ <name/>
3
+ <title/>
4
+ <description/>
5
+ <uuid/>
6
+ <memory/>
7
+ <vcpu>1</vcpu>
8
+
9
+
10
+ <cpu mode='host-model'>
11
+ <model fallback='allow'/>
12
+ </cpu>
13
+
14
+
15
+ <os>
16
+ <type>hvm</type>
17
+ <kernel/>
18
+ <initrd/>
19
+ <cmdline/>
20
+ </os>
21
+ <features>
22
+ <acpi/>
23
+ <apic/>
24
+ <pae/>
25
+ </features>
26
+ <clock offset='utc'/>
27
+ <devices>
28
+
29
+
30
+ <serial type='pty'>
31
+ <target port='0'/>
32
+ </serial>
33
+ <console type='pty'>
34
+ <target port='0'/>
35
+ </console>
36
+
37
+
38
+ <input bus='ps2' type='mouse'/>
39
+
40
+ <graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
41
+ <video>
42
+ <model heads='1' type='cirrus' vram='9216'/>
43
+ </video>
44
+
45
+
46
+ <tpm model='tpm-crb'><backend type='emulator' version='2.0'/></tpm></devices>
47
+
48
+ </domain>
@@ -12,18 +12,19 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
12
12
  include_context 'libvirt'
13
13
  include_context 'unit'
14
14
 
15
+ let (:driver) { VagrantPlugins::ProviderLibvirt::Driver.new env[:machine] }
16
+
15
17
  describe '#call' do
16
18
  before do
17
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
18
- .to receive(:get_domain).and_return(domain)
19
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
20
- .and_return(:running)
19
+ allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Provider).to receive(:driver)
20
+ .and_return(driver)
21
+ allow(driver).to receive(:get_domain).and_return(domain)
22
+ allow(driver).to receive(:state).and_return(:running)
21
23
  end
22
24
 
23
25
  context 'when machine does not exist' do
24
26
  before do
25
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
26
- .to receive(:get_domain).and_return(nil)
27
+ allow(driver).to receive(:get_domain).and_return(nil)
27
28
  end
28
29
 
29
30
  it 'raises exception' do
@@ -41,43 +42,43 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
41
42
  it 'should exit' do
42
43
  expect(app).to_not receive(:call)
43
44
  expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
45
+ expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
44
46
  expect(subject.call(env)).to be_nil
45
47
  end
46
48
  end
47
49
 
48
- context 'if interrupted waiting for SSH' do
50
+ context 'multiple timeouts waiting for IP' do
49
51
  before do
50
- allow(domain).to receive(:wait_for).and_return(true)
51
52
  allow(env).to receive(:[]).and_call_original
52
- allow(env).to receive(:[]).with(:interrupted).and_return(false, true, true)
53
- allow(env).to receive(:[]).with(:ip_address).and_return('192.168.121.2')
53
+ allow(env).to receive(:[]).with(:interrupted).and_return(false)
54
+ allow(logger).to receive(:debug)
55
+ allow(logger).to receive(:info)
54
56
  end
55
- it 'should exit after getting IP' do
57
+
58
+ it 'should abort after hitting limit' do
59
+ expect(domain).to receive(:wait_for).at_least(300).times.and_raise(::Fog::Errors::TimeoutError)
56
60
  expect(app).to_not receive(:call)
57
61
  expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
58
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
59
- logger = subject.instance_variable_get(:@logger)
60
- expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
61
- expect(logger).to receive(:info).with('Got IP address 192.168.121.2')
62
- expect(logger).to receive(:info).with(/Time for getting IP: .*/)
62
+ expect(ui).to_not receive(:info).with('Waiting for SSH to become available...')
63
63
  expect(env[:machine].communicate).to_not receive(:ready?)
64
- expect(subject.call(env)).to be_nil
64
+ expect {subject.call(env) }.to raise_error(::Fog::Errors::TimeoutError)
65
65
  end
66
66
  end
67
67
  end
68
68
 
69
- context 'when machine boots and ssh available' do
69
+ context 'when machine boots and ip available' do
70
70
  before do
71
71
  allow(domain).to receive(:wait_for).and_return(true)
72
72
  allow(env).to receive(:[]).and_call_original
73
73
  allow(env).to receive(:[]).with(:interrupted).and_return(false)
74
- allow(env).to receive(:[]).with(:ip_address).and_return('192.168.121.2')
74
+ allow(driver).to receive(:get_domain_ipaddress).and_return('192.168.121.2')
75
75
  end
76
76
  it 'should call the next hook' do
77
77
  expect(app).to receive(:call)
78
78
  expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
79
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
80
- expect(env[:machine].communicate).to receive(:ready?).and_return(true)
79
+ expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
80
+ expect(logger).to receive(:info).with('Got IP address 192.168.121.2')
81
+ expect(logger).to receive(:info).with(/Time for getting IP: .*/)
81
82
  expect(subject.call(env)).to be_nil
82
83
  end
83
84
  end