bosh_vsphere_cpi/lib/cloud/vsphere/resources/cluster.rb
def fetch_res_pool_utilization
        properties = @client.get_properties(
            @resource_pool.mob, Vim::ResourcePool, %w(summary))
        if properties.nil?
          raise "Failed to get utilization for resource pool #{resource_pool}"
        end

        runtime_info = properties["summary"].runtime
        if runtime_info.overall_status == "green"
          cpu = runtime_info.cpu
          @idle_cpu = 1 - (cpu.overall_usage.to_f / cpu.max_usage)
          memory = runtime_info.memory
          @total_memory = memory.max_usage / BYTES_IN_MB
          @synced_free_memory =
              (memory.max_usage - memory.overall_usage) / BYTES_IN_MB
        else
          @logger.warn("Ignoring cluster: #{config.name} resource_pool: " +
                           "#{@resource_pool.mob} as its state is " +
                           "unreliable: #{runtime_info.overall_status}")
          # resource pool is in an unreliable state
          @idle_cpu = 0
          @total_memory = 0
          @synced_free_memory = 0
        end
      end
# Fetches the resource pool utilization from vSphere.
#
# We can only rely on the vSphere data if the resource pool is healthy.
# Otherwise we mark the resources as unavailable.
#
# Unfortunately this method does not work for the root resource pool,
# so we can't use it for the raw clusters.
#
# @return [void]
Fetches the resource pool utilization from vSphere.
We can only rely on the vSphere data if the resource pool is healthy.
Otherwise we mark the resources as unavailable.

Unfortunately this method does not work for the root resource pool,
so we can't use it for the raw clusters.
Fetches the resource pool utilization from vSphere . We can only rely on the vSphere data if the resource pool is healthy . Otherwise we mark the resources as unavailable . Unfortunately this method does not work for the root resource pool so we can ' t use it for the raw clusters .
def fetch_res_pool_utilization
        properties = @client.get_properties(
            @resource_pool.mob, Vim::ResourcePool, %w(summary))
        if properties.nil?
          raise "Failed to get utilization for resource pool #{resource_pool}"
        end
        runtime_info = properties["summary"].runtime
        if runtime_info.overall_status == "green"
          cpu = runtime_info.cpu
          @idle_cpu = 1 - (cpu.overall_usage.to_f / cpu.max_usage)
          memory = runtime_info.memory
          @total_memory = memory.max_usage / BYTES_IN_MB
          @synced_free_memory =
              (memory.max_usage - memory.overall_usage) / BYTES_IN_MB
        else
          @logger.warn("Ignoring cluster: #{config.name} resource_pool: " +
                           "#{@resource_pool.mob} as its state is " +
                           "unreliable: #{runtime_info.overall_status}")
          @idle_cpu = 0
          @total_memory = 0
          @synced_free_memory = 0
        end
      end
def fetch_res_pool_utilization properties = @client . get_properties ( @resource_pool . mob , Vim :: ResourcePool , %w( summary ) ) if properties . nil? raise "Failed to get utilization for resource pool #{resource_pool}" end runtime_info = properties [ "summary" ] . runtime if runtime_info . overall_status == "green" cpu = runtime_info . cpu @idle_cpu = 1 - ( cpu . overall_usage . to_f / cpu . max_usage ) memory = runtime_info . memory @total_memory = memory . max_usage / BYTES_IN_MB @synced_free_memory = ( memory . max_usage - memory . overall_usage ) / BYTES_IN_MB else @logger . warn ( "Ignoring cluster: #{config.name} resource_pool: " + "#{@resource_pool.mob} as its state is " + "unreliable: #{runtime_info.overall_status}" ) @idle_cpu = 0 @total_memory = 0 @synced_free_memory = 0 end end
Fetches the resource pool utilization from vSphere.
Fetches the resource pool utilization from vSphere .
# resource pool is in an unreliable state
None
void