Sha256: 1ff322bc29f168a71af44f5266ac4726011e8e018110af05cdcbf74e6efa7bca

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

require 'erb'

module Veewee
  module Provider
    module Vmfusion
      module BoxCommand

        # When we create a new box
        # We assume the box is not running
        def create(options)
          create_vm
          create_disk
          self.create_floppy("virtualfloppy.img")
        end


        def create_disk
          #Disk types:
          #    0                   : single growable virtual disk
          #    1                   : growable virtual disk split in 2GB files
          #    2                   : preallocated virtual disk
          #    3                   : preallocated virtual disk split in 2GB files
          #    4                   : preallocated ESX-type virtual disk
          #    5                   : compressed disk optimized for streaming
          #    6                   : thin provisioned virtual disk - ESX 3.x and above
          disk_type=1
          current_dir=FileUtils.pwd
          FileUtils.chdir(vm_path)
          env.ui.info "Creating disk"
          command="#{fusion_path.shellescape}/vmware-vdiskmanager -c -s #{definition.disk_size}M -a lsilogic -t #{disk_type} #{name}.vmdk"
          shell_results=shell_exec("#{command}",{:mute => true})
          FileUtils.chdir(current_dir)
        end

        def fusion_os_type(type_id)
          env.logger.info "Translating #{type_id} into fusion type"
          fusiontype=env.ostypes[type_id][:fusion]
          env.logger.info "Found fusion type #{fusiontype}"
          return fusiontype
        end

        def create_vm
          fusion_definition=definition.dup

          fusion_definition.os_type_id=fusion_os_type(definition.os_type_id)

          FileUtils.mkdir_p(vm_path)
          current_dir=FileUtils.pwd
          FileUtils.chdir(vm_path)
          aFile = File.new(vmx_file_path, "w")
          aFile.write(vmx_template(fusion_definition))
          aFile.close
          FileUtils.chdir(current_dir)
        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/create.rb
veewee-0.3.0.alpha8 lib/veewee/provider/vmfusion/box/create.rb
veewee-0.3.0.alpha7 lib/veewee/provider/vmfusion/box/create.rb
veewee-0.3.0.alpha6 lib/veewee/provider/vmfusion/box/create.rb
veewee-0.3.0.alpha5 lib/veewee/provider/vmfusion/box/create.rb