vagrant-ovirt4 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,11 +11,53 @@ RSpec.configure do |config|
11
11
  config.expect_with :rspec do |c|
12
12
  c.syntax = [:should, :expect]
13
13
  end
14
+
15
+ # When this setting is enabled, check that we saw calls to all available
16
+ # provider config readers and writers.
17
+ config.add_setting :check_provider_config_attr_accessor_calls
18
+ config.check_provider_config_attr_accessor_calls ||= ENV.key?('CI')
14
19
  end
15
20
 
16
21
  describe VagrantPlugins::OVirtProvider::Config do
17
22
  let(:instance) { described_class.new }
18
23
 
24
+ if RSpec.configuration.check_provider_config_attr_accessor_calls
25
+ before :all do
26
+ @writers ||= described_class.instance_methods.grep(/\w\=$/).sort - Vagrant.plugin('2', :config).instance_methods
27
+ @readers ||= @writers.map { |w| w.to_s.sub(/\=$/, '').to_sym }
28
+
29
+ @writer_calls ||= Hash.new { |h, w| h[w] = 0 }
30
+ @reader_calls ||= Hash.new { |h, r| h[r] = 0 }
31
+ end
32
+
33
+ before :each do
34
+ @writers.each do |writer|
35
+ ivar = :"@#{writer.to_s.sub(/\=$/, '')}"
36
+ allow(instance).to receive(writer) do |arg|
37
+ instance.instance_variable_set(ivar, arg)
38
+ @writer_calls[writer] += 1
39
+ arg
40
+ end
41
+ end
42
+
43
+ @readers.each do |reader|
44
+ ivar = :"@#{reader}"
45
+
46
+ allow(instance).to receive(reader) do
47
+ @reader_calls[reader] += 1
48
+ instance.instance_variable_get(ivar)
49
+ end
50
+ end
51
+ end
52
+
53
+ after :all do
54
+ missing_writers = @writers.select { |w| @writer_calls[w].zero? }
55
+ missing_readers = @readers.select { |w| @reader_calls[w].zero? }
56
+ all = missing_readers + missing_writers
57
+ fail "saw no tests of the following config methods: #{all.map(&:inspect).join(", ")}" unless all.empty?
58
+ end
59
+ end
60
+
19
61
  # Ensure tests are not affected by AWS credential environment variables
20
62
  before :each do
21
63
  ENV.stub(:[] => nil)
@@ -40,9 +82,9 @@ describe VagrantPlugins::OVirtProvider::Config do
40
82
  its("cluster") { should be_nil }
41
83
  its("console") { should be_nil }
42
84
  its("template") { should be_nil }
43
- its("memory_size") { should == 256000000 }
44
- its("memory_maximum") { should == 256000000 }
45
- its("memory_guaranteed") { should == 256000000 }
85
+ its("memory_size") { should == 268435456 }
86
+ its("memory_maximum") { should == 268435456 }
87
+ its("memory_guaranteed") { should == 268435456 }
46
88
  its("cloud_init") { should be_nil }
47
89
  its("affinity") { should be_nil }
48
90
  its("placement_host") { should be_nil }
@@ -50,11 +92,16 @@ describe VagrantPlugins::OVirtProvider::Config do
50
92
  its("optimized_for") { should be_nil }
51
93
  its("description") { should == '' }
52
94
  its("comment") { should == '' }
95
+ its("vmname") { should be_nil }
96
+ its("timeout") { should be_nil }
97
+ its("connect_timeout") { should be_nil }
98
+ its("disks") { should be_empty }
99
+ its("run_once") { should be false }
53
100
 
54
101
  end
55
102
 
56
103
  describe "overriding defaults" do
57
- [:url, :username, :password, :insecure, :debug, :filtered_api, :cpu_cores, :cpu_sockets, :cpu_threads, :cluster, :console, :template, :cloud_init, :placement_host, :bios_serial, :optimized_for, :description, :comment].each do |attribute|
104
+ [:url, :username, :password, :insecure, :debug, :filtered_api, :cpu_cores, :cpu_sockets, :cpu_threads, :cluster, :console, :template, :cloud_init, :placement_host, :bios_serial, :description, :comment, :vmname].each do |attribute|
58
105
 
59
106
  it "should not default #{attribute} if overridden" do
60
107
  instance.send("#{attribute}=".to_sym, "foo")
@@ -64,19 +111,40 @@ describe VagrantPlugins::OVirtProvider::Config do
64
111
  end
65
112
  end
66
113
 
114
+ describe "overriding optimized_for" do
115
+ [:optimized_for].each do |attribute|
116
+ OvirtSDK4::VmType.constants.each do |const|
117
+ value = const.to_s.downcase
118
+
119
+ it "should accept #{value} for #{attribute}" do
120
+ instance.send("#{attribute}=".to_sym, value)
121
+ instance.finalize!
122
+ instance.send(attribute).should == value
123
+ end
124
+ end
125
+
126
+ it "should reject a value for #{attribute} outside of the defined values" do
127
+ expect {
128
+ instance.send("#{attribute}=".to_sym, "foo")
129
+ instance.finalize!
130
+ }.to raise_error(RuntimeError)
131
+ end
132
+ end
133
+ end
134
+
67
135
  describe "overriding memory defaults" do
68
136
  [:memory_size, :memory_maximum, :memory_guaranteed].each do |attribute|
69
137
 
70
138
  it "should not default #{attribute} if overridden" do
71
139
  instance.send("#{attribute}=".to_sym, "512 MiB")
72
140
  instance.finalize!
73
- instance.send(attribute).should == 512000000
141
+ instance.send(attribute).should == 536870912
74
142
  end
75
143
 
76
144
  it "should convert the value" do
77
145
  instance.send("#{attribute}=".to_sym, "1 GiB")
78
146
  instance.finalize!
79
- instance.send(attribute).should == 1000000000
147
+ instance.send(attribute).should == 1073741824
80
148
  end
81
149
 
82
150
  end
@@ -84,26 +152,143 @@ describe VagrantPlugins::OVirtProvider::Config do
84
152
 
85
153
  describe "overriding affinity defaults" do
86
154
  [:affinity].each do |attribute|
155
+ OvirtSDK4::VmAffinity.constants.each do |const|
156
+ value = const.to_s.downcase
157
+
158
+ it "should accept #{value} for #{attribute}" do
159
+ instance.send("#{attribute}=".to_sym, value)
160
+ instance.finalize!
161
+ instance.send(attribute).should == value
162
+ end
163
+ end
164
+
165
+ it "should reject a value for #{attribute} outside of the defined values" do
166
+ expect {
167
+ instance.send("#{attribute}=".to_sym, "foo")
168
+ instance.finalize!
169
+ }.to raise_error(RuntimeError)
170
+ end
171
+ end
172
+
173
+ end
174
+
175
+ describe "overriding disk size defaults" do
176
+ ['10 GiB', '999 M', '101010101 KB'].each do |value|
177
+ it "should accept #{value.inspect} for disk size" do
178
+ instance.send("disk_size=".to_sym, value)
179
+ expect { instance.finalize! }.not_to raise_error
180
+ end
181
+ end
87
182
 
88
- context 'valid value' do
89
- it "should not default #{attribute} if overridden" do
90
- instance.send("#{attribute}=".to_sym, "pinned")
183
+ [-1, '10 Umm', Object.new].each do |value|
184
+ it "should reject #{value.inspect} for disk size" do
185
+ instance.send("disk_size=".to_sym, value)
186
+ expect { instance.finalize! }.to raise_error do |error|
187
+ expect(error).to be_a(RuntimeError)
188
+ expect(error.message).to match(/^Not able to parse '[^']+'\. Please verify and check again\.$/)
189
+ end
190
+ end
191
+ end
192
+
193
+ end
194
+
195
+ describe "overriding timeout defaults" do
196
+ [:timeout, :connect_timeout].each do |attribute|
197
+ [0, 6, 1_000_000, 8.10, nil].each do |value|
198
+ it "should accept #{value.to_s} for #{attribute}" do
199
+ instance.send("#{attribute}=".to_sym, value)
91
200
  instance.finalize!
92
- instance.send(attribute).should == "pinned"
201
+
202
+ if value.nil?
203
+ instance.send(attribute).should be_nil
204
+ else
205
+ instance.send(attribute).should == Integer(value)
206
+ end
93
207
  end
94
208
  end
95
209
 
96
- context 'invalid value' do
97
- it "should error" do
210
+ ["foo", Object.new, -100].each do |value|
211
+ it "should reject a value for #{attribute} outside of the defined values" do
98
212
  expect {
99
- instance.send("#{attribute}=".to_sym, "foo")
213
+ instance.send("#{attribute}=".to_sym, value)
100
214
  instance.finalize!
101
- }.to raise_error(RuntimeError)
102
-
215
+ }.to raise_error { |error|
216
+ expect(error).to be_a(RuntimeError)
217
+ expect(error.message).to match(/nonnegative integer/)
218
+ }
103
219
  end
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ describe "adding storage" do
226
+ let(:storage) { :file }
227
+ let(:storage_size) { '8 GiB' }
228
+ let(:storage_type) { 'qcow2' }
229
+ let(:storage_domain) { 'mystoragedomain' }
230
+
231
+ def configure_storage!
232
+ instance.storage(storage, size: storage_size, type: storage_type, storage_domain: storage_domain)
233
+ end
234
+
235
+ before do
236
+ expect(instance.disks).to be_empty
237
+ end
238
+
239
+ it "handles storage specifications" do
240
+ configure_storage!
241
+ instance.finalize!
242
+ expect(instance.disks).not_to be_empty
243
+ expect(instance.disks).to include(hash_including(
244
+ name: 'storage_disk_1',
245
+ type: storage_type,
246
+ bus: 'virtio',
247
+ storage_domain: storage_domain,
248
+ ))
249
+ end
104
250
 
251
+ context "given a type other than #{:file.inspect}" do
252
+ let(:storage) { :foobar }
253
+
254
+ it "ignores the storage specification" do
255
+ configure_storage!
256
+ instance.finalize!
257
+ expect(instance.disks).to be_empty
105
258
  end
259
+ end
106
260
 
261
+ context "given an invalid storage size" do
262
+ let(:storage_size) { 'Nope' }
263
+
264
+ it "raises an exception" do
265
+ expect { configure_storage! }.to raise_error(ArgumentError)
266
+ end
107
267
  end
268
+
108
269
  end
270
+
271
+ describe "overriding run_once defaults" do
272
+ context "given truthy values" do
273
+ [Object.new, {}, true, 1, 0].each do |value|
274
+ it "should convert #{value.inspect} to 'true'" do
275
+ instance.run_once = value
276
+ instance.finalize!
277
+ expect(instance.run_once).to be true
278
+ end
279
+ end
280
+ end
281
+
282
+ context "given falsey values" do
283
+ [false, nil].each do |value|
284
+ it "should convert #{value.inspect} to 'false'" do
285
+ instance.run_once = value
286
+ instance.finalize!
287
+ expect(instance.run_once).to be false
288
+ end
289
+ end
290
+ end
291
+
292
+ end
293
+
109
294
  end
@@ -0,0 +1,80 @@
1
+ require 'vagrant-ovirt4/util/connection'
2
+
3
+ describe VagrantPlugins::OVirtProvider::Util::Connection do
4
+ class MockConnection
5
+ def initialize(exception)
6
+ @closed = false
7
+ @exception = exception
8
+ end
9
+
10
+ def close
11
+ raise @exception if @closed
12
+ @closed = true
13
+ end
14
+ end
15
+
16
+ let(:error_class) { described_class::ERROR_CLASSES.first }
17
+ let(:exception) { error_class.new('already closed') }
18
+ let(:conn) { MockConnection.new(exception) }
19
+
20
+ describe '#safe_close_connection!' do
21
+ context 'when called on an open connection' do
22
+ it 'does not raise an error' do
23
+ expect { described_class.safe_close_connection!(conn) }.not_to raise_error
24
+ end
25
+ end
26
+
27
+ context 'when called on an already-closed connection' do
28
+ context 'and the error pertains to double-closing' do
29
+ it 'yields the error' do
30
+ expect { described_class.safe_close_connection!(conn) }.not_to raise_error
31
+ expect { |b| described_class.safe_close_connection!(conn, &b) }.to yield_with_args(exception)
32
+ end
33
+ end
34
+
35
+ context 'and the error does not pertain to double-close' do
36
+ let(:exception) { RuntimeError.new('sorry, no') }
37
+
38
+ it 'yields and then raises the error' do
39
+ expect { described_class.safe_close_connection!(conn) }.not_to raise_error
40
+ expect { |b| described_class.safe_close_connection!(conn, &b) }.to yield_with_args(exception).and raise_error(exception)
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ describe '#safe_connection_connection_standard!' do
47
+ let(:env) {
48
+ {
49
+ connection: conn,
50
+ ui: double('ui'),
51
+ }
52
+ }
53
+
54
+ context 'when called on an open connection' do
55
+ it 'does not raise an error' do
56
+ expect { described_class.safe_close_connection_standard!(env) }.not_to raise_error
57
+ end
58
+ end
59
+
60
+ context 'when called on an already-closed connection' do
61
+ context 'and the error pertains to double-closing' do
62
+ it 'logs a warning' do
63
+ expect { described_class.safe_close_connection_standard!(env) }.not_to raise_error
64
+ expect(env[:ui]).to receive(:warn).with(/^Encountered exception of class #{exception.class}: #{exception.message}/)
65
+ expect { described_class.safe_close_connection_standard!(env) }.not_to raise_error
66
+ end
67
+ end
68
+
69
+ context 'and the error does not pertain to double-close' do
70
+ let(:exception) { RuntimeError.new('sorry, no') }
71
+
72
+ it 'logs a warning and then raises the error' do
73
+ expect { described_class.safe_close_connection_standard!(env) }.not_to raise_error
74
+ expect(env[:ui]).to receive(:warn).with(/^Encountered exception of class #{exception.class}: #{exception.message}/)
75
+ expect { |b| described_class.safe_close_connection_standard!(env) }.to raise_error(exception)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = VagrantPlugins::OVirtProvider::VERSION
18
18
 
19
- gem.add_runtime_dependency 'ovirt-engine-sdk', '~> 4.0.1'
19
+ gem.add_runtime_dependency 'ovirt-engine-sdk', '~> 4'
20
20
  gem.add_runtime_dependency 'filesize', '~> 0'
21
- gem.add_runtime_dependency 'nokogiri', '>= 1.10.8'
21
+ gem.add_runtime_dependency 'nokogiri', '~> 1'
22
22
 
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ovirt4
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Young
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ovirt-engine-sdk
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.1
19
+ version: '4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.1
26
+ version: '4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: filesize
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.10.8
47
+ version: '1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.10.8
54
+ version: '1'
55
55
  description: Vagrant provider for oVirt and RHEV v4
56
56
  email:
57
57
  - myoung34@my.apsu.edu
@@ -60,15 +60,16 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".github/FUNDING.yml"
63
- - ".github/workflows/release.yml"
64
63
  - ".gitignore"
65
64
  - ".rspec"
65
+ - CHANGELOG
66
66
  - Dockerfile
67
67
  - Gemfile
68
68
  - Gemfile.lock
69
69
  - LICENSE
70
70
  - README.md
71
71
  - Rakefile
72
+ - SECURITY.md
72
73
  - example_box/README.md
73
74
  - example_box/Vagrantfile
74
75
  - example_box/dummy.box
@@ -110,10 +111,14 @@ files:
110
111
  - lib/vagrant-ovirt4/provider.rb
111
112
  - lib/vagrant-ovirt4/util.rb
112
113
  - lib/vagrant-ovirt4/util/collection.rb
114
+ - lib/vagrant-ovirt4/util/connection.rb
115
+ - lib/vagrant-ovirt4/util/machine_names.rb
113
116
  - lib/vagrant-ovirt4/util/timer.rb
114
117
  - lib/vagrant-ovirt4/version.rb
115
118
  - locales/en.yml
116
119
  - spec/spec_helper.rb
120
+ - spec/support/shared_context.rb
121
+ - spec/vagrant-ovirt4/action/create_vm_spec.rb
117
122
  - spec/vagrant-ovirt4/action/is_created_spec.rb
118
123
  - spec/vagrant-ovirt4/action/is_running_spec.rb
119
124
  - spec/vagrant-ovirt4/action/message_already_up_spec.rb
@@ -124,7 +129,9 @@ files:
124
129
  - spec/vagrant-ovirt4/action/message_saving_state_spec.rb
125
130
  - spec/vagrant-ovirt4/action/read_ssh_info_spec.rb
126
131
  - spec/vagrant-ovirt4/action/read_state_spec.rb
132
+ - spec/vagrant-ovirt4/action/start_vm_spec.rb
127
133
  - spec/vagrant-ovirt4/config_spec.rb
134
+ - spec/vagrant-ovirt4/util/connection_spec.rb
128
135
  - templates/Vagrantfile.erb
129
136
  - tools/prepare_redhat_for_box.sh
130
137
  - vagrant-ovirt4.gemspec
@@ -132,7 +139,7 @@ homepage: https://github.com/myoung34/vagrant-ovirt4
132
139
  licenses:
133
140
  - MIT
134
141
  metadata: {}
135
- post_install_message:
142
+ post_install_message:
136
143
  rdoc_options: []
137
144
  require_paths:
138
145
  - lib
@@ -147,13 +154,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
154
  - !ruby/object:Gem::Version
148
155
  version: '0'
149
156
  requirements: []
150
- rubygems_version: 3.0.3
151
- signing_key:
157
+ rubygems_version: 3.0.3.1
158
+ signing_key:
152
159
  specification_version: 4
153
160
  summary: This vagrant plugin provides the ability to create, control, and destroy
154
161
  virtual machines under oVirt/RHEV
155
162
  test_files:
156
163
  - spec/spec_helper.rb
164
+ - spec/support/shared_context.rb
165
+ - spec/vagrant-ovirt4/action/create_vm_spec.rb
157
166
  - spec/vagrant-ovirt4/action/is_created_spec.rb
158
167
  - spec/vagrant-ovirt4/action/is_running_spec.rb
159
168
  - spec/vagrant-ovirt4/action/message_already_up_spec.rb
@@ -164,4 +173,6 @@ test_files:
164
173
  - spec/vagrant-ovirt4/action/message_saving_state_spec.rb
165
174
  - spec/vagrant-ovirt4/action/read_ssh_info_spec.rb
166
175
  - spec/vagrant-ovirt4/action/read_state_spec.rb
176
+ - spec/vagrant-ovirt4/action/start_vm_spec.rb
167
177
  - spec/vagrant-ovirt4/config_spec.rb
178
+ - spec/vagrant-ovirt4/util/connection_spec.rb
@@ -1,20 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- paths:
6
- - lib/vagrant-ovirt4/version.rb
7
- branches:
8
- - master
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
- - uses: fregante/setup-git-user@v1
15
- - name: Release Gem
16
- uses: cadwallion/publish-rubygems-action@master
17
- env:
18
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19
- RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
20
- RELEASE_COMMAND: rake release