// Remove a host
500124
func (d *Driver) Remove() error {
	if err := d.verifyRootPermissions(); err != nil {
		return err
	}

	s, err := d.GetState()
	if err != nil || s == state.Error {
		log.Debugf("Error checking machine status: %v, assuming it has been removed already", err)
	}
	if s == state.Running {
		if err := d.Stop(); err != nil {
			return err
		}
	}
	return nil
}
315106
func (s *Set) Remove() error {
	// Remove the table
	_, err := s.host.db.Exec(fmt.Sprintf("DROP TABLE %s", s.table))
	return err
}
407784
func (h *Hostlist) RemoveDomain(domain string) int {
	return h.RemoveDomainV(domain, 4) + h.RemoveDomainV(domain, 6)
}
805114
func (_class HostPatchClass) Destroy(sessionID SessionRef, self HostPatchRef) (_err error) {
	_method := "host_patch.destroy"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertHostPatchRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg)
	return
}
955106
func (uvm *UtilityVM) RemoveSCSI(hostPath string) (err error) {
	op := "uvm::RemoveSCSI"
	log := logrus.WithFields(logrus.Fields{
		logfields.UVMID: uvm.id,
		"host-path":     hostPath,
	})
	log.Debug(op + " - Begin Operation")
	defer func() {
		if err != nil {
			log.Data[logrus.ErrorKey] = err
			log.Error(op + " - End Operation - Error")
		} else {
			log.Debug(op + " - End Operation - Success")
		}
	}()

	uvm.m.Lock()
	defer uvm.m.Unlock()

	if uvm.scsiControllerCount == 0 {
		return ErrNoSCSIControllers
	}

	// Make sure is actually attached
	controller, lun, uvmPath, err := uvm.findSCSIAttachment(hostPath)
	if err != nil {
		return err
	}

	if uvm.scsiLocations[controller][lun].isLayer {
		uvm.scsiLocations[controller][lun].refCount--
		if uvm.scsiLocations[controller][lun].refCount > 0 {
			return nil
		}
	}

	if err := uvm.removeSCSI(hostPath, uvmPath, controller, lun); err != nil {
		return fmt.Errorf("failed to remove SCSI disk %s from container %s: %s", hostPath, uvm.id, err)

	}
	return nil
}
267052
func (c *ServiceConfigs) Remove(name string) {
	c.mu.Lock()
	delete(c.m, name)
	c.mu.Unlock()
}
115474
func (_class HostClass) Destroy(sessionID SessionRef, self HostRef) (_err error) {
	_method := "host.destroy"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertHostRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg)
	return
}
563689
func (_m *FacadeInterface) RemoveHostExpiration(ctx datastore.Context, hostID string) {
	_m.Called(ctx, hostID)
}
1322295
func (pool *Pool) Remove(addr string) {
	pool.mutex.Lock()
	defer pool.mutex.Unlock()
	delete(pool.Clients, addr)
}
305891
func (c *Client) RemoveUser(name string) error {
	return c.delete(nil, "/user/"+name)
}
1110557
func removeHost(alias string) {
	conf, err := loadMcConfig()
	fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config version `"+globalMCConfigVersion+"`.")

	// Remove host.
	delete(conf.Hosts, alias)

	err = saveMcConfig(conf)
	fatalIf(err.Trace(alias), "Unable to save deleted hosts in config version `"+globalMCConfigVersion+"`.")

	printMsg(hostMessage{op: "remove", Alias: alias})
}
1256192
func RemoveHost(cancel <-chan struct{}, conn client.Connection, poolID, hostID string) error {
	basepth := ""
	if poolID != "" {
		basepth = path.Join("/pools", poolID)
	}
	pth := path.Join(basepth, "/hosts", hostID)

	logger := plog.WithFields(log.Fields{
		"hostid": hostID,
		"zkpath": pth,
	})

	// lock the host from scheduling
	mu, err := conn.NewLock(path.Join(pth, "locked"))
	if err != nil {
		logger.WithError(err).Debug("Could not instantiate scheduling lock")
		return err
	}
	if err := mu.Lock(); err != nil {
		logger.WithError(err).Debug("Could not lock host from scheduling")
		return err
	}
	defer mu.Unlock()

	// schedule all running states to stop
	done := make(chan struct{})
	defer func() { close(done) }()
	for {

		// clean any bad host states
		if err := CleanHostStates(conn, poolID, hostID); err != nil {
			return err
		}

		// get the list of states
		ch, ev, err := conn.ChildrenW(path.Join(pth, "instances"), done)
		if err != nil && err != client.ErrNoNode {
			logger.WithError(err).Debug("Could not watch instances for host")
			return err
		}

		for _, stateID := range ch {
			st8log := logger.WithField("stateid", stateID)

			_, serviceID, instanceID, err := ParseStateID(stateID)
			if err != nil {

				// This should never happen, but handle it
				st8log.WithError(err).Error("Invalid state id while monitoring host")
				return err
			}

			req := StateRequest{
				PoolID:     poolID,
				HostID:     hostID,
				ServiceID:  serviceID,
				InstanceID: instanceID,
			}

			// set the state to stopped if not already stopped
			if err := UpdateState(conn, req, func(s *State) bool {
				if s.DesiredState != service.SVCStop {
					s.DesiredState = service.SVCStop
					return true
				}
				return false
			}); err != nil {
				return err
			}
		}

		// if all the states have died, exit loop
		if len(ch) == 0 {
			break
		}

		// otherwise, wait for the number of states to change
		select {
		case <-ev:
		case <-cancel:
			logger.Debug("Delete was cancelled")
			return nil
		}
		close(done)
		done = make(chan struct{})
	}

	if err := removeHost(conn, poolID, hostID); err != nil {
		logger.WithError(err).Debug("Could not delete host entry from zookeeper")
		return err
	}

	logger.Debug("Deleted host entry from zookeeper")
	return nil
}
32416
func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error {
	req := types.RemoveVirtualSwitch{
		This:        o.Reference(),
		VswitchName: vswitchName,
	}

	_, err := methods.RemoveVirtualSwitch(ctx, o.c, &req)
	if err != nil {
		return err
	}

	return nil
}
1040645
func remove(path string) {
	err := os.Remove(path)
	if err != nil {
		fmt.Fprintf(os.Stderr, "could not remove %v: %v\n", path, err)
	}
}
1271961
func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) {
	logrus.Debugf("hcn::HostComputeLoadBalancer::RemoveEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id)

	err := loadBalancer.Delete()
	if err != nil {
		return nil, err
	}

	// Create a list of all the endpoints besides the one being removed
	var endpoints []string
	for _, endpointReference := range loadBalancer.HostComputeEndpoints {
		if endpointReference == endpoint.Id {
			continue
		}
		endpoints = append(endpoints, endpointReference)
	}
	loadBalancer.HostComputeEndpoints = endpoints
	return loadBalancer.Create()
}
1287415
func (vm *VM) Destroy() error {
	vmclient, err := vm.getVMClient()
	if err != nil {
		return fmt.Errorf(errGetClient, err)
	}

	reqID, err := vmclient.DeleteDeployment(vm.ServiceName, vm.Name)
	if err != nil {
		return err
	}

	// and wait for the deletion:
	if err := client.WaitForOperation(reqID, nil); err != nil {
		return fmt.Errorf("Error waiting for instance %s to be deleted off the hosted service %s: %s",
			vm.Name, vm.Name, err)
	}

	return vm.deleteHostedService()
}
270557
func (i *index) Remove(ctx context.Context) error {
	req, err := i.conn.NewRequest("DELETE", path.Join(i.relPath(), i.id))
	if err != nil {
		return WithStack(err)
	}
	resp, err := i.conn.Do(ctx, req)
	if err != nil {
		return WithStack(err)
	}
	if err := resp.CheckStatus(200); err != nil {
		return WithStack(err)
	}
	return nil
}