// GET /servers/{id}/ips
553956
func (api *API) ListServerIps(server_id string) ([]ServerIp, error) {
	result := []ServerIp{}
	url := createUrl(api, serverPathSegment, server_id, "ips")
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	for index, _ := range result {
		result[index].api = api
	}
	return result, nil
}
1099863
func (vm *VM) GetIPs() ([]net.IP, error) {
	if err := SetupSession(vm); err != nil {
		return nil, err
	}
	defer func() {
		vm.client.Logout(vm.ctx)
		vm.cancel()
	}()

	// Get a reference to the datacenter with host and vm folders populated
	dcMo, err := GetDatacenter(vm)
	if err != nil {
		return nil, err
	}
	vmMo, err := findVM(vm, dcMo, vm.Name)
	if err != nil {
		return nil, err
	}
	// Lazy initialized when there is an IP address later.
	var ips []net.IP
	for _, nic := range vmMo.Guest.Net {
		for _, ip := range nic.IpAddress {
			netIP := net.ParseIP(ip)
			if netIP == nil {
				continue
			}
			if ips == nil {
				ips = make([]net.IP, 0, 1)
			}
			ips = append(ips, netIP)
		}
	}
	if ips == nil && vmMo.Guest.IpAddress != "" {
		ip := net.ParseIP(vmMo.Guest.IpAddress)
		if ip != nil {
			ips = append(ips, ip)
		}
	}
	return ips, nil
}
579555
func GetVMIPs(vm lvm.VirtualMachine, options ssh.Options) ([]net.IP, error) {
	ips := options.IPs
	if len(ips) == 0 {
		var err error
		ips, err = vm.GetIPs()
		if err != nil {
			return nil, fmt.Errorf("Error getting IPs for the VM: %s", err)
		}
		if len(ips) == 0 {
			return nil, lvm.ErrVMNoIP
		}
	}
	return ips, nil
}
1272419
func GetIPsFromGroup(group *api.ToGroups) ([]net.IP, error) {
	result := []net.IP{}
	if group.AWS == nil {
		return result, fmt.Errorf("no aws data available")
	}
	return getInstancesIpsFromFilter(group.AWS)
}
1366505
func (c *Client) GetAuthServers() ([]services.Server, error) {
	out, err := c.Get(c.Endpoint("authservers"), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var items []json.RawMessage
	if err := json.Unmarshal(out.Bytes(), &items); err != nil {
		return nil, trace.Wrap(err)
	}
	re := make([]services.Server, len(items))
	for i, raw := range items {
		server, err := services.GetServerMarshaler().UnmarshalServer(raw, services.KindAuthServer, services.SkipValidation())
		if err != nil {
			return nil, trace.Wrap(err)
		}
		re[i] = server
	}
	return re, nil
}
490494
func (s *IPServiceList) GetAllServices() ([]IPService, error) {
	services := s.Services
	t := s

	for t.HasNextPage() {
		var err error
		t, err = t.NextPage()
		if err != nil {
			return nil, err
		}
		services = append(services, t.Services...)
	}
	return services, nil
}
28610
func (m *MockServiceDiscovery) GetServers() []*cluster.Server {
	ret := m.ctrl.Call(m, "GetServers")
	ret0, _ := ret[0].([]*cluster.Server)
	return ret0
}
842180
func (api *API) GetServer(server_id string) (*Server, error) {
	result := new(Server)
	url := createUrl(api, serverPathSegment, server_id)
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	result.api = api
	result.decodeRaws()
	return result, 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
}
887943
func (vm *VM) GetIPs() ([]net.IP, error) {
	vm.waitUntilReady()

	return vm.ips, nil
}
339749
func (c *Client) GetDNSReverse(ctx context.Context, ip []net.IP) (map[string]*[]string, error) {
	ips := make([]string, 0)

	for _, ipAddress := range ip {
		ips = append(ips, ipAddress.String())
	}

	dnsReversed := make(map[string]*[]string)
	params := struct {
		IP string `url:"ips"`
	}{strings.Join(ips, ",")}

	req, err := c.NewRequest("GET", reversePath, params, nil)
	if err != nil {
		return nil, err
	}

	if err := c.Do(ctx, req, &dnsReversed); err != nil {
		return nil, err
	}

	return dnsReversed, nil
}
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
}
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
}
1342112
func (s *Server) GetPoolIPs(poolID string, reply *pool.PoolIPs) error {
	response, err := s.f.GetPoolIPs(s.context(), poolID)
	if err != nil {
		return err
	}
	if response == nil {
		return errors.New("pool not found")
	}
	*reply = *response
	return nil
}
524186
func (vm *VM) requestIPs() []net.IP {
	if vm.ipUpdate == nil {
		vm.ipUpdate = map[string]string{}
	}
	var ips []net.IP
	stdout, _, _ := runner.Run("guestproperty", "enumerate", vm.Name)
	for _, line := range strings.Split(stdout, "\n") {
		if match := ipLineRegexp.FindStringSubmatch(line); match != nil {
			if match := ipAddrRegexp.FindStringSubmatch(line); match != nil {
				ipString := strings.Split(match[0], ":")[1]
				ipString = strings.TrimSuffix(strings.TrimSpace(ipString), ", timestamp")
				if ip := net.ParseIP(ipString); ip != nil {
					ips = append(ips, ip)
					if match := timestampRegexp.FindStringSubmatch(line); match != nil {
						vm.ipUpdate[ipString] = match[0]
					}
				}
			}
		}
	}
	vm.ips = ips
	return ips
}
244523
func IPs() (IPRanges, error) {
	resp, err := http.Get(apiURL + "/ips")
	if err != nil {
		return IPRanges{}, errors.Wrap(err, "HTTP request failed")
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return IPRanges{}, errors.Wrap(err, "Response body could not be read")
	}
	var r IPsResponse
	err = json.Unmarshal(body, &r)
	if err != nil {
		return IPRanges{}, errors.Wrap(err, errUnmarshalError)
	}
	return r.Result, nil
}
873352
func (ip *Interpreter) getKeys(args []string) {
	list, err := ip.Backend.GetUserDataKeys(args[0])
	if err == nil {
		for _, key := range list {
			ip.Write(key)
		}
	}
	ip.simpleResponder(err)
}