// GetHostStatuses returns the memory usage and whether or not a host is active
346334
func (f *Facade) GetHostStatuses(ctx datastore.Context, hostIDs []string, since time.Time) ([]host.HostStatus, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetHostStatuses"))
	if hostIDs == nil {
		return []host.HostStatus{}, nil
	}

	statuses := []host.HostStatus{}
	for _, id := range hostIDs {
		h, err := f.GetHost(ctx, id)
		if err != nil {
			continue
		}

		status := host.HostStatus{HostID: id, HostName: h.Name, MemoryUsage: service.Usage{}}
		active, err := f.zzk.IsHostActive(h.PoolID, h.ID)
		if err != nil {
			continue
		}
		status.Active = active

		expired, _ := f.hostRegistry.IsExpired(h.ID)
		status.Authenticated = !expired

		instances, err := f.GetHostInstances(ctx, since, id)
		if err != nil {
			continue
		}

		for _, i := range instances {
			status.MemoryUsage.Cur += i.MemoryUsage.Cur
			status.MemoryUsage.Max += i.MemoryUsage.Max
			status.MemoryUsage.Avg += i.MemoryUsage.Avg
		}

		statuses = append(statuses, status)
	}

	return statuses, nil
}
304515
func (h *HostRegistryListener) GetRegisteredHosts(cancel <-chan interface{}) ([]host.Host, error) {
	logger := plog.WithField("poolid", h.poolid)

	var conn client.Connection
	if conn = h.conn; conn == nil {
		return nil, errors.New("connection is not initialized")
	}

	for {
		hosts, err := GetRegisteredHostsForPool(conn, h.poolid)
		if err != nil {
			return nil, err
		}

		if count := len(hosts); count > 0 {
			return hosts, nil
		}

		logger.Warn("No active hosts registered, waiting")

		select {
		case <-h.isOnline:
			logger.Info("At least one active host detected, checking")
		case <-cancel:
			return []host.Host{}, nil
		}
	}
}
342450
func (r Dns_Secondary) GetStatus() (resp datatypes.Dns_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Dns_Secondary", "getStatus", nil, &r.Options, &resp)
	return
}
1233615
func (_class HostCPUClass) GetAll(sessionID SessionRef) (_retval []HostCPURef, _err error) {
	_method := "host_cpu.get_all"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg)
	if _err != nil {
		return
	}
	_retval, _err = convertHostCPURefSetToGo(_method + " -> ", _result.Value)
	return
}
472602
func (bs *benchmarkServer) getStats(reset bool) *testpb.ServerStats {
	bs.mu.RLock()
	defer bs.mu.RUnlock()
	wallTimeElapsed := time.Since(bs.lastResetTime).Seconds()
	rusageLatest := syscall.GetRusage()
	uTimeElapsed, sTimeElapsed := syscall.CPUTimeDiff(bs.rusageLastReset, rusageLatest)

	if reset {
		bs.lastResetTime = time.Now()
		bs.rusageLastReset = rusageLatest
	}
	return &testpb.ServerStats{
		TimeElapsed: wallTimeElapsed,
		TimeUser:    uTimeElapsed,
		TimeSystem:  sTimeElapsed,
	}
}
890573
func getHostResources(hostStats *api.HostStats, node *api.Node) ([]string, error) {
	if hostStats == nil {
		return nil, fmt.Errorf("actual resource usage not present")
	}
	var resources []string

	// calculate disk usage
	storageDevice := node.Attributes["unique.storage.volume"]
	var diskUsed, diskSize uint64
	var physical bool
	for _, disk := range hostStats.DiskStats {
		if disk.Device == storageDevice {
			diskUsed = disk.Used
			diskSize = disk.Size
			physical = true
		}
	}

	resources = make([]string, 2)
	resources[0] = "CPU|Memory|Disk"
	if physical {
		resources[1] = fmt.Sprintf("%v/%d MHz|%s/%s|%s/%s",
			math.Floor(hostStats.CPUTicksConsumed),
			*node.Resources.CPU,
			humanize.IBytes(hostStats.Memory.Used),
			humanize.IBytes(hostStats.Memory.Total),
			humanize.IBytes(diskUsed),
			humanize.IBytes(diskSize),
		)
	} else {
		// If non-physical device are used, output device name only,
		// since nomad doesn't collect the stats data.
		resources[1] = fmt.Sprintf("%v/%d MHz|%s/%s|(%s)",
			math.Floor(hostStats.CPUTicksConsumed),
			*node.Resources.CPU,
			humanize.IBytes(hostStats.Memory.Used),
			humanize.IBytes(hostStats.Memory.Total),
			storageDevice,
		)
	}
	return resources, nil
}
742421
func NetworkHostPorts(hps []HostPort) []network.HostPort {
	nhps := make([]network.HostPort, len(hps))
	for i, hp := range hps {
		nhps[i] = hp.NetworkHostPort()
	}
	return nhps
}
158297
func (_m *ClientInterface) GetHost(hostID string) (*host.Host, error) {
	ret := _m.Called(hostID)

	var r0 *host.Host
	if rf, ok := ret.Get(0).(func(string) *host.Host); ok {
		r0 = rf(hostID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*host.Host)
		}
	}

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

	return r0, r1
}
155566
func (a *api) GetHosts() ([]host.Host, error) {
	client, err := a.connectMaster()
	if err != nil {
		return nil, err
	}

	return client.GetHosts()
}
117755
func (c *Client) ListVhosts() (rec []VhostInfo, err error) {
	req, err := newGETRequest(c, "vhosts")
	if err != nil {
		return []VhostInfo{}, err
	}

	if err = executeAndParseRequest(c, req, &rec); err != nil {
		return []VhostInfo{}, err
	}

	return rec, nil
}
965615
func GetStatus() *Statuses {
	result := &Statuses{}
	result.DeviceMapperStatusMap = make(map[string]*DeviceMapperStatus)
	result.SimpleStatusMap = make(map[string]*SimpleStatus)
	driverMap := getDrivers()
	for path, driver := range *driverMap {
		status, err := driver.Status()
		if err != nil {
			glog.Warningf("Error getting driver status for path %s: %v", path, err)
		}
		if status != nil {
			if driver.DriverType() == DriverTypeDeviceMapper {
				result.DeviceMapperStatusMap[path] = status.(*DeviceMapperStatus)
			} else {
				result.SimpleStatusMap[path] = status.(*SimpleStatus)
			}
		} else {
			glog.Warningf("nil status returned for path %s", path)
		}
	}
	return result
}
1305246
func RetrieveTicketStatusByHash(ctx context.Context, db *sql.DB, ticketHash string) (id uint64,
	spendStatus dbtypes.TicketSpendType, poolStatus dbtypes.TicketPoolStatus, err error) {
	err = db.QueryRowContext(ctx, internal.SelectTicketStatusByHash, ticketHash).
		Scan(&id, &spendStatus, &poolStatus)
	return
}
541060
func GetClusterStatus(client clientset.Interface) (*kubeadmapi.ClusterStatus, error) {
	configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
	if apierrors.IsNotFound(err) {
		return &kubeadmapi.ClusterStatus{}, nil
	}
	if err != nil {
		return nil, err
	}

	clusterStatus, err := UnmarshalClusterStatus(configMap.Data)
	if err != nil {
		return nil, err
	}

	return clusterStatus, nil
}
318582
func HostPortsToStrings(hps []HostPort) []string {
	result := make([]string, len(hps))
	for i, hp := range hps {
		result[i] = hp.NetAddr()
	}
	return result
}
603138
func (i *Import) GetStatus() string {
	if i == nil || i.Status == nil {
		return ""
	}
	return *i.Status
}
282703
func (ds *Datastore) GetDatastoreHostMounts(ctx context.Context) ([]types.ManagedObjectReference, error) {
	var dsMo mo.Datastore
	pc := property.DefaultCollector(ds.Client())
	err := pc.RetrieveOne(ctx, ds.Datastore.Reference(), []string{"host"}, &dsMo)
	if err != nil {
		klog.Errorf("Failed to retrieve datastore host mount property. err: %v", err)
		return nil, err
	}
	hosts := make([]types.ManagedObjectReference, len(dsMo.Host))
	for _, dsHostMount := range dsMo.Host {
		hosts = append(hosts, dsHostMount.Key)
	}
	return hosts, nil
}
408933
func (h *Hostsfile) readHosts() {
	file, err := os.Open(h.path)
	if err != nil {
		// We already log a warning if the file doesn't exist or can't be opened on setup. No need to return the error here.
		return
	}
	defer file.Close()

	stat, err := file.Stat()
	h.RLock()
	size := h.size
	h.RUnlock()
	if err == nil && h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
		return
	}

	newMap := h.parse(file)
	log.Debugf("Parsed hosts file into %d entries", newMap.Len())

	h.Lock()

	h.hmap = newMap
	// Update the data cache.
	h.mtime = stat.ModTime()
	h.size = stat.Size()

	h.Unlock()
}