// getServer gets the server IP to put in a provisioned PV's spec.
553164
func (p *nfsProvisioner) getServer() (string, error) {
	if p.outOfCluster {
		if p.serverHostname != "" {
			return p.serverHostname, nil
		}
		// TODO make this better
		out, err := exec.Command("hostname", "-i").Output()
		if err != nil {
			return "", fmt.Errorf("hostname -i failed with error: %v, output: %s", err, out)
		}
		addresses := strings.Fields(string(out))
		if len(addresses) > 0 {
			return addresses[0], nil
		}
		return "", fmt.Errorf("hostname -i had bad output %s, no address to use", string(out))
	}

	nodeName := os.Getenv(p.nodeEnv)
	if nodeName != "" {
		glog.Infof("using node name %s=%s as NFS server IP", p.nodeEnv, nodeName)
		return nodeName, nil
	}

	podIP := os.Getenv(p.podIPEnv)
	if podIP == "" {
		return "", fmt.Errorf("pod IP env %s must be set even if intent is to use service cluster IP as NFS server IP", p.podIPEnv)
	}

	serviceName := os.Getenv(p.serviceEnv)
	if serviceName == "" {
		glog.Infof("using potentially unstable pod IP %s=%s as NFS server IP (because neither service env %s nor node env %s are set)", p.podIPEnv, podIP, p.serviceEnv, p.nodeEnv)
		return podIP, nil
	}

	// Service env was set, now find and validate it
	namespace := os.Getenv(p.namespaceEnv)
	if namespace == "" {
		return "", fmt.Errorf("service env %s is set but namespace env %s isn't; no way to get the service cluster IP", p.serviceEnv, p.namespaceEnv)
	}
	service, err := p.client.CoreV1().Services(namespace).Get(serviceName, metav1.GetOptions{})
	if err != nil {
		return "", fmt.Errorf("error getting service %s=%s in namespace %s=%s", p.serviceEnv, serviceName, p.namespaceEnv, namespace)
	}

	// Do some validation of the service before provisioning useless volumes
	valid := false
	type endpointPort struct {
		port     int32
		protocol v1.Protocol
	}
	expectedPorts := map[endpointPort]bool{
		{2049, v1.ProtocolTCP}:  true,
		{20048, v1.ProtocolTCP}: true,
		{111, v1.ProtocolUDP}:   true,
		{111, v1.ProtocolTCP}:   true,
	}
	endpoints, err := p.client.CoreV1().Endpoints(namespace).Get(serviceName, metav1.GetOptions{})
	for _, subset := range endpoints.Subsets {
		// One service can't have multiple nfs-provisioner endpoints. If it had, kubernetes would round-robin
		// the request which would probably go to the wrong instance.
		if len(subset.Addresses) != 1 {
			continue
		}
		if subset.Addresses[0].IP != podIP {
			continue
		}
		actualPorts := make(map[endpointPort]bool)
		for _, port := range subset.Ports {
			actualPorts[endpointPort{port.Port, port.Protocol}] = true
		}
		if !reflect.DeepEqual(expectedPorts, actualPorts) {
			continue
		}
		valid = true
		break
	}
	if !valid {
		return "", fmt.Errorf("service %s=%s is not valid; check that it has for ports %v exactly one endpoint, this pod's IP %s=%s", p.serviceEnv, serviceName, expectedPorts, p.podIPEnv, podIP)
	}
	if service.Spec.ClusterIP == v1.ClusterIPNone {
		return "", fmt.Errorf("service %s=%s is valid but it doesn't have a cluster IP", p.serviceEnv, serviceName)
	}

	glog.Infof("using service %s=%s cluster IP %s as NFS server IP", p.serviceEnv, serviceName, service.Spec.ClusterIP)
	return service.Spec.ClusterIP, nil
}
28610
func (m *MockServiceDiscovery) GetServers() []*cluster.Server {
	ret := m.ctrl.Call(m, "GetServers")
	ret0, _ := ret[0].([]*cluster.Server)
	return ret0
}
153644
func getClient(ctx context.Context, client *http.Client, server string) (*MachineProvider, error) {
	mp, err := machine.New(client)
	if err != nil {
		return nil, err
	}
	mp.BasePath = server + "/_ah/api/machine/v1/"
	return &MachineProvider{client: mp}, nil
}
830356
func (wc *Wechat) GetServer(req *http.Request, writer http.ResponseWriter) *server.Server {
	wc.Context.Request = req
	wc.Context.Writer = writer
	return server.NewServer(wc.Context)
}
239389
func (vm *VM) GetIPs() ([]net.IP, error) {
	vmclient, err := vm.getVMClient()
	if err != nil {
		return nil, err
	}

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

	ips := make([]net.IP, 2)
	if ip := resp.VirtualIPs[0].Address; ip != "" {
		ips[PublicIP] = net.ParseIP(ip)
	}
	if ip := resp.RoleInstanceList[0].IPAddress; ip != "" {
		ips[PrivateIP] = net.ParseIP(ip)
	}

	return ips, nil
}
161170
func GetIP(daemonHost string) string {
	u, err := url.Parse(daemonHost)
	if err != nil {
		log.Errorf("[GetIP] GetIP %s failed %v", daemonHost, err)
		return ""
	}
	return u.Hostname()
}
71025
func (api *SwitchAPI) GetServers(switchID int64) ([]sacloud.Server, error) {
	var (
		method = "GET"
		uri    = fmt.Sprintf("%s/%d/server", api.getResourceURL(), switchID)
		res    = &sacloud.SearchResponse{}
	)
	err := api.baseAPI.request(method, uri, nil, res)
	if err != nil {
		return nil, err
	}
	return res.Servers, nil
}
1095584
func (runner *runner) GetRealServers(vs *VirtualServer) ([]*RealServer, error) {
	svc, err := toIPVSService(vs)
	if err != nil {
		return nil, err
	}
	runner.mu.Lock()
	dsts, err := runner.ipvsHandle.GetDestinations(svc)
	runner.mu.Unlock()
	if err != nil {
		return nil, err
	}
	rss := make([]*RealServer, 0)
	for _, dst := range dsts {
		dst, err := toRealServer(dst)
		// TODO: aggregate errors?
		if err != nil {
			return nil, err
		}
		rss = append(rss, dst)
	}
	return rss, nil
}
780673
func (svs *ServerVersionService) Get(ctx context.Context) (v *ServerVersion, resp *APIResponse, err error) {
	if cachedServerVersion != nil {
		return cachedServerVersion, nil, nil
	}

	v = &ServerVersion{}
	if _, resp, err = svs.client.getAction(ctx, &APIClientRequest{
		Path:         "version",
		ResponseBody: v,
		APIVersion:   apiV1,
	}); err != nil {
		return
	}

	err = v.parseVersion()

	cachedServerVersion = v

	return
}
396445
func (s *ConfigService) GetServerInfo() (*ServerInfo, *Response, error) {
	u := "config/server/info"

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new(ServerInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
20241
func (vm *VM) getClient() (management.Client, error) {
	mu.Lock()
	defer mu.Unlock()
	if client != nil {
		return client, nil
	}

	var err error
	client, err = management.ClientFromPublishSettingsFile(vm.PublishSettings, "")
	if err != nil {
		return nil, err
	}

	return client, nil
}
293787
func (w *Writer) getConn() serverConn {
	w.mu.RLock()
	conn := w.conn
	w.mu.RUnlock()
	return conn
}
749118
func (srv *Server) Get(params imageserver.Params) (*imageserver.Image, error) {
	enc, format, err := getEncoderFormat(srv.DefaultFormat, params)
	if err != nil {
		return nil, err
	}
	nim, err := srv.Provider.Get(params)
	if err != nil {
		return nil, err
	}
	im, err := encode(nim, format, enc, params)
	if err != nil {
		return nil, err
	}
	return im, nil
}
1029249
func (_class PVSSiteClass) GetServers(sessionID SessionRef, self PVSSiteRef) (_retval []PVSServerRef, _err error) {
	_method := "PVS_site.get_servers"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertPVSSiteRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertPVSServerRefSetToGo(_method + " -> ", _result.Value)
	return
}
1219044
func GetIP(code dhcp4.OptionCode, o dhcp4.Options) IP {
	v := o.Get(code)
	if v == nil {
		return nil
	}
	var ip IP
	if err := (&ip).UnmarshalBinary(v); err != nil {
		return nil
	}
	return ip
}
738796
func getIPAddrFromHostname() (ip string, err error) {
	output, err := exec.Command("hostname", "-i").Output()
	if err != nil {
		return ip, err
	}
	return strings.TrimSpace(string(output)), err
}
437192
func (srv *HandlerServer) Get(params Params) (*Image, error) {
	im, err := srv.Server.Get(params)
	if err != nil {
		return nil, err
	}
	im, err = srv.Handler.Handle(im, params)
	if err != nil {
		return nil, err
	}
	return im, nil
}