bosh_vsphere_cpi/lib/cloud/vsphere/resources/scorer.rb
def score
        min_ephemeral = @ephemeral
        min_persistent = @persistent.min
        min_shared = min_ephemeral
        if !min_persistent.nil? && min_persistent < min_shared
          min_shared = min_persistent
        end

        # Filter out any datastores that are below the min threshold
        filter(@free_ephemeral, min_ephemeral + DISK_THRESHOLD)
        filter(@free_shared, min_shared + DISK_THRESHOLD)
        unless @persistent.empty?
          filter(@free_persistent, min_persistent + DISK_THRESHOLD)
        end

        count = 0
        loop do
          @free_memory -= @memory
          if @free_memory < MEMORY_THRESHOLD
            @logger.debug("#{@cluster.name} memory bound")
            break
          end

          consumed = consume_disk(@free_ephemeral, @ephemeral, min_ephemeral)
          unless consumed
            unless consume_disk(@free_shared, @ephemeral, min_shared)
              @logger.debug("#{@cluster.name} ephemeral disk bound")
              break
            end
          end

          unless @persistent.empty?
            consumed_all = true
            @persistent.each do |size|
              consumed = consume_disk(@free_persistent, size, min_persistent)
              unless consumed
                unless consume_disk(@free_shared, size, min_shared)
                  consumed_all = false
                  @logger.debug("#{@cluster.name} persistent disk bound")
                  break
                end
              end
            end
            break unless consumed_all
          end

          count += 1
        end

        count
      end
# Run the scoring function and return the placement score for the required
# resources.
#
# @return [Integer] score.
Run the scoring function and return the placement score for the required
resources.
Run the scoring function and return the placement score for the required resources .
def score
        min_ephemeral = @ephemeral
        min_persistent = @persistent.min
        min_shared = min_ephemeral
        if !min_persistent.nil? && min_persistent < min_shared
          min_shared = min_persistent
        end
        filter(@free_ephemeral, min_ephemeral + DISK_THRESHOLD)
        filter(@free_shared, min_shared + DISK_THRESHOLD)
        unless @persistent.empty?
          filter(@free_persistent, min_persistent + DISK_THRESHOLD)
        end
        count = 0
        loop do
          @free_memory -= @memory
          if @free_memory < MEMORY_THRESHOLD
            @logger.debug("#{@cluster.name} memory bound")
            break
          end
          consumed = consume_disk(@free_ephemeral, @ephemeral, min_ephemeral)
          unless consumed
            unless consume_disk(@free_shared, @ephemeral, min_shared)
              @logger.debug("#{@cluster.name} ephemeral disk bound")
              break
            end
          end
          unless @persistent.empty?
            consumed_all = true
            @persistent.each do |size|
              consumed = consume_disk(@free_persistent, size, min_persistent)
              unless consumed
                unless consume_disk(@free_shared, size, min_shared)
                  consumed_all = false
                  @logger.debug("#{@cluster.name} persistent disk bound")
                  break
                end
              end
            end
            break unless consumed_all
          end
          count += 1
        end
        count
      end
def score min_ephemeral = @ephemeral min_persistent = @persistent . min min_shared = min_ephemeral if ! min_persistent . nil? && min_persistent < min_shared min_shared = min_persistent end filter ( @free_ephemeral , min_ephemeral + DISK_THRESHOLD ) filter ( @free_shared , min_shared + DISK_THRESHOLD ) unless @persistent . empty? filter ( @free_persistent , min_persistent + DISK_THRESHOLD ) end count = 0 loop do @free_memory -= @memory if @free_memory < MEMORY_THRESHOLD @logger . debug ( "#{@cluster.name} memory bound" ) break end consumed = consume_disk ( @free_ephemeral , @ephemeral , min_ephemeral ) unless consumed unless consume_disk ( @free_shared , @ephemeral , min_shared ) @logger . debug ( "#{@cluster.name} ephemeral disk bound" ) break end end unless @persistent . empty? consumed_all = true @persistent . each do | size | consumed = consume_disk ( @free_persistent , size , min_persistent ) unless consumed unless consume_disk ( @free_shared , size , min_shared ) consumed_all = false @logger . debug ( "#{@cluster.name} persistent disk bound" ) break end end end break unless consumed_all end count += 1 end count end
Run the scoring function and return the placement score for the required
resources.
Run the scoring function and return the placement score for the required resources .
# Filter out any datastores that are below the min threshold
None
Integer