Class: Vagrant::Action::VM::Export
- Inherits:
-
Object
- Object
- Vagrant::Action::VM::Export
- Defined in:
- lib/vagrant/action/vm/export.rb
Instance Attribute Summary collapse
-
#temp_dir ⇒ Object
readonly
Returns the value of attribute temp_dir.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #export ⇒ Object
-
#initialize(app, env) ⇒ Export
constructor
A new instance of Export.
- #ovf_path ⇒ Object
- #recover(env) ⇒ Object
- #setup_temp_dir ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Export
Returns a new instance of Export.
9 10 11 12 |
# File 'lib/vagrant/action/vm/export.rb', line 9 def initialize(app, env) @app = app @env = env end |
Instance Attribute Details
#temp_dir ⇒ Object (readonly)
Returns the value of attribute temp_dir.
7 8 9 |
# File 'lib/vagrant/action/vm/export.rb', line 7 def temp_dir @temp_dir end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant/action/vm/export.rb', line 14 def call(env) @env = env raise Errors::VMPowerOffToPackage if !@env["vm"].vm.powered_off? setup_temp_dir export @app.call(env) recover(env) # called to cleanup temp directory end |
#export ⇒ Object
39 40 41 42 43 44 |
# File 'lib/vagrant/action/vm/export.rb', line 39 def export @env.ui.info I18n.t("vagrant.actions.vm.export.exporting") @env["vm"].vm.export(ovf_path) do |progress| @env.ui.report_progress(progress.percent, 100, false) end end |
#ovf_path ⇒ Object
46 47 48 |
# File 'lib/vagrant/action/vm/export.rb', line 46 def ovf_path File.join(@env["export.temp_dir"], @env.env.config.vm.box_ovf) end |
#recover(env) ⇒ Object
27 28 29 30 31 |
# File 'lib/vagrant/action/vm/export.rb', line 27 def recover(env) if temp_dir && File.exist?(temp_dir) FileUtils.rm_rf(temp_dir) end end |
#setup_temp_dir ⇒ Object
33 34 35 36 37 |
# File 'lib/vagrant/action/vm/export.rb', line 33 def setup_temp_dir @env.ui.info I18n.t("vagrant.actions.vm.export.create_dir") @temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s) FileUtils.mkpath(@env["export.temp_dir"]) end |