Keep asking for a hostname that not exist
501046
def ask_not_existing_hostname(project_root, environment)
      hostname = ask_hostname(project_root, environment)
      # Check if the node not exist
      if node_exists?(project_root, environment, hostname)
        error _('wizard.node.hostname_exist')
        ask_hostname(project_root, environment)
      else
        return hostname
      end
    end
1008353
def check_correct_host(self):
        
        if self._host == 'knoema.com':
            return
        url = self._get_url('/api/1.0/frontend/tags')
        req = urllib.request.Request(url)
        try:
            resp = urllib.request.urlopen(req)
        except:
            raise ValueError('The specified host {} does not exist'.format(self._host))
1359614
def _get_ids_from_hostname(self, hostname):
        """"""
        results = self.list_hardware(hostname=hostname, mask="id")
        return [result['id'] for result in results]
518108
def any_match(self, urls):
        
        return any(urlparse(u).hostname in self for u in urls)
75943
def hostname
      # return it if already set
      return @server if @server
      # otherwise, from the config
      srvr = JSS::CONFIG.db_server_name
      # otherwise, assume its on the JSS server to which this client talks
      srvr ||= JSS::Client.jss_server
      srvr
    end
517566
function hostnameof (req) {
  var host = req.headers.host

  if (!host) {
    return
  }

  var offset = host[0] === '['
    ? host.indexOf(']') + 1
    : 0
  var index = host.indexOf(':', offset)

  return index !== -1
    ? host.substring(0, index)
    : host
}
1367556
async def query(
            cls, *,
            hostnames: typing.Iterable[str] = None,
            domains: typing.Iterable[str] = None,
            zones: typing.Iterable[str] = None,
            macs: typing.Iterable[str] = None,
            system_ids: typing.Iterable[str] = None,
            agent_name: str = None,
            level: typing.Union[Level, int, str] = None,
            before: int = None,
            after: int = None,
            limit: int = None,
            owner: typing.Union[User, str] = None):
        """"""

        if before is not None and after is not None:
            raise ValueError("Specify either `before` or `after`, not both.")

        params = {}

        if hostnames is not None:
            params["hostname"] = list(hostnames)
        if domains is not None:
            params["domain"] = list(domains)
        if zones is not None:
            params["zone"] = list(zones)
        if macs is not None:
            params["mac_address"] = list(macs)
        if system_ids is not None:
            params["id"] = list(system_ids)
        if agent_name is not None:
            params["agent_name"] = [agent_name]
        if level is not None:
            level = Level.normalise(level)
            params["level"] = [level.name]
        if before is not None:
            params["before"] = ["{:d}".format(before)]
        if after is not None:
            params["after"] = ["{:d}".format(after)]
        if limit is not None:
            params["limit"] = ["{:d}".format(limit)]
        if owner is not None:
            if isinstance(owner, User):
                params["owner"] = [owner.username]
            elif isinstance(owner, str):
                params["owner"] = [owner]
            else:
                raise TypeError(
                    "owner must be either User or str, not %s" % (
                        type(owner).__name__))

        data = await cls._handler.query(**params)
        return cls(data)
1149004
def _resolve_resource_name(self, name):
        """"""
        if name[:4] == 'http':  # already a url
            return name
        name = name.rstrip('/').lstrip('/')
        return '%s%s/%s' % (self.scheme, self.host, name)
1128119
def get_hostname_text(self):
        """"""
        # FIXME: fix it, too complex logic
        try:
            hostname_text = self.device.send('hostname', timeout=10)
            if hostname_text:
                self.device.hostname = hostname_text.splitlines()[0]
                return hostname_text
        except CommandError:
            self.log("Non Unix jumphost type detected")
            return None
1151306
def collect_hosts(api, wanted_hostnames):
  
  all_hosts = api.get_all_hosts(view='full')
  all_hostnames = set([ h.hostname for h in all_hosts])
  wanted_hostnames = set(wanted_hostnames)

  unknown_hosts = wanted_hostnames.difference(all_hostnames)
  if len(unknown_hosts) != 0:
    msg = "The following hosts are not found in Cloudera Manager. "\
          "Please check for typos:\n%s" % ('\n'.join(unknown_hosts))
    LOG.error(msg)
    raise RuntimeError(msg)

  return [ h for h in all_hosts if h.hostname in wanted_hostnames ]
1045807
def hostname(self, levels=1):
        
        if levels < 1:
            return self.random_element(self.hostname_prefixes) + '-' + self.numerify('##')
        return self.random_element(self.hostname_prefixes) + '-' + self.numerify('##') + '.' + self.domain_name(levels)
252579
def get_host_name():
    

    if sys.platform == 'win32':
        host = os.getenv('COMPUTERNAME')
    else:
        host = os.uname()[1]


    return host
743879
def hostname_for_event(self, clean_server_name):
        """"""
        uri = urlsplit(clean_server_name)
        if '@' in uri.netloc:
            hostname = uri.netloc.split('@')[1].split(':')[0]
        else:
            hostname = uri.netloc.split(':')[0]
        if hostname == 'localhost':
            hostname = self.hostname
        return hostname
1065247
def ConfigureHostnames(config, external_hostname = None):
  """"""
  if not external_hostname:
    try:
      external_hostname = socket.gethostname()
    except (OSError, IOError):
      print("Sorry, we couldn't guess your hostname.\n")

    external_hostname = RetryQuestion(
        "Please enter your hostname e.g. "
        "grr.example.com", "^[\\.A-Za-z0-9-]+$", external_hostname)

  print("""\n\n-=Server URL=-
The Server URL specifies the URL that the clients will connect to
communicate with the server. For best results this should be publicly
accessible. By default this will be port 8080 with the URL ending in /control.
""")
  frontend_url = RetryQuestion("Frontend URL", "^http://.*/$",
                               "http://%s:8080/" % external_hostname)
  config.Set("Client.server_urls", [frontend_url])

  frontend_port = urlparse.urlparse(frontend_url).port or grr_config.CONFIG.Get(
      "Frontend.bind_port")
  config.Set("Frontend.bind_port", frontend_port)

  print("""\n\n-=AdminUI URL=-:
The UI URL specifies where the Administrative Web Interface can be found.
""")
  ui_url = RetryQuestion("AdminUI URL", "^http[s]*://.*$",
                         "http://%s:8000" % external_hostname)
  config.Set("AdminUI.url", ui_url)
  ui_port = urlparse.urlparse(ui_url).port or grr_config.CONFIG.Get(
      "AdminUI.port")
  config.Set("AdminUI.port", ui_port)
1270313
def add_host(zone, name, ttl, ip, nameserver='127.0.0.1', replace=True,
             timeout=5, port=53, **kwargs):
    '''
    
    '''
    res = update(zone, name, ttl, 'A', ip, nameserver, timeout, replace, port,
                 **kwargs)
    if res is False:
        return False

    fqdn = '{0}.{1}.'.format(name, zone)
    parts = ip.split('.')[::-1]
    popped = []

    # Iterate over possible reverse zones
    while len(parts) > 1:
        p = parts.pop(0)
        popped.append(p)
        zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
        name = '.'.join(popped)
        ptr = update(zone, name, ttl, 'PTR', fqdn, nameserver, timeout,
                     replace, port, **kwargs)
        if ptr:
            return True
    return res
1266851
def host2id(self, hostname):
        """"""
        for key, value in self.server_map.items():
            if value == hostname:
                return key
650627
def get_host_system_failfast(
            self,
            name,
            verbose=False,
            host_system_term='HS'
    ):
        
        if verbose:
            print("Finding HostSystem named %s..." % name)

        hs = self.get_host_system(name)

        if hs is None:
            print("Error: %s '%s' does not exist" % (host_system_term, name))
            sys.exit(1)

        if verbose:
            print("Found HostSystem: {0} Name: {1}" % (hs, hs.name))

        return hs