Sha256: 61819de4c93959a2d5dc0d0c5b7b832fa41e217fa5a81d7ad1223c2fd495bf90

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require 'erb'

module Veewee
  module Provider
    module Vmfusion
      module BoxCommand
      class ErbBinding < OpenStruct
        def get_binding
          return binding()
        end
      end

      def vmx_template(definition)
        # We only want specific variables for ERB

        floppy_path=nil
        unless definition.floppy_files.nil?
          floppy_path=File.join(definition.path,'virtualfloppy.img')
        end

        data = {
          :cpu_count => definition.cpu_count, :memory_size => definition.memory_size,
          :controller_type => "lsilogic",
          :fusion_os_type => definition.os_type_id,
          :floppyfile => floppy_path,
          :mac_addres => "auto generated",
          :iso_file => "#{File.join(env.config.veewee.iso_dir,definition.iso_file)}",
          :box_name => name,
          :vnc_port => guess_vnc_port
        }

        vars = ErbBinding.new(data)
        template_path=File.join(File.dirname(__FILE__),"template.vmx.erb")
        template=File.open(template_path).readlines.join
        erb = ERB.new(template)
        vars_binding = vars.send(:get_binding)
        result=erb.result(vars_binding)
        return result
      end
    end

  end
end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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