def create_disk_spec(params)
      disk_type = params[:disk_type] || :flat
      disk_file = params[:disk_file]
      if disk_type == :sparse and disk_file.nil?
        raise Exception.new("Creating sparse disks in ESX is not supported. Use an existing image.")
      end
      disk_size = params[:disk_size]
      datastore = params[:datastore]
      datastore = datastore + " #{disk_file}" if not disk_file.nil?
      spec = {}
      if disk_type == :sparse
        spec = {
          :operation => :add,
          :device => RbVmomi::VIM.VirtualDisk(
                           :key => 0,
                           :backing => RbVmomi::VIM.VirtualDiskSparseVer2BackingInfo(
                                          :fileName => datastore,
                                          :diskMode => :persistent),
                           :controllerKey => 1000,
                           :unitNumber => 0,
                           :capacityInKB => disk_size)
        }
      else
        spec = {
          :operation => :add,
          :device => RbVmomi::VIM.VirtualDisk(
                           :key => 0,
                           :backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
                                          :fileName => datastore,
                                          :diskMode => :persistent),
                           :controllerKey => 1000,
                           :unitNumber => 0,
                           :capacityInKB => disk_size)
        }
      end
      spec[:fileOperation] = :create if disk_file.nil?
      spec
    end
def create_disk_spec(params)
      disk_type = params[:disk_type] || :flat
      disk_file = params[:disk_file]
      if disk_type == :sparse and disk_file.nil?
        raise Exception.new("Creating sparse disks in ESX is not supported. Use an existing image.")
      end
      disk_size = params[:disk_size]
      datastore = params[:datastore]
      datastore = datastore + " #{disk_file}" if not disk_file.nil?
      spec = {}
      if disk_type == :sparse
        spec = {
          :operation => :add,
          :device => RbVmomi::VIM.VirtualDisk(
                           :key => 0,
                           :backing => RbVmomi::VIM.VirtualDiskSparseVer2BackingInfo(
                                          :fileName => datastore,
                                          :diskMode => :persistent),
                           :controllerKey => 1000,
                           :unitNumber => 0,
                           :capacityInKB => disk_size)
        }
      else
        spec = {
          :operation => :add,
          :device => RbVmomi::VIM.VirtualDisk(
                           :key => 0,
                           :backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
                                          :fileName => datastore,
                                          :diskMode => :persistent),
                           :controllerKey => 1000,
                           :unitNumber => 0,
                           :capacityInKB => disk_size)
        }
      end
      spec[:fileOperation] = :create if disk_file.nil?
      spec
    end
disk_file
 datastore
 disk_size
 disk_type