Remove a host from the known_hosts file
971166
def remove_sshkey(host, known_hosts=None):
    '''
    
    '''
    if known_hosts is None:
        if 'HOME' in os.environ:
            known_hosts = '{0}/.ssh/known_hosts'.format(os.environ['HOME'])
        else:
            try:
                known_hosts = '{0}/.ssh/known_hosts'.format(
                    pwd.getpwuid(os.getuid()).pwd_dir
                )
            except Exception:
                pass

    if known_hosts is not None:
        log.debug(
            'Removing ssh key for %s from known hosts file %s',
            host, known_hosts
        )
    else:
        log.debug('Removing ssh key for %s from known hosts file', host)

    cmd = 'ssh-keygen -R {0}'.format(host)
    subprocess.call(cmd, shell=True)
882906
def remove_server(self, name):
        """"""
        for i in self._server_list:
            if i['key'] == name:
                try:
                    self._server_list.remove(i)
                    logger.debug("Remove server %s from the list" % name)
                    logger.debug("Updated servers list (%s servers): %s" % (
                        len(self._server_list), self._server_list))
                except ValueError:
                    logger.error(
                        "Cannot remove server %s from the list" % name)
341476
def remove(self):
        '''
        
        '''
        print 'remove'
        if self.exists():
            print 'cleaning', self.venv
            run('rm -rf {}'.format(self.venv))
10923
private void removeForeignHost(final int hostId) {
        ImmutableCollection<ForeignHost> fhs = m_foreignHosts.get(hostId);
        synchronized (m_mapLock) {
            m_foreignHosts = ImmutableMultimap.<Integer, ForeignHost>builder()
                    .putAll(Multimaps.filterKeys(m_foreignHosts, not(equalTo(hostId))))
                    .build();

            Predicate<Long> hostIdNotEqual = new Predicate<Long>() {
                @Override
                public boolean apply(Long intput) {
                    return CoreUtils.getHostIdFromHSId(intput) != hostId;
                }
            };

            m_fhMapping = ImmutableMap.<Long, ForeignHost>builder()
                    .putAll(Maps.filterKeys(m_fhMapping, hostIdNotEqual))
                    .build();
        }
        assert(Thread.holdsLock(this)); // Make sure m_zombieForeignHosts is protected
        ArrayList<ForeignHost> picoNetworkZombies = m_picoZombieForeignHosts.get(hostId);
        ArrayList<ForeignHost> zookeeperZombies = new ArrayList<>(fhs.size());
        for (ForeignHost fh : fhs) {
            if (picoNetworkZombies != null && picoNetworkZombies.contains(fh)) {
                picoNetworkZombies.remove(fh);
            }
            else {
                zookeeperZombies.add(fh);
            }
            fh.close();
        }
        if (picoNetworkZombies != null && picoNetworkZombies.isEmpty()) {
            m_picoZombieForeignHosts.remove(hostId);
        }
        if (!zookeeperZombies.isEmpty()) {
            m_zkZombieForeignHosts.put(hostId, zookeeperZombies);
        }
    }
405495
def remove_exclusion(host_or_ip)
      asset = host_or_ip
      unless host_or_ip.respond_to?(:host) || host_or_ip.respond_to?(:from)
        # Attept to convert String to appropriate object.
        asset = HostOrIP.convert(host_or_ip)
      end
      @asset_exclusions = asset_exclusions.reject { |a| a.eql? asset }
    end
1134166
def stop_host(self, config_file):
        
        res = self.send_json_request('host/stop', data={'config': config_file})

        if res.status_code != 200:
            raise UnexpectedResponse(
                'Attempted to stop a JSHost. Response: {res_code}: {res_text}'.format(
                    res_code=res.status_code,
                    res_text=res.text,
                )
            )

        return res.json()
498796
def atlasdb_remove_peer( peer_hostport, con=None, path=None, peer_table=None ):
    
    # remove from db
    with AtlasDBOpen(con=con, path=path) as dbcon:

        log.debug("Delete peer '%s'" % peer_hostport)

        sql = "DELETE FROM peers WHERE peer_hostport = ?;"
        args = (peer_hostport,)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )
        dbcon.commit()

    # remove from the peer table as well
    with AtlasPeerTableLocked(peer_table) as ptbl:

        if ptbl.has_key(peer_hostport):
            if not atlas_peer_is_whitelisted( peer_hostport, peer_table=ptbl ) and not atlas_peer_is_blacklisted( peer_hostport, peer_table=ptbl ):
                del ptbl[peer_hostport]

    return True
491987
public function removeHost($host)
    {
        $ips = $this->getIp($host);
        unset($this->hosts[$host]);
        foreach ($ips as $ip) {
            unset($this->ips[$ip][$host]);
        }
    }
488866
def hosting_devices_removed(self, context, payload):
        """"""
        try:
            if payload['hosting_data']:
                if payload['hosting_data'].keys():
                    self.process_services(removed_devices_info=payload)
        except KeyError as e:
            LOG.error("Invalid payload format for received RPC message "
                      "`hosting_devices_removed`. Error is %(error)s. Payload "
                      "is %(payload)s", {'error': e, 'payload': payload})
333210
public function remove($host)
    {
        $this->validHost($host);

        if (!$this->check($host)) {
            throw new \RuntimeException('Host does not exists in the file');
        }

        $this->backup();

        $tmpFilePath = $this->filepath.'.tmp';

        $tmpFile = new \SplFileObject($tmpFilePath, 'w+');

        $this->file->rewind();

        while (!$this->file->eof()) {
            $pattern = '/\b'.$host.'\b/i';
            if (!preg_match($pattern, $this->file->current())) {
                $tmpFile->fwrite($this->file->current());
            }
            $this->file->next();
        }

        copy($tmpFilePath, $this->filepath);
        unlink($tmpFilePath);

        return true;
    }
655072
def remove_host(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The remove_host function must be called with '
            '-f or --function.'
        )

    host_name = kwargs.get('host') if kwargs and 'host' in kwargs else None

    if not host_name:
        raise SaltCloudSystemExit(
            'You must specify name of the host system.'
        )

    # Get the service instance
    si = _get_si()

    host_ref = salt.utils.vmware.get_mor_by_property(si, vim.HostSystem, host_name)
    if not host_ref:
        raise SaltCloudSystemExit(
            'Specified host system does not exist.'
        )

    try:
        if isinstance(host_ref.parent, vim.ClusterComputeResource):
            # This is a host system that is part of a Cluster
            task = host_ref.Destroy_Task()
        else:
            # This is a standalone host system
            task = host_ref.parent.Destroy_Task()
        salt.utils.vmware.wait_for_task(task, host_name, 'remove host', log_level='info')
    except Exception as exc:
        log.error(
            'Error while removing host %s: %s',
            host_name, exc,
            # Show the traceback if the debug logging level is enabled
            exc_info_on_loglevel=logging.DEBUG
        )
        return {host_name: 'failed to remove host'}

    return {host_name: 'removed host from vcenter'}
687894
def del_results_for_stopped_hosts(self, scan_id):
        
        unfinished_hosts = self.get_hosts_unfinished(scan_id)
        for result in self.results_iterator(scan_id, False):
            if result['host'] in unfinished_hosts:
                self.remove_single_result(scan_id, result)
1077192
public static void removeHost(String hostName) throws Exception {
        changeHost(hostName, false, false, true, false, false);
    }
1219077
def remove(alias_name, options)
      file = File.open(FILE_PATH, 'r')
      servers = all_hosts_in(file)
      if servers.include?alias_name
        new_file = File.open(FILE_PATH + 'temp', 'w')
        remove_alias_name(alias_name, file, new_file)

        File.delete(FILE_PATH)
        File.rename(FILE_PATH + 'temp', FILE_PATH)
        # Causes a bug in fedore if permission was not updated to 0600
        File.chmod(0600, FILE_PATH)
        PRINTER.print "`#{alias_name}` was successfully removed from your hosts"
      else
        PRINTER.print "Could not find host `#{alias_name}`"
      end
      finish_exec
    end
626622
def remove_host_mapping(interface, nexus_ip):
    """"""

    LOG.debug("remove_host_mapping() called")
    session = bc.get_writer_session()
    try:
        mapping = _lookup_one_host_mapping(
                      session=session,
                      if_id=interface,
                      switch_ip=nexus_ip)
        session.delete(mapping)
        session.flush()
    except c_exc.NexusHostMappingNotFound:
        pass
1128957
def delete(self, virtual_host):
        
        virtual_host = quote(virtual_host, '')
        return self.http_client.delete(API_VIRTUAL_HOST % virtual_host)
163452
def delete_hosting_device_resources(self, context, tenant_id, mgmt_port,
                                        **kwargs):
        """"""

        if mgmt_port is not None:
            try:
                self._cleanup_hosting_port(context, mgmt_port['id'])
            except n_exc.NeutronException as e:
                LOG.error("Unable to delete port:%(port)s after %(tries)d"
                          " attempts due to exception %(exception)s. "
                          "Skipping it", {'port': mgmt_port['id'],
                                          'tries': DELETION_ATTEMPTS,
                                          'exception': str(e)})