Add a host to an existing entry, if the entry is not in place then create
    it with the given host

    CLI Example:

    .. code-block:: bash

        salt '*' hosts.add_host <ip> <alias>
775608
def add_host(ip, alias):
    '''
    
    '''
    hfn = _get_or_create_hostfile()
    if not os.path.isfile(hfn):
        return False

    if has_pair(ip, alias):
        return True

    hosts = _list_hosts()

    # Make sure future calls to _list_hosts() will re-read the file
    __context__.pop('hosts._list_hosts', None)

    inserted = False
    for i, h in six.iteritems(hosts):
        for j in range(len(h)):
            if h[j].startswith('#') and i == ip:
                h.insert(j, alias)
                inserted = True
    if not inserted:
        hosts.setdefault(ip, []).append(alias)
    _write_hosts(hosts)
    return True
615966
def hosts_append(hostsfile='/etc/hosts', ip_addr=None, entries=None):
    '''
    
    '''
    host_list = entries.split(',')
    hosts = parse_hosts(hostsfile=hostsfile)
    if ip_addr in hosts:
        for host in host_list:
            if host in hosts[ip_addr]:
                host_list.remove(host)

    if not host_list:
        return 'No additional hosts were added to {0}'.format(hostsfile)

    append_line = '\n{0} {1}'.format(ip_addr, ' '.join(host_list))
    with salt.utils.files.fopen(hostsfile, 'a') as fp_:
        fp_.write(salt.utils.stringutils.to_str(append_line))

    return 'The following line was added to {0}:{1}'.format(hostsfile,
                                                            append_line)
899238
def host(self, value):
        
        scheme, host, port = get_hostname_parameters_from_url(value)
        self._host = "%s://%s:%s" % (scheme, host, port)
511937
def configure_hosts!(hosts)
      @hosts_queue = Queue.new
      Array(hosts).each do |host|
        @hosts_queue.push(host)
      end
    end
456625
def add_host(self, host_id=None, host='localhost', port=6379,
                 unix_socket_path=None, db=0, password=None,
                 ssl=False, ssl_options=None):
        
        if host_id is None:
            raise RuntimeError('Host ID is required')
        elif not isinstance(host_id, (int, long)):
            raise ValueError('The host ID has to be an integer')
        host_id = int(host_id)
        with self._lock:
            if host_id in self.hosts:
                raise TypeError('Two hosts share the same host id (%r)' %
                                (host_id,))
            self.hosts[host_id] = HostInfo(host_id=host_id, host=host,
                                           port=port, db=db,
                                           unix_socket_path=unix_socket_path,
                                           password=password, ssl=ssl,
                                           ssl_options=ssl_options)
            self._hosts_age += 1
684562
def add(name, connection_uri, id_file="", o=[], config=None):
    
    storm_ = get_storm_instance(config)

    try:

        # validate name
        if '@' in name:
            raise ValueError('invalid value: "@" cannot be used in name.')

        user, host, port = parse(
            connection_uri,
            user=get_default("user", storm_.defaults),
            port=get_default("port", storm_.defaults)
        )

        storm_.add_entry(name, host, user, port, id_file, o)

        print(
            get_formatted_message(
                '{0} added to your ssh config. you can connect '
                'it by typing "ssh {0}".'.format(name),
            'success')
        )

    except ValueError as error:
        print(get_formatted_message(error, 'error'), file=sys.stderr)
        sys.exit(1)
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
14629
def add(self, host_value):
        
        host_obj = self._host_factory(host_value)
        if self._get_match(host_obj) is not None:
            return
        self._add_new(host_obj)
487536
def add(self, connection):
        ''''''
        key = (connection.host, connection.port)
        with self._lock:
            if key not in self._connections:
                self._connections[key] = connection
                self.added(connection)
                return connection
            else:
                return None
186439
def add(name,
        uid=None,
        gid=None,
        groups=None,
        home=None,
        shell=None,
        fullname=None,
        createhome=True,
        **kwargs):
    '''
    
    '''
    if info(name):
        raise CommandExecutionError('User \'{0}\' already exists'.format(name))

    if salt.utils.stringutils.contains_whitespace(name):
        raise SaltInvocationError('Username cannot contain whitespace')

    if uid is None:
        uid = _first_avail_uid()
    if gid is None:
        gid = 20  # gid 20 == 'staff', the default group
    if home is None:
        home = '/Users/{0}'.format(name)
    if shell is None:
        shell = '/bin/bash'
    if fullname is None:
        fullname = ''

    if not isinstance(uid, int):
        raise SaltInvocationError('uid must be an integer')
    if not isinstance(gid, int):
        raise SaltInvocationError('gid must be an integer')

    name_path = '/Users/{0}'.format(name)
    _dscl([name_path, 'UniqueID', uid])
    _dscl([name_path, 'PrimaryGroupID', gid])
    _dscl([name_path, 'UserShell', shell])
    _dscl([name_path, 'NFSHomeDirectory', home])
    _dscl([name_path, 'RealName', fullname])

    # Make sure home directory exists
    if createhome:
        __salt__['file.mkdir'](home, user=uid, group=gid)

    # dscl buffers changes, sleep before setting group membership
    time.sleep(1)
    if groups:
        chgroups(name, groups)
    return True
710280
def add_computer(self, ip, hostname, domain, os, dc=None):
        
        domain = domain.split('.')[0].upper()
        cur = self.conn.cursor()

        cur.execute('SELECT * FROM computers WHERE ip LIKE ?', [ip])
        results = cur.fetchall()

        if not len(results):
            cur.execute("INSERT INTO computers (ip, hostname, domain, os, dc) VALUES (?,?,?,?,?)", [ip, hostname, domain, os, dc])
        else:
            for host in results:
                if (hostname != host[2]) or (domain != host[3]) or (os != host[4]):
                    cur.execute("UPDATE computers SET hostname=?, domain=?, os=? WHERE id=?", [hostname, domain, os, host[0]])
                if dc != None and (dc != host[5]):
                    cur.execute("UPDATE computers SET dc=? WHERE id=?", [dc, host[0]])

        cur.close()

        return cur.lastrowid
1195019
def add_ip_to_net(networks, host):
    
    for network in networks:
        if host['ipaddr'] in network['network']:
            network['hosts'].append(host)
            return
540958
def update_host(name, data, **api_opts):
    '''
    
    '''
    o = get_host(name=name, **api_opts)
    return update_object(objref=o['_ref'], data=data, **api_opts)
598686
def do_add(argdict):
    ''''''
    site = make_site_obj(argdict)
    if not site.tree_ready:
        print "Cannot add page. You are not within a simplystatic \
tree and you didn't specify a directory."
        sys.exit()
    title = argdict['title']
    try: 
        new_page = site.add_page(title)
        new_page.write()
        print "Added page '"+ title + "'"
    except ValueError as e: # pragma: no cover
        print "Attempted to create a page which already exists."
        sys.exit()
75589
def add_host(self, ip, mac):
		
		msg = OmapiMessage.open(b"host")
		msg.message.append((b"create", struct.pack("!I", 1)))
		msg.message.append((b"exclusive", struct.pack("!I", 1)))
		msg.obj.append((b"hardware-address", pack_mac(mac)))
		msg.obj.append((b"hardware-type", struct.pack("!I", 1)))
		msg.obj.append((b"ip-address", pack_ip(ip)))
		response = self.query_server(msg)
		if response.opcode != OMAPI_OP_UPDATE:
			raise OmapiError("add failed")
874283
def add_host_supersede_name(self, ip, mac, name):  # pylint:disable=E0213
		
		msg = OmapiMessage.open(b"host")
		msg.message.append((b"create", struct.pack("!I", 1)))
		msg.message.append((b"exclusive", struct.pack("!I", 1)))
		msg.obj.append((b"hardware-address", pack_mac(mac)))
		msg.obj.append((b"hardware-type", struct.pack("!I", 1)))
		msg.obj.append((b"ip-address", pack_ip(ip)))
		msg.obj.append((b"name", name.encode('utf-8')))
		msg.obj.append((b"statements", 'supersede host-name "{0}";'.format(name).encode('utf-8')))
		response = self.query_server(msg)
		if response.opcode != OMAPI_OP_UPDATE:
			raise OmapiError("add failed")
508290
def add_host(zone, name, ttl, ip, keyname, keyfile, nameserver, timeout,
             port=53, keyalgorithm='hmac-md5'):
    '''
    
    '''
    res = []
    if zone in name:
        name = name.replace(zone, '').rstrip('.')
    fqdn = '{0}.{1}'.format(name, zone)

    ret = create(zone, name, ttl, 'A', ip, keyname, keyfile, nameserver,
                 timeout, port, keyalgorithm)
    res.append(ret[fqdn])

    parts = ip.split('.')[::-1]
    i = len(parts)
    popped = []

    # Iterate over possible reverse zones
    while i > 1:
        p = parts.pop(0)
        i -= 1
        popped.append(p)

        zone = '{0}.{1}'.format('.'.join(parts), 'in-addr.arpa.')
        name = '.'.join(popped)
        rev_fqdn = '{0}.{1}'.format(name, zone)
        ret = create(zone, name, ttl, 'PTR', "{0}.".format(fqdn), keyname,
                     keyfile, nameserver, timeout, port, keyalgorithm)

        if "Created" in ret[rev_fqdn]:
            res.append(ret[rev_fqdn])
            return {fqdn: res}

    res.append(ret[rev_fqdn])

    return {fqdn: res}