[DRE-commits] [vagrant-libvirt] 123/163: Multiple disks in different provider call fails.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:57:14 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.26
in repository vagrant-libvirt.
commit ea5d474e0d7c64af7aaaf18f8b926faa16b38f9d
Author: sathlan <chem at sathlan.org>
Date: Fri Feb 20 00:12:11 2015 -0500
Multiple disks in different provider call fails.
This
```ruby
Vagrant.configure("2") do |c|
c.vm.box = "centos-7.0"
c.vm.hostname = "default-centos-70.vagrantup.com"
c.vm.provider :libvirt do |p|
p.storage :file, :size => "5M", :path => "vagrant_vdb.qcow2", :device => "vdb"
p.storage :file, :size => "5M", :path => "vagrant_vdc.qcow2", :device => "vdc"
end
end
```
works.
But this fails:
```ruby
def add_block_device(node, port, size)
node.vm.provider 'libvirt' do |lv|
port_name = ('b'..'z').to_a[port-1]
lv.storage :file, :size => "#{size}M", :path => "vagrant_#{node.vm.hostname}_vd#{port_name}.qcow2", :device => "vd#{port_name}"
end
end
Vagrant.configure("2") do |c|
c.vm.box = "centos-7.0"
c.vm.hostname = "default-centos-70.vagrantup.com"
add_block_device(c, 1, 5)
add_block_device(c, 2, 5)
end
```
In the second case only the last disk is added:
```
==> default: -- Disks: vdc(qcow2,5M)
==> default: -- Disk(vdc): /var/lib/libvirt/images/vagrant_default-centos-70.vagrantup.com_vdc.qcow2
```
This patch corrects this. It is done as the `customize` configuration
is the vagrant code.
---
lib/vagrant-libvirt/config.rb | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index 12e049e..b03d019 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -107,11 +107,10 @@ module VagrantPlugins
@video_vram = UNSET_VALUE
# Storage
- @disks = UNSET_VALUE
+ @disks = []
end
def _get_device(disks)
- disks = [] if disks == UNSET_VALUE
# skip existing devices and also the first one (vda)
exist = disks.collect {|x| x[:device]}+[1.vdev.to_s]
skip = 1 # we're 1 based, not 0 based...
@@ -134,9 +133,6 @@ module VagrantPlugins
:bus => 'virtio'
}.merge(options)
- #puts "storage(#{storage_type} --- #{options.to_s})"
- @disks = [] if @disks == UNSET_VALUE
-
disk = {
:device => options[:device],
:type => options[:type],
@@ -237,9 +233,6 @@ module VagrantPlugins
@graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
@video_type = 'cirrus' if @video_type == UNSET_VALUE
@video_vram = 9216 if @video_vram == UNSET_VALUE
-
- # Storage
- @disks = [] if @disks == UNSET_VALUE
end
def validate(machine)
@@ -254,7 +247,13 @@ module VagrantPlugins
{ "Libvirt Provider" => errors }
end
+ def merge(other)
+ super.tap do |result|
+ c = disks.dup
+ c += other.disks
+ result.disks = c
+ end
+ end
end
end
end
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git
More information about the Pkg-ruby-extras-commits
mailing list