// GetPoolIPs provides a mock function with given fields: poolID
343083
func (_m *ClientInterface) GetPoolIPs(poolID string) (*pool.PoolIPs, error) {
	ret := _m.Called(poolID)

	var r0 *pool.PoolIPs
	if rf, ok := ret.Get(0).(func(string) *pool.PoolIPs); ok {
		r0 = rf(poolID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*pool.PoolIPs)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(poolID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
908638
func (r *Service) GetKeys(prefix string) ([]string, error) {
	c := r.pool.Get()
	defer c.Close()
	if err := c.Err(); err != nil {
		return nil, err
	}

	return r.getKeysConn(c, prefix)
}
539858
func (c *channelPool) getConns() chan *idleConn {
	c.mu.Lock()
	conns := c.conns
	c.mu.Unlock()
	return conns
}
1092100
func getIPResources(hostID string, hostIP string, staticIPs ...string) ([]HostIPResource, error) {

	//make a map of all ipaddresses to interface
	ifacemap, err := getInterfaceMap()
	if err != nil {
		return nil, err
	}
	hostLogger := plog.WithFields(log.Fields{
		"hostid": hostID,
		"hostip": hostIP,
	})
	hostLogger.WithFields(log.Fields{
		"interfaces": ifacemap,
	}).Debug("Interfaces on this host")

	// Get a unique list of ips from staticIPs and hostIP.
	ips := func() []string {
		for _, ip := range staticIPs {
			if hostIP == ip {
				return staticIPs
			}
		}
		return append(staticIPs, hostIP)
	}()

	hostIPResources := make([]HostIPResource, len(ips))
	for i, ip := range ips {
		hostLogger.WithFields(log.Fields{
			"ip": ip,
		}).Debug("Checking IP")
		if iface, ok := ifacemap[ip]; ok {
			if isLoopBack(ip) {
				return nil, IsLoopbackError(ip)
			}
			hostIPResource := HostIPResource{
				HostID:        hostID,
				IPAddress:     ip,
				InterfaceName: iface.Name,
				MACAddress:    iface.HardwareAddr.String(),
			}
			hostIPResources[i] = hostIPResource
		} else {
			return nil, InvalidIPAddress(ip)
		}
	}

	return hostIPResources, nil
}
75809
func (f *Facade) HasIP(ctx datastore.Context, poolID string, ipAddr string) (bool, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.HasIP"))
	if exists, err := f.poolStore.HasVirtualIP(ctx, poolID, ipAddr); err != nil {
		glog.Errorf("Could not look up ip %s for pool %s: %s", ipAddr, poolID, err)
		return false, err
	} else if exists {
		return true, nil
	}

	if host, err := f.GetHostByIP(ctx, ipAddr); err != nil {
		glog.Errorf("Could not look up static host by ip %s: %s", ipAddr, err)
		return false, err
	} else if host != nil && host.PoolID == poolID {
		return true, nil
	}

	return false, nil
}
190222
func (svc *googleService) getIPs() ([]net.IP, error) {
	instance, err := svc.service.Instances.Get(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
	if err != nil {
		return nil, err
	}

	ips := make([]net.IP, 2)
	nic := instance.NetworkInterfaces[0]

	publicIP := nic.AccessConfigs[0].NatIP
	if publicIP == "" {
		return nil, errors.New("error while retrieving public IP")
	}

	privateIP := nic.NetworkIP
	if privateIP == "" {
		return nil, errors.New("error while retrieving private IP")
	}

	ips[PublicIP] = net.ParseIP(publicIP)
	ips[PrivateIP] = net.ParseIP(privateIP)

	return ips, nil
}
874429
func (c *Client) FindHostsInPool(poolID string) ([]host.Host, error) {
	response := make([]host.Host, 0)
	if err := c.call("FindHostsInPool", poolID, &response); err != nil {
		return []host.Host{}, err
	}
	return response, nil
}
648994
func (b *BigIP) Pools() (*Pools, error) {
	var pools Pools
	err, _ := b.getForEntity(&pools, uriLtm, uriPool)
	if err != nil {
		return nil, err
	}

	return &pools, nil
}
916862
func GetLocalIPs() ([]*net.IP, error) {
	hostname, err := os.Hostname()
	if err != nil {
		return nil, errors.Wrap(err, "Failed to lookup hostname")
	}
	// Resolves IP Address from Hostname, this way overrides in /etc/hosts
	// can work too for IP resolution.
	ipInfo, err := net.ResolveIPAddr("ip4", hostname)
	if err != nil {
		return nil, errors.Wrap(err, "Failed to resolve ip")
	}
	ips := []*net.IP{&ipInfo.IP}

	// TODO(zviad): Is rest of the code really necessary?
	addrs, err := net.InterfaceAddrs()
	if err != nil {
		return nil, errors.Wrap(err, "Failed to get interface addresses.")
	}
	for _, addr := range addrs {
		ipnet, ok := addr.(*net.IPNet)
		if !ok {
			continue
		}

		if ipnet.IP.IsLoopback() {
			continue
		}

		ips = append(ips, &ipnet.IP)
	}
	return ips, nil
}
960344
func (pool *AddressBasedPool) GetConn(addr string) (IOSession, error) {
	conn := pool.getConnLocked(addr)
	if err := pool.checkConnect(addr, conn); err != nil {
		return nil, err
	}

	return conn, nil
}
346894
func getHostsForPool(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
	poolID, err := url.QueryUnescape(r.PathParam("poolId"))
	if err != nil {
		writeJSON(w, err, http.StatusBadRequest)
		return
	} else if len(poolID) == 0 {
		writeJSON(w, "poolId must be specified", http.StatusBadRequest)
		return
	}

	facade := ctx.getFacade()
	dataCtx := ctx.getDatastoreContext()

	hosts, err := facade.FindReadHostsInPool(dataCtx, poolID)
	if err != nil {
		restServerError(w, err)
		return
	}

	w.WriteJson(hosts)
}
167058
func (vm *VM) GetIPs() ([]net.IP, error) {
	server, err := getServer(vm)
	if server == nil || err != nil {
		// Probably need to call Provision first.
		return nil, err
	}

	client, err := getNetworkClient(vm)
	if client == nil || err != nil {
		// Probably need to create some network first.
		return nil, err
	}
	ips := make([]net.IP, 2)
	for _, networkID := range vm.Networks {
		network, err := networks.Get(client, networkID).Extract()
		if err != nil {
			return nil, err
		}

		addressSlice := server.Addresses[network.Name].([]interface{})
		for _, addressElement := range addressSlice {
			addressBlock := addressElement.(map[string]interface{})
			ipType := addressBlock["OS-EXT-IPS:type"].(string)
			ip := addressBlock["addr"].(string)
			if ipType == "floating" {
				ips[PublicIP] = net.ParseIP(ip)
			}
			if ipType == "fixed" {
				ips[PrivateIP] = net.ParseIP(ip)
			}
		}
	}

	return ips, nil
}
1073660
func (_m *FacadeInterface) FindHostsInPool(ctx datastore.Context, poolID string) ([]host.Host, error) {
	ret := _m.Called(ctx, poolID)

	var r0 []host.Host
	if rf, ok := ret.Get(0).(func(datastore.Context, string) []host.Host); ok {
		r0 = rf(ctx, poolID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]host.Host)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, string) error); ok {
		r1 = rf(ctx, poolID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1116670
func GetIPs(code dhcp4.OptionCode, o dhcp4.Options) IPs {
	v := o.Get(code)
	if v == nil {
		return nil
	}

	var i IPs
	if err := i.UnmarshalBinary(v); err != nil {
		return nil
	}
	return i
}
273523
func (l *Limiter) GetIPLookups() []string {
	l.RLock()
	defer l.RUnlock()
	return l.ipLookups
}
805981
func (p *Pool) getPool(addr string) *redis.Pool {

	defer scopedLock(&p.mutx)()

	pool, found := p.pools[addr]
	if !found {
		pool = redis.NewPool(func() (redis.Conn, error) {
			return p.dialFunc(addr)
		}, maxIdle)

		pool.TestOnBorrow = func(c redis.Conn, t time.Time) error {

			// for testing - count how many borrows we did
			atomic.AddInt64(&p.numBorrowed, 1)
			if time.Since(t) > testOnBorrowInterval {
				_, err := c.Do("PING")
				return err
			}
			return nil
		}

		p.pools[addr] = pool
	}

	return pool

}
640735
func (zk *zkf) GetServiceStateIDs(poolID, serviceID string) ([]zks.StateRequest, error) {
	logger := plog.WithFields(log.Fields{
		"poolid":    poolID,
		"serviceid": serviceID,
	})

	// get the root-based connection to look up the state ids for a service
	conn, err := zzk.GetLocalConnection("/")
	if err != nil {
		logger.WithError(err).Debug("Could not acquire root-based connection")
		return nil, err
	}

	return zks.GetServiceStateIDs(conn, poolID, serviceID)
}