vagrant-libvirt 0.5.3 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +110 -18
  3. data/lib/vagrant-libvirt/action/clean_machine_folder.rb +2 -0
  4. data/lib/vagrant-libvirt/action/create_domain.rb +8 -1
  5. data/lib/vagrant-libvirt/action/create_domain_volume.rb +5 -0
  6. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +8 -2
  7. data/lib/vagrant-libvirt/action/create_networks.rb +12 -8
  8. data/lib/vagrant-libvirt/action/destroy_domain.rb +2 -0
  9. data/lib/vagrant-libvirt/action/destroy_networks.rb +2 -0
  10. data/lib/vagrant-libvirt/action/forward_ports.rb +7 -5
  11. data/lib/vagrant-libvirt/action/halt_domain.rb +4 -34
  12. data/lib/vagrant-libvirt/action/handle_box_image.rb +22 -13
  13. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +7 -1
  14. data/lib/vagrant-libvirt/action/is_created.rb +2 -0
  15. data/lib/vagrant-libvirt/action/is_running.rb +2 -0
  16. data/lib/vagrant-libvirt/action/is_suspended.rb +2 -0
  17. data/lib/vagrant-libvirt/action/message_already_created.rb +2 -0
  18. data/lib/vagrant-libvirt/action/message_not_created.rb +2 -0
  19. data/lib/vagrant-libvirt/action/message_not_running.rb +2 -0
  20. data/lib/vagrant-libvirt/action/message_not_suspended.rb +2 -0
  21. data/lib/vagrant-libvirt/action/message_will_not_destroy.rb +2 -0
  22. data/lib/vagrant-libvirt/action/package_domain.rb +133 -68
  23. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +2 -0
  24. data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +2 -0
  25. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +2 -0
  26. data/lib/vagrant-libvirt/action/read_mac_addresses.rb +2 -0
  27. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -0
  28. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +2 -0
  29. data/lib/vagrant-libvirt/action/resume_domain.rb +2 -0
  30. data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -0
  31. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +3 -1
  32. data/lib/vagrant-libvirt/action/share_folders.rb +2 -0
  33. data/lib/vagrant-libvirt/action/shutdown_domain.rb +71 -0
  34. data/lib/vagrant-libvirt/action/start_domain.rb +26 -17
  35. data/lib/vagrant-libvirt/action/suspend_domain.rb +2 -0
  36. data/lib/vagrant-libvirt/action/wait_till_up.rb +2 -0
  37. data/lib/vagrant-libvirt/action.rb +37 -12
  38. data/lib/vagrant-libvirt/cap/mount_9p.rb +2 -0
  39. data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +2 -0
  40. data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +2 -0
  41. data/lib/vagrant-libvirt/cap/public_address.rb +2 -0
  42. data/lib/vagrant-libvirt/cap/synced_folder_9p.rb +5 -2
  43. data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +5 -2
  44. data/lib/vagrant-libvirt/config.rb +49 -25
  45. data/lib/vagrant-libvirt/driver.rb +67 -12
  46. data/lib/vagrant-libvirt/errors.rb +6 -0
  47. data/lib/vagrant-libvirt/plugin.rb +2 -0
  48. data/lib/vagrant-libvirt/provider.rb +2 -0
  49. data/lib/vagrant-libvirt/templates/domain.xml.erb +4 -2
  50. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +1 -0
  51. data/lib/vagrant-libvirt/util/collection.rb +2 -0
  52. data/lib/vagrant-libvirt/util/erb_template.rb +2 -0
  53. data/lib/vagrant-libvirt/util/error_codes.rb +2 -0
  54. data/lib/vagrant-libvirt/util/network_util.rb +3 -0
  55. data/lib/vagrant-libvirt/util/nfs.rb +2 -0
  56. data/lib/vagrant-libvirt/util/storage_util.rb +1 -0
  57. data/lib/vagrant-libvirt/util/timer.rb +2 -0
  58. data/lib/vagrant-libvirt/util/ui.rb +1 -0
  59. data/lib/vagrant-libvirt/util.rb +2 -0
  60. data/lib/vagrant-libvirt/version +1 -1
  61. data/lib/vagrant-libvirt/version.rb +2 -0
  62. data/lib/vagrant-libvirt.rb +2 -0
  63. data/locales/en.yml +7 -0
  64. data/spec/spec_helper.rb +2 -0
  65. data/spec/support/binding_proc.rb +2 -0
  66. data/spec/support/environment_helper.rb +2 -0
  67. data/spec/support/libvirt_context.rb +2 -0
  68. data/spec/support/matchers/have_file_content.rb +2 -0
  69. data/spec/support/sharedcontext.rb +3 -0
  70. data/spec/support/temporary_dir.rb +12 -0
  71. data/spec/unit/action/clean_machine_folder_spec.rb +2 -0
  72. data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +7 -0
  73. data/spec/unit/action/create_domain_spec/default_domain.xml +6 -0
  74. data/spec/unit/action/create_domain_spec.rb +62 -30
  75. data/spec/unit/action/create_domain_volume_spec.rb +4 -0
  76. data/spec/unit/action/destroy_domain_spec.rb +8 -2
  77. data/spec/unit/action/forward_ports_spec.rb +2 -0
  78. data/spec/unit/action/halt_domain_spec.rb +30 -57
  79. data/spec/unit/action/handle_box_image_spec.rb +36 -4
  80. data/spec/unit/action/package_domain_spec.rb +304 -0
  81. data/spec/unit/action/set_name_of_domain_spec.rb +2 -0
  82. data/spec/unit/action/shutdown_domain_spec.rb +160 -0
  83. data/spec/unit/action/start_domain_spec/existing.xml +62 -0
  84. data/spec/unit/action/start_domain_spec.rb +18 -28
  85. data/spec/unit/action/wait_till_up_spec.rb +2 -0
  86. data/spec/unit/action_spec.rb +174 -0
  87. data/spec/unit/config_spec.rb +52 -2
  88. data/spec/unit/driver_spec.rb +155 -0
  89. data/spec/unit/templates/domain_all_settings.xml +4 -0
  90. data/spec/unit/templates/domain_spec.rb +2 -0
  91. data/spec/unit/util/byte_number_spec.rb +2 -0
  92. metadata +54 -42
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'support/sharedcontext'
3
5
  require 'support/libvirt_context'
4
6
 
5
7
  require 'vagrant-libvirt/errors'
8
+ require 'vagrant-libvirt/util/byte_number'
6
9
  require 'vagrant-libvirt/action/create_domain'
7
10
 
8
11
  describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
@@ -14,6 +17,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
14
17
  let(:libvirt_client) { double('libvirt_client') }
15
18
  let(:servers) { double('servers') }
16
19
  let(:volumes) { double('volumes') }
20
+ let(:domain_volume) { double('domain_volume') }
17
21
 
18
22
  let(:domain_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), domain_xml_file)) }
19
23
  let(:storage_pool_xml) { File.read(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb'), storage_pool_xml_file)) }
@@ -27,8 +31,15 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
27
31
 
28
32
  allow(connection).to receive(:servers).and_return(servers)
29
33
  allow(connection).to receive(:volumes).and_return(volumes)
34
+ allow(volumes).to receive(:all).and_return([domain_volume])
35
+ allow(domain_volume).to receive(:pool_name).and_return('default')
36
+ allow(domain_volume).to receive(:[]).with('name').and_return('vagrant-test_default.img')
37
+ allow(domain_volume).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default.img')
38
+ allow(machine).to receive_message_chain("box.name") { 'vagrant-libvirt/test' }
30
39
 
31
40
  allow(logger).to receive(:info)
41
+ allow(logger).to receive(:debug)
42
+ allow(ui).to receive(:info)
32
43
 
33
44
  env[:domain_name] = "vagrant-test_default"
34
45
 
@@ -36,7 +47,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
36
47
  env[:box_volumes].push({
37
48
  :path=>"/test/box.img",
38
49
  :name=>"test_vagrant_box_image_1.1.1_0.img",
39
- :virtual_size=>5
50
+ :virtual_size=> ByteNumber.new(5),
40
51
  })
41
52
  # should be ignored for system session and used for user session
42
53
  allow(Process).to receive(:uid).and_return(9999)
@@ -44,35 +55,44 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
44
55
  end
45
56
 
46
57
  context 'connection => qemu:///system' do
47
- context 'default pool' do
48
- let(:domain_xml_file) { 'default_domain.xml' }
49
- let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
58
+ let(:domain_xml_file) { 'default_domain.xml' }
50
59
 
60
+ context 'default pool' do
51
61
  it 'should execute correctly' do
52
- expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
53
- expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
54
62
  expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
55
63
  expect(volumes).to_not receive(:create) # additional disks only
56
64
 
57
65
  expect(subject.call(env)).to be_nil
58
66
  end
59
67
 
60
- context 'additional disks' do
68
+ context 'with no box' do
69
+ let(:storage_pool_xml_file) { 'default_system_storage_pool.xml' }
61
70
  let(:vagrantfile) do
62
71
  <<-EOF
63
72
  Vagrant.configure('2') do |config|
64
73
  config.vm.define :test
65
- config.vm.provider :libvirt do |libvirt|
66
- libvirt.storage :file, :size => '20G'
67
- end
68
74
  end
69
75
  EOF
70
76
  end
71
77
 
78
+ it 'should query for the storage pool path' do
79
+ expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
80
+ expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
81
+ expect(servers).to receive(:create).and_return(machine)
82
+
83
+ expect(subject.call(env)).to be_nil
84
+ end
85
+ end
86
+
87
+ context 'additional disks' do
88
+ let(:vagrantfile_providerconfig) do
89
+ <<-EOF
90
+ libvirt.storage :file, :size => '20G'
91
+ EOF
92
+ end
93
+
72
94
  context 'volume create failed' do
73
95
  it 'should raise an exception' do
74
- expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
75
- expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
76
96
  expect(volumes).to receive(:create).and_raise(Libvirt::Error)
77
97
 
78
98
  expect{ subject.call(env) }.to raise_error(VagrantPlugins::ProviderLibvirt::Errors::FogCreateDomainVolumeError)
@@ -83,8 +103,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
83
103
  let(:domain_xml_file) { 'additional_disks_domain.xml' }
84
104
 
85
105
  it 'should complete' do
86
- expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
87
- expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
88
106
  expect(volumes).to receive(:create).with(
89
107
  hash_including(
90
108
  :path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
@@ -102,6 +120,14 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
102
120
  end
103
121
 
104
122
  context 'no default pool' do
123
+ let(:vagrantfile) do
124
+ <<-EOF
125
+ Vagrant.configure('2') do |config|
126
+ config.vm.define :test
127
+ end
128
+ EOF
129
+ end
130
+
105
131
  it 'should raise an exception' do
106
132
  expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(nil)
107
133
 
@@ -111,45 +137,51 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
111
137
  end
112
138
 
113
139
  context 'connection => qemu:///session' do
114
- let(:vagrantfile) do
140
+ let(:vagrantfile_providerconfig) do
115
141
  <<-EOF
116
- Vagrant.configure('2') do |config|
117
- config.vm.define :test
118
- config.vm.provider :libvirt do |libvirt|
119
- libvirt.qemu_use_session = true
120
- end
121
- end
142
+ libvirt.qemu_use_session = true
122
143
  EOF
123
144
  end
124
145
 
125
146
  context 'default pool' do
126
- let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
127
-
128
147
  it 'should execute correctly' do
129
- expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
130
- expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
131
148
  expect(servers).to receive(:create).and_return(machine)
132
149
 
133
150
  expect(subject.call(env)).to be_nil
134
151
  end
135
152
 
136
- context 'additional disks' do
153
+ context 'with no box' do
154
+ let(:storage_pool_xml_file) { 'default_user_storage_pool.xml' }
137
155
  let(:vagrantfile) do
138
156
  <<-EOF
139
157
  Vagrant.configure('2') do |config|
140
158
  config.vm.define :test
141
159
  config.vm.provider :libvirt do |libvirt|
142
- libvirt.qemu_use_session = true
143
- libvirt.storage :file, :size => '20G'
160
+ #{vagrantfile_providerconfig}
144
161
  end
145
162
  end
146
163
  EOF
147
164
  end
148
165
 
166
+ it 'should query for the storage pool path' do
167
+ expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
168
+ expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
169
+ expect(servers).to receive(:create).and_return(machine)
170
+
171
+ expect(subject.call(env)).to be_nil
172
+ end
173
+ end
174
+
175
+ context 'additional disks' do
176
+ let(:vagrantfile_providerconfig) do
177
+ <<-EOF
178
+ libvirt.qemu_use_session = true
179
+ libvirt.storage :file, :size => '20G'
180
+ EOF
181
+ end
182
+
149
183
  context 'volume create succeeded' do
150
184
  it 'should complete' do
151
- expect(libvirt_client).to receive(:lookup_storage_pool_by_name).and_return(libvirt_storage_pool)
152
- expect(libvirt_storage_pool).to receive(:xml_desc).and_return(storage_pool_xml)
153
185
  expect(volumes).to receive(:create).with(
154
186
  hash_including(
155
187
  :path => "/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2",
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'support/sharedcontext'
3
5
  require 'support/libvirt_context'
@@ -32,6 +34,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomainVolume do
32
34
  allow(all).to receive(:first).and_return(box_volume)
33
35
  allow(box_volume).to receive(:id).and_return(nil)
34
36
  env[:domain_name] = 'test'
37
+
38
+ allow(logger).to receive(:debug)
35
39
  end
36
40
 
37
41
  context 'when one disk' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'support/sharedcontext'
3
5
  require 'support/libvirt_context'
@@ -10,14 +12,18 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
10
12
  include_context 'unit'
11
13
  include_context 'libvirt'
12
14
 
15
+ let(:driver) { double('driver') }
13
16
  let(:libvirt_domain) { double('libvirt_domain') }
14
17
  let(:libvirt_client) { double('libvirt_client') }
15
18
  let(:servers) { double('servers') }
16
19
 
20
+ before do
21
+ allow(machine.provider).to receive('driver').and_return(driver)
22
+ allow(driver).to receive(:connection).and_return(connection)
23
+ end
24
+
17
25
  describe '#call' do
18
26
  before do
19
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
20
- .to receive(:connection).and_return(connection)
21
27
  allow(connection).to receive(:client).and_return(libvirt_client)
22
28
  allow(libvirt_client).to receive(:lookup_domain_by_uuid)
23
29
  .and_return(libvirt_domain)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'support/sharedcontext'
3
5
  require 'support/libvirt_context'
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'support/sharedcontext'
3
5
  require 'support/libvirt_context'
4
- require 'vagrant-libvirt/action/destroy_domain'
6
+ require 'vagrant-libvirt/action/halt_domain'
5
7
 
6
8
  describe VagrantPlugins::ProviderLibvirt::Action::HaltDomain do
7
9
  subject { described_class.new(app, env) }
@@ -9,81 +11,52 @@ describe VagrantPlugins::ProviderLibvirt::Action::HaltDomain do
9
11
  include_context 'unit'
10
12
  include_context 'libvirt'
11
13
 
14
+ let(:driver) { double('driver') }
12
15
  let(:libvirt_domain) { double('libvirt_domain') }
13
16
  let(:servers) { double('servers') }
14
17
 
18
+ before do
19
+ allow(machine.provider).to receive('driver').and_return(driver)
20
+ allow(driver).to receive(:created?).and_return(true)
21
+ allow(driver).to receive(:connection).and_return(connection)
22
+ end
23
+
15
24
  describe '#call' do
16
25
  before do
17
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
18
- .to receive(:connection).and_return(connection)
19
26
  allow(connection).to receive(:servers).and_return(servers)
20
27
  allow(servers).to receive(:get).and_return(domain)
21
- # always see this at the start of #call
22
- expect(ui).to receive(:info).with('Halting domain...')
28
+ allow(ui).to receive(:info).with('Halting domain...')
23
29
  end
24
30
 
25
- context 'with graceful timeout' do
26
- it "should shutdown" do
27
- expect(guest).to receive(:capability).with(:halt).and_return(true)
28
- expect(domain).to receive(:wait_for).with(60).and_return(false)
29
- expect(subject.call(env)).to be_nil
30
- end
31
-
32
- context 'when halt fails' do
33
- before do
34
- expect(logger).to receive(:info).with('Trying Libvirt graceful shutdown.')
35
- expect(guest).to receive(:capability).with(:halt).and_raise(IOError)
36
- expect(domain).to receive(:state).and_return('running')
37
- end
31
+ context "when state is not running" do
32
+ before { expect(driver).to receive(:state).at_least(1).
33
+ and_return(:not_created) }
38
34
 
39
- it "should call shutdown" do
40
- expect(domain).to receive(:shutdown)
41
- expect(domain).to receive(:wait_for).with(60).and_return(false)
42
- expect(subject.call(env)).to be_nil
43
- end
44
-
45
- context 'when shutdown fails' do
46
- it "should call power off" do
47
- expect(logger).to receive(:error).with('Failed to shutdown cleanly. Calling force poweroff.')
48
- expect(domain).to receive(:shutdown).and_raise(IOError)
49
- expect(domain).to receive(:poweroff)
50
- expect(subject.call(env)).to be_nil
51
- end
52
- end
53
-
54
- context 'when shutdown exceeds the timeout' do
55
- it "should call poweroff" do
56
- expect(logger).to receive(:info).with('VM is still running. Calling force poweroff.')
57
- expect(domain).to receive(:shutdown).and_raise(Timeout::Error)
58
- expect(domain).to receive(:poweroff)
59
- expect(subject.call(env)).to be_nil
60
- end
61
- end
35
+ it "should not poweroff when state is not running" do
36
+ expect(domain).not_to receive(:poweroff)
37
+ subject.call(env)
62
38
  end
63
39
 
64
- context 'when halt exceeds the timeout' do
65
- before do
66
- expect(logger).to_not receive(:info).with('Trying Libvirt graceful shutdown.')
67
- expect(guest).to receive(:capability).with(:halt).and_raise(Timeout::Error)
68
- end
69
-
70
- it "should call poweroff" do
71
- expect(logger).to receive(:info).with('VM is still running. Calling force poweroff.')
72
- expect(domain).to receive(:poweroff)
73
- expect(subject.call(env)).to be_nil
74
- end
40
+ it "should not print halting message" do
41
+ expect(ui).not_to receive(:info)
42
+ subject.call(env)
75
43
  end
76
44
  end
77
45
 
78
- context 'with force halt enabled' do
46
+ context "when state is running" do
79
47
  before do
80
- allow(env).to receive(:[]).and_call_original
81
- expect(env).to receive(:[]).with(:force_halt).and_return(true)
48
+ expect(driver).to receive(:state).and_return(:running)
82
49
  end
83
50
 
84
- it "should just call poweroff" do
51
+ it "should poweroff" do
85
52
  expect(domain).to receive(:poweroff)
86
- expect(subject.call(env)).to be_nil
53
+ subject.call(env)
54
+ end
55
+
56
+ it "should print halting message" do
57
+ allow(domain).to receive(:poweroff)
58
+ expect(ui).to receive(:info).with('Halting domain...')
59
+ subject.call(env)
87
60
  end
88
61
  end
89
62
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'json'
3
5
  require 'support/sharedcontext'
@@ -77,7 +79,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
77
79
  ]
78
80
  }
79
81
  allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
80
- '/test/'.concat(arg.to_s)
82
+ '/test/' + arg.to_s
81
83
  end
82
84
  end
83
85
 
@@ -96,6 +98,36 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
96
98
  )
97
99
  end
98
100
 
101
+ context 'when no box version set' do
102
+ let(:box_mtime) { Time.now }
103
+
104
+ before do
105
+ expect(env[:machine]).to receive_message_chain("box.version") { nil }
106
+ expect(File).to receive(:mtime).and_return(box_mtime)
107
+ end
108
+
109
+ it 'should use the box file timestamp' do
110
+ expect(ui).to receive(:warn).with(
111
+ "No verison detected for test, using timestamp to watch for modifications. Consider\n" +
112
+ "generating a local metadata for the box with a version to allow better handling.\n" +
113
+ 'See https://www.vagrantup.com/docs/boxes/format#box-metadata for further details.'
114
+ )
115
+
116
+ expect(subject.call(env)).to be_nil
117
+ expect(env[:box_volume_number]).to eq(1)
118
+ expect(env[:box_volumes]).to eq(
119
+ [
120
+ {
121
+ :path=>"/test/box.img",
122
+ :name=>"test_vagrant_box_image_0_#{box_mtime.to_i}_box.img",
123
+ :virtual_size=>byte_number_5G,
124
+ :format=>"qcow2"
125
+ }
126
+ ]
127
+ )
128
+ end
129
+ end
130
+
99
131
  context 'When config.machine_virtual_size is set and smaller than box_virtual_size' do
100
132
  before do
101
133
  allow(env[:machine]).to receive_message_chain("provider_config.machine_virtual_size").and_return(1)
@@ -197,7 +229,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
197
229
  ],
198
230
  ]}
199
231
  allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
200
- '/test/'.concat(arg.to_s)
232
+ '/test/' + arg.to_s
201
233
  end
202
234
  allow(status).to receive(:success?).and_return(true)
203
235
  allow(Open3).to receive(:capture3).with('qemu-img', 'info', '--output=json', '/test/box.img').and_return([
@@ -334,7 +366,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
334
366
  ]
335
367
  }
336
368
  allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
337
- '/test/'.concat(arg.to_s)
369
+ '/test/' + arg.to_s
338
370
  end
339
371
  end
340
372
 
@@ -354,7 +386,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
354
386
  allow(env[:machine]).to receive_message_chain("box.version") { '1.1.1' }
355
387
  allow(env[:machine]).to receive_message_chain("box.metadata") { box_metadata }
356
388
  allow(env[:machine]).to receive_message_chain("box.directory.join") do |arg|
357
- '/test/'.concat(arg.to_s)
389
+ '/test/' + arg.to_s
358
390
  end
359
391
  allow(status).to receive(:success?).and_return(true)
360
392
  allow(Open3).to receive(:capture3).with('qemu-img', 'info', "--output=json", '/test/box.img').and_return([