def create_vm(specification)
      spec = specification
      spec[:cpus] = (specification[:cpus] || 1).to_i
      spec[:cpu_cores] = (specification[:cpu_cores] || 1).to_i
      spec[:guest_id] = specification[:guest_id] || 'otherGuest'
	  spec[:hw_version] = (specification[:hw_version] || 8).to_i
      if specification[:disk_size]
        spec[:disk_size] = (specification[:disk_size].to_i * 1024)
      else
        spec[:disk_size] = 4194304
      end
      spec[:memory] = (specification[:memory] || 128).to_i
      if specification[:datastore]
        spec[:datastore] = "[#{specification[:datastore]}]"
      else
        spec[:datastore] = '[datastore1]'
      end
      vm_cfg = {
        :name => spec[:vm_name],
        :guestId => spec[:guest_id],
        :files => { :vmPathName => spec[:datastore] },
        :numCPUs => spec[:cpus],
        :numCoresPerSocket => spec[:cpu_cores],
        :memoryMB => spec[:memory],
        :deviceChange => [
          {
            :operation => :add,
            :device => RbVmomi::VIM.VirtualLsiLogicController(
                             :key => 1000,
                             :busNumber => 0,
                             :sharedBus => :noSharing)
          }
        ],
		:version => 'vmx-'+spec[:hw_version].to_s.rjust(2,'0'),
        :extraConfig => [
          {
            :key => 'bios.bootOrder',
            :value => 'ethernet0'
          }
        ]
      }

      #Add multiple nics
      nics_count = 0
      if spec[:nics]
        spec[:nics].each do |nic_spec|
          vm_cfg[:deviceChange].push(
            {
              :operation => :add,
              :device => RbVmomi::VIM.VirtualE1000(create_net_dev(nics_count, nic_spec))

            }
          )
          nics_count += 1
        end
      end
      # VMDK provided, replace the empty vmdk
      vm_cfg[:deviceChange].push(create_disk_spec(:disk_file => spec[:disk_file],
                                :disk_type => spec[:disk_type],
                                :disk_size => spec[:disk_size],
                                :datastore => spec[:datastore]))

      unless @free_license
        VM.wrap(@_datacenter.vmFolder.CreateVM_Task(:config => vm_cfg, :pool => @_datacenter.hostFolder.children.first.resourcePool).wait_for_completion,self)
      else
        gem_root = Gem::Specification.find_by_name("esx").gem_dir
        template_path = File.join(gem_root, 'templates', 'vmx_template.erb')
        spec[:guest_id] = convert_guest_id_for_vmdk(spec[:guest_id])
        erb = ERB.new File.read(template_path)
        vmx = erb.result binding
        tmp_vmx = Tempfile.new 'vmx'
        tmp_vmx.write vmx
        tmp_vmx.close
        ds = spec[:datastore]||'datastore1'
        ds = ds.gsub('[','').gsub(']','')
        vmx_path = "/vmfs/volumes/#{ds}/#{spec[:vm_name]}/#{spec[:vm_name]}.vmx"
        remote_command "mkdir -p #{File.dirname(vmx_path)}"
        upload_file tmp_vmx.path, vmx_path
        remote_command "vim-cmd solo/registervm #{vmx_path}"
        VM.wrap(@_datacenter.find_vm(spec[:vm_name]),self)
      end
    end
def create_vm(specification)
      spec = specification
      spec[:cpus] = (specification[:cpus] || 1).to_i
      spec[:cpu_cores] = (specification[:cpu_cores] || 1).to_i
      spec[:guest_id] = specification[:guest_id] || 'otherGuest'
	  spec[:hw_version] = (specification[:hw_version] || 8).to_i
      if specification[:disk_size]
        spec[:disk_size] = (specification[:disk_size].to_i * 1024)
      else
        spec[:disk_size] = 4194304
      end
      spec[:memory] = (specification[:memory] || 128).to_i
      if specification[:datastore]
        spec[:datastore] = "[#{specification[:datastore]}]"
      else
        spec[:datastore] = '[datastore1]'
      end
      vm_cfg = {
        :name => spec[:vm_name],
        :guestId => spec[:guest_id],
        :files => { :vmPathName => spec[:datastore] },
        :numCPUs => spec[:cpus],
        :numCoresPerSocket => spec[:cpu_cores],
        :memoryMB => spec[:memory],
        :deviceChange => [
          {
            :operation => :add,
            :device => RbVmomi::VIM.VirtualLsiLogicController(
                             :key => 1000,
                             :busNumber => 0,
                             :sharedBus => :noSharing)
          }
        ],
		:version => 'vmx-'+spec[:hw_version].to_s.rjust(2,'0'),
        :extraConfig => [
          {
            :key => 'bios.bootOrder',
            :value => 'ethernet0'
          }
        ]
      }

      #Add multiple nics
      nics_count = 0
      if spec[:nics]
        spec[:nics].each do |nic_spec|
          vm_cfg[:deviceChange].push(
            {
              :operation => :add,
              :device => RbVmomi::VIM.VirtualE1000(create_net_dev(nics_count, nic_spec))

            }
          )
          nics_count += 1
        end
      end
      # VMDK provided, replace the empty vmdk
      vm_cfg[:deviceChange].push(create_disk_spec(:disk_file => spec[:disk_file],
                                :disk_type => spec[:disk_type],
                                :disk_size => spec[:disk_size],
                                :datastore => spec[:datastore]))

      unless @free_license
        VM.wrap(@_datacenter.vmFolder.CreateVM_Task(:config => vm_cfg, :pool => @_datacenter.hostFolder.children.first.resourcePool).wait_for_completion,self)
      else
        gem_root = Gem::Specification.find_by_name("esx").gem_dir
        template_path = File.join(gem_root, 'templates', 'vmx_template.erb')
        spec[:guest_id] = convert_guest_id_for_vmdk(spec[:guest_id])
        erb = ERB.new File.read(template_path)
        vmx = erb.result binding
        tmp_vmx = Tempfile.new 'vmx'
        tmp_vmx.write vmx
        tmp_vmx.close
        ds = spec[:datastore]||'datastore1'
        ds = ds.gsub('[','').gsub(']','')
        vmx_path = "/vmfs/volumes/#{ds}/#{spec[:vm_name]}/#{spec[:vm_name]}.vmx"
        remote_command "mkdir -p #{File.dirname(vmx_path)}"
        upload_file tmp_vmx.path, vmx_path
        remote_command "vim-cmd solo/registervm #{vmx_path}"
        VM.wrap(@_datacenter.find_vm(spec[:vm_name]),self)
      end
    end
Create a Virtual Machine

 Requires a Hash with the following keys:

 {
   :vm_name => name, (string, required)
   :cpus => 1, #(int, optional)
   :guest_id => 'otherGuest', #(string, optional)
   :disk_size => 4096,  #(in MB, optional)
   :memory => 128, #(in MB, optional)
   :datastore => datastore1 #(string, optional)
   :disk_file => path to vmdk inside datastore (optional)
   :disk_type => flat, sparse (default flat)
   :hw_version => 8 #(int, optional)
 }

 supported guest_id list:
 http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html

 Default values above.