lib/vmpooler/providers/vsphere.rb
# The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
def find_least_used_hosts(cluster, datacentername, percentage)
          @connection_pool.with_metrics do |pool_object|
            connection = ensured_vsphere_connection(pool_object)
            cluster_object = find_cluster(cluster, connection, datacentername)
            raise("Cluster #{cluster} cannot be found") if cluster_object.nil?
            target_hosts = get_cluster_host_utilization(cluster_object)
            raise("there is no candidate in vcenter that meets all the required conditions, that the cluster has available hosts in a 'green' status, not in maintenance mode and not overloaded CPU and memory'") if target_hosts.empty?
            architectures = build_compatible_hosts_lists(target_hosts, percentage)
            least_used_hosts = select_least_used_hosts(target_hosts, percentage)
            {
              'hosts' => least_used_hosts,
              'architectures' => architectures
            }
          end
        end
def find_least_used_hosts ( cluster , datacentername , percentage ) @connection_pool . with_metrics do | pool_object | connection = ensured_vsphere_connection ( pool_object ) cluster_object = find_cluster ( cluster , connection , datacentername ) raise ( "Cluster #{cluster} cannot be found" ) if cluster_object . nil? target_hosts = get_cluster_host_utilization ( cluster_object ) raise ( "there is no candidate in vcenter that meets all the required conditions, that the cluster has available hosts in a 'green' status, not in maintenance mode and not overloaded CPU and memory'" ) if target_hosts . empty? architectures = build_compatible_hosts_lists ( target_hosts , percentage ) least_used_hosts = select_least_used_hosts ( target_hosts , percentage ) { 'hosts' => least_used_hosts , 'architectures' => architectures } end end
The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
cluster
datacentername
percentage