From cea8c5dafd13c651799bb6c7afd0fcb5ff768c8a Mon Sep 17 00:00:00 2001 From: John Barney Date: Sat, 9 Feb 2013 19:42:04 -0800 Subject: [PATCH] Whitespace issue fixed --- plugins/providers/virtualbox/action/import.rb | 2 +- .../providers/virtualbox/action/import.rb~ | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 plugins/providers/virtualbox/action/import.rb~ diff --git a/plugins/providers/virtualbox/action/import.rb b/plugins/providers/virtualbox/action/import.rb index e4b155914..cd614575c 100644 --- a/plugins/providers/virtualbox/action/import.rb +++ b/plugins/providers/virtualbox/action/import.rb @@ -15,7 +15,7 @@ module VagrantPlugins if Vagrant::Util::Platform.cygwin? ovf_file = `cygpath -w #{ovf_file}`.chomp end - env[:machine].id = env[:machine].provider.driver.import(ovf_file) do |progress| + env[:machine].id = env[:machine].provider.driver.import(ovf_file) do |progress| env[:ui].clear_line env[:ui].report_progress(progress, 100, false) end diff --git a/plugins/providers/virtualbox/action/import.rb~ b/plugins/providers/virtualbox/action/import.rb~ new file mode 100644 index 000000000..e4b155914 --- /dev/null +++ b/plugins/providers/virtualbox/action/import.rb~ @@ -0,0 +1,54 @@ +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 + if Vagrant::Util::Platform.cygwin? + ovf_file = `cygpath -w #{ovf_file}`.chomp + end + 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