Check if this host has already been added to the database, if not add it in.
4150
def add_computer(self, ip, hostname, domain, os, instances):
        
        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, instances) VALUES (?,?,?,?,?)", [ip, hostname, domain, os, instances])

        cur.close()
650129
private void putForeignHost(int hostId, ForeignHost fh) {
        synchronized (m_mapLock) {
            m_foreignHosts = ImmutableMultimap.<Integer, ForeignHost>builder()
                    .putAll(m_foreignHosts)
                    .put(hostId, fh)
                    .build();
        }
    }
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
379613
public void addVirtualHost(String hostname)
    {
        // Note that null hosts are also added.
        if (!_vhosts.contains(hostname))
        {
            _vhosts.add(hostname);
            _contextName=null;

            if (_httpServer!=null)
            {
                if (_vhosts.size()==1)
                    _httpServer.removeMapping(null,this);
                _httpServer.addMapping(hostname,this);
            }
            _vhostsArray=null;
        }
    }
143038
def check(self, url_data):
        """"""
        location = get_location(url_data.host)
        if location:
            url_data.add_info(_("URL is located in %(location)s.") %
            {"location": _(location)})
892885
def present(name, character_set=None, collate=None, **connection_args):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'Database {0} is already present'.format(name)}
    # check if database exists
    existing = __salt__['mysql.db_get'](name, **connection_args)
    if existing:
        alter = False
        if character_set and character_set != existing.get('character_set'):
            log.debug('character set differes from %s : %s',
                      character_set, existing.get('character_set'))
            alter = True
        if collate and collate != existing.get('collate'):
            log.debug('collate set differs from %s : %s',
                      collate, existing.get('collate'))
            alter = True
        if alter:
            __salt__['mysql.alter_db'](
                name, character_set=character_set, collate=collate,
                **connection_args)
        current = __salt__['mysql.db_get'](name, **connection_args)
        if existing.get('collate', None) != current.get('collate', None):
            ret['changes'].update({'collate': {
                'before': existing.get('collate', None),
                'now': current.get('collate', None)}})
        if existing.get('character_set', None) != current.get('character_set', None):
            ret['changes'].update({'character_set': {
                'before': existing.get('character_set', None),
                'now': current.get('character_set', None)}})
        return ret
    else:
        err = _get_mysql_error()
        if err is not None:
            ret['comment'] = err
            ret['result'] = False
            return ret

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = ('Database {0} is not present and needs to be created'
                ).format(name)
        return ret
    # The database is not present, make it!
    if __salt__['mysql.db_create'](
            name, character_set=character_set, collate=collate,
            **connection_args):
        ret['comment'] = 'The database {0} has been created'.format(name)
        ret['changes'][name] = 'Present'
    else:
        ret['comment'] = 'Failed to create database {0}'.format(name)
        err = _get_mysql_error()
        if err is not None:
            ret['comment'] += ' ({0})'.format(err)
        ret['result'] = False

    return ret
1468
def _increment(self, what, host):
        '''  '''

        self.processed[host] = 1
        prev = (getattr(self, what)).get(host, 0)
        getattr(self, what)[host] = prev+1
774627
def add_hosts(self, hostIds):
    
    hostRefList = [ApiHostRef(self._get_resource_root(), x) for x in hostIds]
    return self._post("hosts", ApiHostRef, True, data=hostRefList,
        api_version=3)
1206803
def __check_existing(self, row):
        
        if self.__update_keys is not None:
            key = tuple(row[key] for key in self.__update_keys)
            if key in self.__bloom:
                return True
            self.__bloom.add(key)
            return False
        return False
762459
def add_if_unique(self, name):
        
        with self.lock:
            if name not in self.names:
                self.names.append(name)
                return True
        return False
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)
813124
public function hasOnUpdate()
    {
        $database = $this->getTable()->getDatabase();
        if($database instanceof Database &&
               $this->onUpdate === $database->getPlatform()->getDefaultFKOnUpdateBehavior()) {
          return false;
        }

        return ($this->onUpdate !== self::NONE);
    }
113416
def add_to_known_hosts(self, hosts, known_hosts=DEFAULT_KNOWN_HOSTS, dry=False):
        
        to_add = []
        with open(known_hosts) as fh:
            known_hosts_set = set(line.strip() for line in fh.readlines())

        cmd = ['ssh-keyscan'] + [host.hostname for host in hosts]
        logger.debug('Call: %s',  ' '.join(cmd))
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
        for line in stdout.splitlines():
            line = line.strip()
            logger.info('[%s] Add the remote host SSH public key to [%s]...', line.split(' ', 1)[0], known_hosts)
            if line not in known_hosts_set:
                known_hosts_set.add(line)
                to_add.append('{0}\n'.format(line))

        if not dry:
            with open(known_hosts, 'a') as fh:
                fh.writelines(to_add)
1172065
private function checkIfTableExist()
    {
        $sql = new SqlCommand();
        $sql->exeCommand("SHOW TABLES LIKE '" . PRE . $this->entity . "'");
        if (!$sql->getResult())
            new \EntityForm\EntityCreateEntityDatabase($this->entity, []);
    }
1051354
def add_to_inventory(self):
        """"""
        host = self.db_attrs.pop(A.database.HOST)
        self.stack.add_host(
                host,
                self.groups,
                self.db_attrs
                )
384746
protected function isDatabaseReady()
    {
        // Such as during setup of testsession prior to DB connection.
        if (!DB::is_active()) {
            return false;
        }

        // If we have a DB of the wrong type then complain
        if (!(DB::get_conn() instanceof MySQLDatabase)) {
            throw new Exception('HybridSessions\Store\DatabaseStore currently only works with MySQL databases');
        }

        // Prevent freakout during dev/build
        return ClassInfo::hasTable('HybridSessionDataObject');
    }
231743
def add(self, host, **kwargs):
        
        if host in self.hosts_:
            raise ValueError("Host %s: exists (use update)." % host)
        self.hosts_.add(host)
        self.lines_.append(ConfigLine(line="", host=None))
        self.lines_.append(ConfigLine(line="Host %s" % host, host=host, key="Host", value=host))
        for k, v in kwargs.items():
            if type(v) not in [list, tuple]:
                v = [v]
            mapped_k = _remap_key(k)
            for value in v:
                self.lines_.append(ConfigLine(line="  %s %s" % (mapped_k, str(value)), host=host, key=mapped_k, value=value))
        self.lines_.append(ConfigLine(line="", host=None))