Sha256: 2ff4993a783570a22410cd8ab5d22d3753d8dd4577c36b41ea839b593eb45770

Contents?: true

Size: 1.73 KB

Versions: 13

Compression:

Stored size: 1.73 KB

Contents

module VagrantPlugins
  module ProviderVirtualBox
    module Action
      class Import
        def initialize(app, env)
          @app = app
        end

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

          # Import the virtual machine
          ovf_file = env[:machine].box.directory.join("box.ovf").to_s
          env[:machine].id = env[:machine].provider.driver.import(ovf_file) do |progress|
            env[:ui].clear_line
            env[:ui].report_progress(progress, 100, false)
          end

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

          # If we got interrupted, then the import could have been
          # interrupted and its not a big deal. Just return out.
          return if env[:interrupted]

          # Flag as erroneous and return if import failed
          raise Vagrant::Errors::VMImportFailure if !env[:machine].id

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

        def recover(env)
          if env[:machine].provider.state.id != :not_created
            return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)

            # Interrupted, destroy the VM. We note that we don't want to
            # validate the configuration here, and we don't want to confirm
            # we want to destroy.
            destroy_env = env.clone
            destroy_env[:config_validate] = false
            destroy_env[:force_confirm_destroy] = true
            env[:action_runner].run(Action.action_destroy, destroy_env)
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 5 rubygems

Version Path
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/import.rb
tnargav-1.2.3 plugins/providers/virtualbox/action/import.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/import.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/import.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/import.rb
tnargav-1.2.2 plugins/providers/virtualbox/action/import.rb
vagrantup-1.1.3 plugins/providers/virtualbox/action/import.rb
vagrantup-1.1.2 plugins/providers/virtualbox/action/import.rb
vagrantup-1.1.1 plugins/providers/virtualbox/action/import.rb
vagrantup-1.1.0 plugins/providers/virtualbox/action/import.rb
vagrantup-1.1.4 plugins/providers/virtualbox/action/import.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/providers/virtualbox/action/import.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/providers/virtualbox/action/import.rb