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 select_next_host(pool_name, target, architecture = nil)
          datacenter = get_target_datacenter_from_config(pool_name)
          cluster = get_target_cluster_from_config(pool_name)
          raise("cluster for pool #{pool_name} cannot be identified") if cluster.nil?
          raise("datacenter for pool #{pool_name} cannot be identified") if datacenter.nil?
          dc = "#{datacenter}_#{cluster}"
          @provider_hosts_lock.synchronize do
            if architecture
              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") unless target[dc].key?('architectures')
              host = target[dc]['architectures'][architecture].shift
              target[dc]['architectures'][architecture] << host
              if target[dc]['hosts'].include?(host)
                target[dc]['hosts'].delete(host)
                target[dc]['hosts'] << host
              end
            else
              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") unless target[dc].key?('hosts')
              host = target[dc]['hosts'].shift
              target[dc]['hosts'] << host
              target[dc]['architectures'].each do |arch|
                target[dc]['architectures'][arch] = arch.partition { |v| v != host }.flatten if arch.include?(host)
              end
            end
            return host
          end
        end
def select_next_host ( pool_name , target , architecture = nil ) datacenter = get_target_datacenter_from_config ( pool_name ) cluster = get_target_cluster_from_config ( pool_name ) raise ( "cluster for pool #{pool_name} cannot be identified" ) if cluster . nil? raise ( "datacenter for pool #{pool_name} cannot be identified" ) if datacenter . nil? dc = "#{datacenter}_#{cluster}" @provider_hosts_lock . synchronize do if architecture 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" ) unless target [ dc ] . key? ( 'architectures' ) host = target [ dc ] [ 'architectures' ] [ architecture ] . shift target [ dc ] [ 'architectures' ] [ architecture ] << host if target [ dc ] [ 'hosts' ] . include? ( host ) target [ dc ] [ 'hosts' ] . delete ( host ) target [ dc ] [ 'hosts' ] << host end else 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" ) unless target [ dc ] . key? ( 'hosts' ) host = target [ dc ] [ 'hosts' ] . shift target [ dc ] [ 'hosts' ] << host target [ dc ] [ 'architectures' ] . each do | arch | target [ dc ] [ 'architectures' ] [ arch ] = arch . partition { | v | v != host } . flatten if arch . include? ( host ) end end return host end end
The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
pool_name
target
architecture