Sha256: 691f6773b3d1ee117ba22c90e88db14c435690e43a49bfc7f20b15e66602e50c

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

module Vagrant
  class Action
    module VM
      class Import
        def initialize(app, env)
          @app = app
        end

        def call(env)
          env.ui.info I18n.t("vagrant.actions.vm.import.importing", :name => env.env.box.name)

          # Import the virtual machine
          env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress|
            env.ui.clear_line
            env.ui.report_progress(progress.percent, 100, false)
          end

          # Clear the line one last time since the progress meter doesn't disappear
          # immediately.
          env.ui.clear_line

          # Flag as erroneous and return if import failed
          raise Errors::VMImportFailure if !env["vm"].vm

          # Import completed successfully. Continue the chain
          @app.call(env)
        end

        def recover(env)
          if env["vm"].created?
            return if env["vagrant.error"].is_a?(Errors::VagrantError)

            # Interrupted, destroy the VM
            env["actions"].run(:destroy)
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
vagrantup-0.8.9 lib/vagrant/action/vm/import.rb
vagrantup-0.8.8 lib/vagrant/action/vm/import.rb
vagrantup-0.8.7 lib/vagrant/action/vm/import.rb
vagrantup-0.8.6 lib/vagrant/action/vm/import.rb
vagrantup-0.8.5 lib/vagrant/action/vm/import.rb
vagrantup-0.8.4 lib/vagrant/action/vm/import.rb
vagrantup-0.8.3 lib/vagrant/action/vm/import.rb
vagrantup-0.8.10 lib/vagrant/action/vm/import.rb
vagrant-0.8.10 lib/vagrant/action/vm/import.rb
vagrant-0.8.8 lib/vagrant/action/vm/import.rb
vagrant-0.8.7 lib/vagrant/action/vm/import.rb
rvagrant-0.8.7.dev lib/vagrant/action/vm/import.rb
vagrant-0.8.6 lib/vagrant/action/vm/import.rb
vagrant-0.8.5 lib/vagrant/action/vm/import.rb