Sha256: 49d2a61e0a644d3ef6ef4cc686f50c3c75f2cd78a18545c189342d5f92a6db96
Contents?: true
Size: 1.95 KB
Versions: 4
Compression:
Stored size: 1.95 KB
Contents
require 'log4r' require 'vagrant/util/scoped_hash_override' module VagrantPlugins module OVirtProvider module Action # Resize the disk if necessary, before VM is running. class ResizeDisk include Vagrant::Util::ScopedHashOverride def initialize(app, env) @logger = Log4r::Logger.new("vagrant_ovirt::action::resize_disk") @app = app end def call(env) # Is it necessary to resize the disk? config = env[:machine].provider_config connect_timeout = config.connect_timeout if config.disk_size.nil? # Nothing to do @app.call(env) return end # Get machine first. begin machine = OVirtProvider::Util::Collection.find_matching( env[:ovirt_compute].servers.all, env[:machine].id.to_s) rescue => e raise Errors::NoVMError, :vm_name => env[:machine].id.to_s end # Extend disk size if necessary begin machine.update_volume( :id => machine.volumes.first.id, :size => config.disk_size*1024*1024*1024, ) rescue => e raise Errors::UpdateVolumeError, :error_message => e.message end # Wait till all volumes are ready. env[:ui].info(I18n.t("vagrant_ovirt3.wait_for_ready_volume")) for i in 0..connect_timeout ready = true machine = env[:ovirt_compute].servers.get(env[:machine].id.to_s) machine.volumes.each do |volume| if volume.status != 'ok' ready = false break end end break if ready sleep 2 end if not ready raise Errors::WaitForReadyResizedVolumeTimeout end @app.call(env) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems