Class: Tenderloin::Actions::Box::Convert
- Inherits:
-
Tenderloin::Actions::Base
- Object
- Tenderloin::Actions::Base
- Tenderloin::Actions::Box::Convert
- Defined in:
- lib/tenderloin/actions/box/convert.rb
Overview
If the box is vagrant format, it converts it to something suitible for tenderloin
Instance Attribute Summary
Attributes inherited from Tenderloin::Actions::Base
Instance Method Summary collapse
Methods inherited from Tenderloin::Actions::Base
#cleanup, #initialize, #prepare, #rescue
Methods included from Util
#error_and_exit, included, #logger, #wrap_output
Constructor Details
This class inherits a constructor from Tenderloin::Actions::Base
Instance Method Details
#convert_ovf ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/tenderloin/actions/box/convert.rb', line 23 def convert_ovf ovf = File.join(@runner.directory, 'box.ovf') vmx = File.join(@runner.directory, 'vmwarebox.vmx') OVFTool.ovf2vmx(ovf, vmx, :lax => true) FileUtils.rm_rf(@runner.directory) FileUtils.mv(@runner.directory + ".vmwarevm", @runner.directory) end |
#execute! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tenderloin/actions/box/convert.rb', line 7 def execute! if !Dir[@runner.directory + '/Tenderfile'].empty? # We can do nothing - pretenderized logger.info "Tenderloin box provided" elsif !Dir[@runner.directory + '/Vagrantfile'].empty? # Need to import from Vagrant. Convert the ovf to vmx using OVFtool, then write a base tenderfile logger.info "Vagrant box provided, converting" convert_ovf write_tenderfile logger.info "Vagrant box converted. It has a basic Tenderfile, you may want to customize this if needed" logger.info "This file can be found in #{@runner.directory}" else raise "Invalid box - No Tenderfile or Vagrantfile" end end |
#write_tenderfile ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/tenderloin/actions/box/convert.rb', line 31 def write_tenderfile tenderfile = <<EOF Tenderloin::Config.run do |config| config.vm.box_vmx = "vmwarebox.vmx" end EOF File.open(File.join(@runner.directory, 'Tenderfile'), 'w') {|f| f.write(tenderfile) } end |