Sha256: 680d1401d4afa809313efa013c6219ceef9f6d69f6e089192759414958b1b00b

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require 'tempfile'

module Veewee
  module Provider
    module Vmfusion
      module BoxCommand
        # This function 'exports' the box based on the definition
        def export_ova(options)
          debug="--X:logToConsole=true --X:logLevel=\"verbose\""
          debug=""
          flags="--compress=9"

          if File.exists?("#{name}.ova")
            if options["force"]
              env.logger.debug("#{name}.ova exists, but --force was provided")
              env.logger.debug("removing #{name}.ova first")
              FileUtils.rm("#{name}.ova")
              env.logger.debug("#{name}.ova removed")
            else
              raise Veewee::Error, "export file #{name}.ova already exists. Use --force option to overwrite."
            end
          end

          # Need to check binary first
          if self.running?
            # Wait for the shutdown to complete
            begin
              Timeout::timeout(20) do
                self.halt(options)
                status=self.running?
                unless status
                  return
                end
                sleep 4
              end
            rescue TimeoutError::Error => ex
              raise Veewee::Error,ex
            end
          end

          # before exporting the system needs to be shut down

          # otherwise the debug log will show - The specified virtual disk needs repair
          shell_exec("#{fusion_path.shellescape}/ovftool/ovftool.bin #{debug} #{flags} #{vmx_file_path.shellescape} #{name}.ova")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
veewee-0.3.0.alpha9 lib/veewee/provider/vmfusion/box/export_ova.rb
veewee-0.3.0.alpha8 lib/veewee/provider/vmfusion/box/export_ova.rb
veewee-0.3.0.alpha7 lib/veewee/provider/vmfusion/box/export_ova.rb
veewee-0.3.0.alpha6 lib/veewee/provider/vmfusion/box/export_ova.rb
veewee-0.3.0.alpha5 lib/veewee/provider/vmfusion/box/export_ova.rb