|
|
@@ -28,6 +28,10 @@ def call(env) |
|
|
@cmd_line = config.cmd_line
|
|
|
@initrd = config.initrd
|
|
|
|
|
|
+ # Storage
|
|
|
+ @storage_pool_name = config.storage_pool_name
|
|
|
+ @disks = config.disks
|
|
|
+
|
|
|
config = env[:machine].provider_config
|
|
|
@domain_type = config.driver
|
|
|
|
|
|
@@ -39,18 +43,52 @@ def call(env) |
|
|
raise Errors::DomainVolumeExists if domain_volume == nil
|
|
|
@domain_volume_path = domain_volume.path
|
|
|
|
|
|
+ #storage_prefix = '/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
|
|
|
+ if disk[:path].nil?
|
|
|
+ disk[:path] = "#{storage_prefix}#{dname}" # automatically chosen!
|
|
|
+ end
|
|
|
+ #puts "Disk: #{disk[:device]}, #{disk[:type]}, #{disk[:path]}"
|
|
|
+
|
|
|
+ # make the disk. equivalent to:
|
|
|
+ # qemu-img create -f qcow2 <path> 5g
|
|
|
+ begin
|
|
|
+ #puts "Making disk: #{d}, #{t}, #{p}"
|
|
|
+ domain_volume_disk = env[:libvirt_compute].volumes.create(
|
|
|
+ :name => disk[:name],
|
|
|
+ :format_type => disk[:type],
|
|
|
+ :path => disk[:path],
|
|
|
+ :capacity => disk[:size],
|
|
|
+ #:allocation => ?,
|
|
|
+ :pool_name => @storage_pool_name)
|
|
|
+ rescue Fog::Errors::Error => e
|
|
|
+ raise Errors::FogDomainVolumeCreateError,
|
|
|
+ :error_message => e.message
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
# Output the settings we're going to use to the user
|
|
|
env[:ui].info(I18n.t("vagrant_libvirt.creating_domain"))
|
|
|
env[:ui].info(" -- Name: #{@name}")
|
|
|
env[:ui].info(" -- Domain type: #{@domain_type}")
|
|
|
env[:ui].info(" -- Cpus: #{@cpus}")
|
|
|
env[:ui].info(" -- Memory: #{@memory_size/1024}M")
|
|
|
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
|
|
|
- env[:ui].info(" -- Storage pool: #{env[:machine].provider_config.storage_pool_name}")
|
|
|
+ env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
|
|
|
env[:ui].info(" -- Image: #{@domain_volume_path}")
|
|
|
env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
|
|
|
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(', ')}")
|
|
|
+ end
|
|
|
+ @disks.each do |disk|
|
|
|
+ env[:ui].info(" -- Disk(#{disk[:device]}): #{disk[:path]}")
|
|
|
+ end
|
|
|
env[:ui].info(" -- Command line : #{@cmd_line}")
|
|
|
|
|
|
# Create libvirt domain.
|
|
|
|
0 comments on commit
be20425