[DRE-commits] [vagrant-libvirt] 55/77: Include changes recommended by patch review for multiple disks.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:56:38 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.17
in repository vagrant-libvirt.
commit 72fbedaaca00302b433a2cbb25983b036f9a9619
Author: James Shubin <james at shubin.ca>
Date: Tue May 6 10:35:02 2014 -0400
Include changes recommended by patch review for multiple disks.
---
lib/vagrant-libvirt/action/create_domain.rb | 18 ++++++++++++------
lib/vagrant-libvirt/config.rb | 6 +++---
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 4096c12..ad46ff0 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -12,6 +12,14 @@ module VagrantPlugins
@app = app
end
+ def _disk_name(name, disk)
+ return "#{name}-#{disk[:device]}.#{disk[:type]}" # disk name
+ end
+
+ def _disks_print(disks)
+ return disks.collect{ |x| x[:device]+'('+x[:type]+','+x[:size]+')' }.join(', ')
+ end
+
def call(env)
# Get config.
config = env[:machine].provider_config
@@ -43,16 +51,14 @@ module VagrantPlugins
raise Errors::DomainVolumeExists if domain_volume == nil
@domain_volume_path = domain_volume.path
- #storage_prefix = '/var/lib/libvirt/images/'
+ # the default storage prefix is typically: /var/lib/libvirt/images/
storage_prefix = File.dirname(@domain_volume_path)+'/' # steal
@disks.each do |disk|
- dname = "#{@name}-#{disk[:device]}.#{disk[:type]}" # disk name
- disk[:name] = dname
+ disk[:name] = _disk_name(@name, disk)
if disk[:path].nil?
- disk[:path] = "#{storage_prefix}#{dname}" # automatically chosen!
+ disk[:path] = "#{storage_prefix}#{_disk_name(@name, disk)}" # automatically chosen!
end
- #puts "Disk: #{disk[:device]}, #{disk[:type]}, #{disk[:path]}"
# make the disk. equivalent to:
# qemu-img create -f qcow2 <path> 5g
@@ -84,7 +90,7 @@ module VagrantPlugins
env[:ui].info(" -- Kernel: #{@kernel}")
env[:ui].info(" -- Initrd: #{@initrd}")
if @disks.length > 0
- env[:ui].info(" -- Disks: #{@disks.collect{ |x| x[:device]+'('+x[:type]+','+x[:size]+')' }.join(', ')}")
+ env[:ui].info(" -- Disks: #{_disks_print(@disks)}")
end
@disks.each do |disk|
env[:ui].info(" -- Disk(#{disk[:device]}): #{disk[:path]}")
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index eba8899..3a6aec4 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -84,14 +84,14 @@ module VagrantPlugins
@disks = UNSET_VALUE
end
- def __get_device(disks)
+ 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...
while true do
dev = skip.vdev # get lettered device
- if not exist.include?(dev)
+ if !exist.include?(dev)
return dev
end
skip+=1
@@ -101,7 +101,7 @@ module VagrantPlugins
# NOTE: this will run twice for each time it's needed- keep it idempotent
def storage(storage_type, options={})
options = {
- :device => __get_device(@disks),
+ :device => _get_device(@disks),
:type => 'qcow2',
:size => '10G', # matches the fog default
:path => nil,
--
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