Define the hosts that an environment needs to be valid,
 for instance, maybe you need a :logger host and a
 :service host at a minimum.
351336
def need(host1, *more)
      sum = more << host1
      # Array doesn't have an 'exists' method, so behold - map reduce wankery!
      unless sum.map { |x| Hosties::HostDefinitions.include? x }.reduce(true) { |xs, x| x & xs }
        raise ArgumentError, "Unrecognized host type"
      end
      @hosts += sum
    end
1142303
def apply_environment
      return if noenv
      @server   ||= ENV['EMAIL_SERVER']
      @from     ||= ENV['EMAIL_FROM']    || ENV['EMAIL_ACCOUNT']
      @account  ||= ENV['EMAIL_ACCOUNT'] || ENV['EMAIL_FROM']
      @password ||= ENV['EMAIL_PASSWORD']
      @port     ||= ENV['EMAIL_PORT']
      @domain   ||= ENV['EMAIL_DOMAIN']
      @login    ||= ENV['EMAIL_LOGIN']
      @secure   ||= ENV['EMAIL_SECURE']
    end
1091146
def create_host(self, host_id, name, ipaddr, rack_id = None):
    
    return hosts.create_host(self, host_id, name, ipaddr, rack_id)
1326015
private void ensureMinimum() {
        int belowMin = minEndpoints - endpoints.size();
        if (belowMin > 0) {
            LOGGER.debug(logIdent(hostname, this) + "Service is {} below minimum, filling up.", belowMin);

            synchronized (epMutex) {
                for (int i = 0; i < belowMin; i++) {
                    Endpoint endpoint = endpointFactory.create(hostname, bucket, username, password, port, ctx);
                    endpoints.add(endpoint);
                    endpointStates.register(endpoint, endpoint);
                    endpoint.connect().subscribe(new Subscriber<LifecycleState>() {
                        @Override
                        public void onCompleted() { /* ignored on purpose */ }

                        @Override
                        public void onError(Throwable e) {
                            LOGGER.warn(logIdent(hostname, PooledService.this)
                                + "Got an error while connecting endpoint!", e);
                        }

                        @Override
                        public void onNext(LifecycleState state) { /* ignored on purpose */ }
                    });
                }

                LOGGER.debug(logIdent(hostname, PooledService.this)
                        + "New number of endpoints is {}", endpoints.size());
            }
        }
    }
542805
function detectWebEnvironment(environments) {
    // If the given environment is just a Closure, we will defer the environment check
    // to the Closure the developer has provided, which allows them to totally swap
    // the webs environment detection logic with their own custom Closure's code.
    if (typeof environments === 'function') {
        return environments()
    }

    var hosts;
    for (var environment in environments) {
        hosts = environments[environment];

        // To determine the current environment, we'll simply iterate through the possible
        // environments and look for the host that matches the host for this request we
        // are currently processing here, then return back these environment's names.
        hosts = helper.parseObject(hosts);
        var k, host;
        for (k in hosts) {
            host = hosts[k];
            if (isMachine(host)) return environment;
        }
    }

    return 'production';
}
895485
def host_validator(value, **kwargs):
    
    scheme, hostname, port, path = decompose_hostname(value)

    if len(hostname) > 255:
        return False
    if hostname[-1] == ".":
        hostname = hostname[:-1]  # strip exactly one dot from the right, if present
    allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)

    with ErrorDict() as errors:
        if not all(allowed.match(x) for x in hostname.split(".")):
            errors.add_error(
                'invalid',
                MESSAGES['host']['invalid'].format(value),
            )

        if path:
            errors.add_error(
                'path',
                MESSAGES['host']['may_not_include_path'].format(value),
            )

        if scheme:
            errors.add_error(
                'scheme',
                MESSAGES['host']['may_not_include_scheme'].format(value),
            )
68633
def ssh_cleanup_known_hosts!(hosts=[host, public_ip])
      hosts = [hosts] unless hosts.respond_to? :each
      hosts.compact.each do |name|
        system_run "ssh-keygen -R %s" % name
      end
    end
716187
def _choose_host(self):
        
        # If a host hasn't been chosen yet or there is only one host
        if len(self._hosts) == 1 or self._http_host is None:
            self._http_host = self._hosts[0]
        else:  # There is a list of hosts to choose from, pick a random one
            choice = self._http_host
            while choice == self._http_host:
                choice = random.choice(self._hosts)
            self._http_host = choice
            self._notify(logging.INFO,
                         consts.LOG_MSG_NEW_SERVER % self._http_host)

        # Set the validation and the REST URLs
        secure = 's' if self._use_ssl else ''
        self._connection_validation_url = \
            consts.CONN_VALIDATION_URL_TEMPLATE.format(host=self._http_host,
                                                       secure=secure)
        self._rest_url = consts.REST_URL_TEMPLATE.format(host=self._http_host,
                                                         token=self._token,
                                                         secure=secure)
        self._token_verification_url = \
            consts.TOKEN_VERIFICATION_URL_TEMPLATE.format(host=self._http_host,
                                                          token=self._token,
                                                          secure=secure)
180266
def to_host(self):
        """"""
        return Host(self.address,
                    alias=self.alias,
                    user=self.user,
                    keyfile=self.keyfile,
                    port=self.port,
                    extra=self.extra)
1076061
def host
      @env[Merb::Const::HTTP_X_FORWARDED_HOST] || @env[Merb::Const::HTTP_HOST] ||
        @env[Merb::Const::SERVER_NAME]
    end
299586
def host
      return @host if defined?(@host)

      # Determine the host class to use. ":detect" is an old Vagrant config
      # that shouldn't be valid anymore, but we respect it here by assuming
      # its old behavior. No need to deprecate this because I thin it is
      # fairly harmless.
      host_klass = vagrantfile.config.vagrant.host
      host_klass = nil if host_klass == :detect

      begin
        @host = Host.new(
          host_klass,
          Vagrant.plugin("2").manager.hosts,
          Vagrant.plugin("2").manager.host_capabilities,
          self)
      rescue Errors::CapabilityHostNotDetected
        # If the auto-detect failed, then we create a brand new host
        # with no capabilities and use that. This should almost never happen
        # since Vagrant works on most host OS's now, so this is a "slow path"
        klass = Class.new(Vagrant.plugin("2", :host)) do
          def detect?(env); true; end
        end

        hosts     = { generic: [klass, nil] }
        host_caps = {}

        @host = Host.new(:generic, hosts, host_caps, self)
      rescue Errors::CapabilityHostExplicitNotDetected => e
        raise Errors::HostExplicitNotDetected, e.extra_data
      end
    end
768252
def host(environ):  # pragma: no cover
    

    url = environ['wsgi.url_scheme'] + '://'

    if environ.get('HTTP_HOST'):
        url += environ['HTTP_HOST']
    else:
        url += environ['SERVER_NAME']

        if environ['wsgi.url_scheme'] == 'https':
            if environ['SERVER_PORT'] != '443':
                url += ':' + environ['SERVER_PORT']
        else:
            if environ['SERVER_PORT'] != '80':
                url += ':' + environ['SERVER_PORT']

    return url + quote(environ.get('SCRIPT_NAME', ''))
1121716
function validateEnvironment(environment, source) {

		// not having an environment is ok
		if (!environment) {
			return;
		}

		if (Array.isArray(environment)) {
			throw new Error("Environment must not be an array");
		}

		if (typeof environment === "object") {
			Object.keys(environment).forEach(function(env) {
				if (!Environments.env) {
					var message = [
						source, ":\n",
						"\tEnvironment key \"", env, "\" is unknown\n"
					];

					throw new Error(message.join(""));
				}
			});
		} else {
			throw new Error("Environment must be an object");
		}
	}
1345261
def hosts
      entries.map do |entry|
        entry.is_a?(HostGroup) ? entry.hosts : entry
      end.flatten.uniq
    end
1262892
def host(self, hostname, owner=None, **kwargs):
        
        return Host(self.tcex, hostname, owner=owner, **kwargs)
1039784
def assoc_host(self, hostname, env):
        

        dest = self._get_view_path(env)
        self.associations.set(hostname, dest)
480617
def set_host(self, host):
        
        if host[-1] == '/':
            host = host[:-1]

        self.host = host
        return self