bosh_vsphere_cpi/lib/cloud/vsphere/resources/cluster.rb
# Picks the best datastore for the specified disk size and type.
#
# First the exclusive datastore pool is used. If it's empty or doesn't
# have enough capacity then the shared pool will be used.
#
# @param [Integer] size disk size.
# @param [Symbol] type disk type.
# @return [Datastore, nil] best datastore if available for the requested
#   size.
Picks the best datastore for the specified disk size and type.
First the exclusive datastore pool is used. If it's empty or doesn't
have enough capacity then the shared pool will be used.
Picks the best datastore for the specified disk size and type . First the exclusive datastore pool is used . If it ' s empty or doesn ' t have enough capacity then the shared pool will be used .
def pick_store(size, type)
        weighted_datastores = []
        datastores =
            type == :persistent ? @persistent_datastores : @ephemeral_datastores
        datastores.each_value do |datastore|
          if datastore.free_space - size >= DISK_THRESHOLD
            weighted_datastores << [datastore, datastore.free_space]
          end
        end
        if weighted_datastores.empty?
          @shared_datastores.each_value do |datastore|
            if datastore.free_space - size >= DISK_THRESHOLD
              weighted_datastores << [datastore, datastore.free_space]
            end
          end
        end
        Util.weighted_random(weighted_datastores)
      end
def pick_store ( size , type ) weighted_datastores = [ ] datastores = type == :persistent ? @persistent_datastores : @ephemeral_datastores datastores . each_value do | datastore | if datastore . free_space - size >= DISK_THRESHOLD weighted_datastores << [ datastore , datastore . free_space ] end end if weighted_datastores . empty? @shared_datastores . each_value do | datastore | if datastore . free_space - size >= DISK_THRESHOLD weighted_datastores << [ datastore , datastore . free_space ] end end end Util . weighted_random ( weighted_datastores ) end
Picks the best datastore for the specified disk size and type.
Picks the best datastore for the specified disk size and type .
best datastore if available for the requested size.
best datastore if available for the requested size .
Datastore, nil
size
type
type disk type.
type disk type .