vagrant-libvirt 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/lib/vagrant-libvirt/action.rb +1 -1
- data/lib/vagrant-libvirt/driver.rb +3 -1
- data/lib/vagrant-libvirt/plugin.rb +1 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/spec/support/binding_proc.rb +24 -0
- data/spec/unit/action/wait_till_up_spec.rb +19 -1
- data/spec/unit/config_spec.rb +8 -8
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cce5cc2c14c33a541cb2c0a446dd76692685131abbff67992976e736cd0f04e
|
4
|
+
data.tar.gz: 4abe7566cc6269cb8c9fa4cac79cdfe6a1d5919e7305ffec1a214e937853c4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb5a19c0aa21eccd856d8056270669d201ceec6f3f6cfb209ec7e6185bfcca0a25fd1b60556bef4ea92ed261b6069c17011c2c0083999c146065dc216656beb
|
7
|
+
data.tar.gz: c3ffc56e5e8d680f87541be65a9990fd77a0e8235c070a413eb5d44d63f7cb1b5bbc712ea6c8b5fb8fe45ef85d72a967e31f241ea0461a9b943f7cd79eb6151b
|
data/README.md
CHANGED
@@ -1788,11 +1788,25 @@ $ bundle exec rspec spec/
|
|
1788
1788
|
If those pass, you're ready to start developing the plugin. You can test the
|
1789
1789
|
plugin without installing it into your Vagrant environment by just creating a
|
1790
1790
|
`Vagrantfile` in the top level of this directory (it is gitignored) that uses
|
1791
|
-
it.
|
1792
|
-
|
1791
|
+
it. You can add the following line to your Vagrantfile while in development to
|
1792
|
+
ensure vagrant checks that the plugin is installed:
|
1793
1793
|
|
1794
1794
|
```ruby
|
1795
|
-
Vagrant.
|
1795
|
+
Vagrant.configure("2") do |config|
|
1796
|
+
config.vagrant.plugins = "vagrant-libvirt"
|
1797
|
+
end
|
1798
|
+
```
|
1799
|
+
Or add the following to the top of the file to ensure that any required plugins
|
1800
|
+
are installed globally:
|
1801
|
+
```ruby
|
1802
|
+
REQUIRED_PLUGINS = %w(vagrant-libvirt)
|
1803
|
+
exit unless REQUIRED_PLUGINS.all? do |plugin|
|
1804
|
+
Vagrant.has_plugin?(plugin) || (
|
1805
|
+
puts "The #{plugin} plugin is required. Please install it with:"
|
1806
|
+
puts "$ vagrant plugin install #{plugin}"
|
1807
|
+
false
|
1808
|
+
)
|
1809
|
+
end
|
1796
1810
|
```
|
1797
1811
|
|
1798
1812
|
Now you can use bundler to execute Vagrant:
|
@@ -186,11 +186,11 @@ module VagrantPlugins
|
|
186
186
|
|
187
187
|
b2.use Call, DestroyConfirm do |env2, b3|
|
188
188
|
if env2[:result]
|
189
|
+
b3.use ProvisionerCleanup, :before
|
189
190
|
b3.use ClearForwardedPorts
|
190
191
|
b3.use PruneNFSExports
|
191
192
|
b3.use DestroyDomain
|
192
193
|
b3.use DestroyNetworks
|
193
|
-
b3.use ProvisionerCleanup
|
194
194
|
else
|
195
195
|
b3.use MessageWillNotDestroy
|
196
196
|
end
|
@@ -97,11 +97,13 @@ module VagrantPlugins
|
|
97
97
|
return get_ipaddress_from_system domain.mac
|
98
98
|
end
|
99
99
|
|
100
|
-
# Get IP address from
|
100
|
+
# Get IP address from dhcp leases table
|
101
101
|
begin
|
102
102
|
ip_address = get_ipaddress_from_domain(domain)
|
103
103
|
rescue Fog::Errors::TimeoutError
|
104
104
|
@logger.info('Timeout at waiting for an ip address for machine %s' % machine.name)
|
105
|
+
|
106
|
+
raise
|
105
107
|
end
|
106
108
|
|
107
109
|
unless ip_address
|
data/lib/vagrant-libvirt/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
@@ -0,0 +1,24 @@
|
|
1
|
+
##
|
2
|
+
# A simple extension of the Proc class that supports setting a custom binding
|
3
|
+
# and evaluates everything in the Proc using the new binding.
|
4
|
+
|
5
|
+
class ProcWithBinding < Proc
|
6
|
+
##
|
7
|
+
# Set the binding for this instance
|
8
|
+
|
9
|
+
def apply_binding(bind, *args)
|
10
|
+
@binding = bind
|
11
|
+
instance_exec(*args, &self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(method, *args)
|
15
|
+
begin
|
16
|
+
method_from_binding = eval("method(#{method.inspect})", @binding)
|
17
|
+
return method_from_binding.call(*args)
|
18
|
+
rescue NameError
|
19
|
+
# fall through on purpose
|
20
|
+
end
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
@@ -12,7 +12,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
12
12
|
include_context 'libvirt'
|
13
13
|
include_context 'unit'
|
14
14
|
|
15
|
-
let (:driver) {
|
15
|
+
let (:driver) { VagrantPlugins::ProviderLibvirt::Driver.new env[:machine] }
|
16
16
|
|
17
17
|
describe '#call' do
|
18
18
|
before do
|
@@ -47,6 +47,24 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
context 'multiple timeouts waiting for IP' do
|
51
|
+
before do
|
52
|
+
allow(env).to receive(:[]).and_call_original
|
53
|
+
allow(env).to receive(:[]).with(:interrupted).and_return(false)
|
54
|
+
allow(logger).to receive(:debug)
|
55
|
+
allow(logger).to receive(:info)
|
56
|
+
end
|
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)
|
60
|
+
expect(app).to_not receive(:call)
|
61
|
+
expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
|
62
|
+
expect(ui).to_not receive(:info).with('Waiting for SSH to become available...')
|
63
|
+
expect(env[:machine].communicate).to_not receive(:ready?)
|
64
|
+
expect {subject.call(env) }.to raise_error(::Fog::Errors::TimeoutError)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
50
68
|
context 'if interrupted waiting for SSH' do
|
51
69
|
before do
|
52
70
|
allow(domain).to receive(:wait_for).and_return(true)
|
data/spec/unit/config_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'support/binding_proc'
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'support/sharedcontext'
|
@@ -103,7 +103,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
103
103
|
:id_ssh_key_file => nil,
|
104
104
|
},
|
105
105
|
{
|
106
|
-
:setup =>
|
106
|
+
:setup => ProcWithBinding.new {
|
107
107
|
expect(File).to_not receive(:file?)
|
108
108
|
}
|
109
109
|
}
|
@@ -116,7 +116,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
116
116
|
:id_ssh_key_file => "/home/tests/.ssh/id_rsa",
|
117
117
|
},
|
118
118
|
{
|
119
|
-
:setup =>
|
119
|
+
:setup => ProcWithBinding.new {
|
120
120
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(true)
|
121
121
|
}
|
122
122
|
}
|
@@ -263,7 +263,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
263
263
|
{:connect_via_ssh => true},
|
264
264
|
{:uri => 'qemu+ssh://localhost/system?no_verify=1', :id_ssh_key_file => nil},
|
265
265
|
{
|
266
|
-
:setup =>
|
266
|
+
:setup => ProcWithBinding.new {
|
267
267
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(false)
|
268
268
|
}
|
269
269
|
}
|
@@ -272,7 +272,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
272
272
|
{:connect_via_ssh => true},
|
273
273
|
{:uri => 'qemu+ssh://localhost/system?no_verify=1&keyfile=/home/tests/.ssh/id_rsa', :id_ssh_key_file => '/home/tests/.ssh/id_rsa'},
|
274
274
|
{
|
275
|
-
:setup =>
|
275
|
+
:setup => ProcWithBinding.new {
|
276
276
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(true)
|
277
277
|
}
|
278
278
|
}
|
@@ -294,7 +294,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
294
294
|
end
|
295
295
|
|
296
296
|
if !opts[:setup].nil?
|
297
|
-
opts[:setup].
|
297
|
+
opts[:setup].apply_binding(binding)
|
298
298
|
end
|
299
299
|
|
300
300
|
inputs.each do |k, v|
|
@@ -362,7 +362,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
362
362
|
{:connect_via_ssh => true, :host => 'remote', :username => 'myuser'},
|
363
363
|
"ssh 'remote' -l 'myuser' -i '/home/tests/.ssh/id_rsa' -W %h:%p",
|
364
364
|
{
|
365
|
-
:setup =>
|
365
|
+
:setup => ProcWithBinding.new {
|
366
366
|
expect(File).to receive(:file?).with("/home/tests/.ssh/id_rsa").and_return(true)
|
367
367
|
}
|
368
368
|
}
|
@@ -417,7 +417,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
417
417
|
end
|
418
418
|
|
419
419
|
if !opts[:setup].nil?
|
420
|
-
opts[:setup].
|
420
|
+
opts[:setup].apply_binding(binding)
|
421
421
|
end
|
422
422
|
|
423
423
|
inputs.each do |k, v|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
@@ -10,22 +10,8 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-03
|
13
|
+
date: 2021-04-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: contextual_proc
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - ">="
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '0'
|
29
15
|
- !ruby/object:Gem::Dependency
|
30
16
|
name: rspec-core
|
31
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,6 +209,7 @@ files:
|
|
223
209
|
- lib/vagrant-libvirt/version.rb
|
224
210
|
- locales/en.yml
|
225
211
|
- spec/spec_helper.rb
|
212
|
+
- spec/support/binding_proc.rb
|
226
213
|
- spec/support/environment_helper.rb
|
227
214
|
- spec/support/libvirt_context.rb
|
228
215
|
- spec/support/sharedcontext.rb
|
@@ -291,5 +278,6 @@ test_files:
|
|
291
278
|
- spec/unit/templates/domain_custom_cpu_model.xml
|
292
279
|
- spec/support/libvirt_context.rb
|
293
280
|
- spec/support/environment_helper.rb
|
281
|
+
- spec/support/binding_proc.rb
|
294
282
|
- spec/support/sharedcontext.rb
|
295
283
|
- spec/spec_helper.rb
|