Class: VagrantPlugins::Utm::Action::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_utm/action/export.rb

Overview

This action exports the virtual machine.

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ Export

Returns a new instance of Export.



8
9
10
# File 'lib/vagrant_utm/action/export.rb', line 8

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Raises:

  • (Vagrant::Errors::VMPowerOffToPackage)


12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant_utm/action/export.rb', line 12

def call(env)
  @env = env

  raise Vagrant::Errors::VMPowerOffToPackage if \
    @env[:machine].state.id != :stopped

  export

  @app.call(env)
end

#exportObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant_utm/action/export.rb', line 23

def export
  @env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
  @env[:machine].provider.driver.export(utm_path) do |progress|
    @env[:ui].rewriting do |ui|
      ui.clear_line
      ui.report_progress(progress.percent, 100, false)
    end
  end

  # Clear the line a final time so the next data can appear
  # alone on the line.
  @env[:ui].clear_line
end

#utm_pathObject



37
38
39
# File 'lib/vagrant_utm/action/export.rb', line 37

def utm_path
  File.join(@env["export.temp_dir"], "box.utm")
end