Sha256: 5b0bcff35712daca48c09b7842a8b94aa3ab3f89fc28cf5b60d3124c5361fb3d
Contents?: true
Size: 1.35 KB
Versions: 40
Compression:
Stored size: 1.35 KB
Contents
require 'fileutils' module Vagrant module Action module VM class Export attr_reader :temp_dir def initialize(app, env) @app = app @env = env end def call(env) @env = env raise Errors::VMPowerOffToPackage if @env["vm"].state != :poweroff setup_temp_dir export @app.call(env) recover(env) # called to cleanup temp directory end def recover(env) if temp_dir && File.exist?(temp_dir) FileUtils.rm_rf(temp_dir) end end def setup_temp_dir @env[:ui].info I18n.t("vagrant.actions.vm.export.create_dir") @temp_dir = @env["export.temp_dir"] = @env[:tmp_path].join(Time.now.to_i.to_s) FileUtils.mkpath(@env["export.temp_dir"]) end def export @env[:ui].info I18n.t("vagrant.actions.vm.export.exporting") @env[:vm].driver.export(ovf_path) do |progress| @env[:ui].clear_line @env[:ui].report_progress(progress.percent, 100, false) end # Clear the line a final time so the next data can appear # alone on the line. @env[:ui].clear_line end def ovf_path File.join(@env["export.temp_dir"], "box.ovf") end end end end end
Version data entries
40 entries across 40 versions & 6 rubygems