// countToDevices returns the list 0, 1, ... count-1 of deviceIDs.
347795
func countToDevices(count int) string {
	devices := make([]string, count)
	for i := range devices {
		devices[i] = strconv.Itoa(i)
	}
	return strings.Join(devices, ",")
}
454726
func (m *ManagerImpl) GetDevices(podUID, containerName string) []*podresourcesapi.ContainerDevices {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	return m.podDevices.getContainerDevices(podUID, containerName)
}
546168
func (s *CreateDeviceDefinitionVersionInput) SetDevices(v []*Device) *CreateDeviceDefinitionVersionInput {
	s.Devices = v
	return s
}
610278
func LocalDevices(ctx context.Context) (*types.LocalDevices, bool) {
	v, ok := ctx.Value(LocalDevicesKey).(*types.LocalDevices)
	return v, ok
}
1325889
func convertProtoDeviceGroups(in []*proto.DeviceGroup) []*DeviceGroup {
	if in == nil {
		return nil
	}

	out := make([]*DeviceGroup, len(in))
	for i, group := range in {
		out[i] = convertProtoDeviceGroup(group)
	}

	return out
}
755677
func infinibandDevices(infinibandPath string) ([]string, error) {
	devices, err := filepath.Glob(filepath.Join(infinibandPath, "/*"))
	if err != nil {
		return nil, err
	}

	if len(devices) < 1 {
		log.Debugf("Unable to detect InfiniBand devices")
		err = errInfinibandNoDevicesFound
		return nil, err
	}

	// Extract just the filenames which equate to the device names.
	for i, device := range devices {
		devices[i] = filepath.Base(device)
	}

	return devices, nil
}
869998
func (_m *DBClient) GetAllDeviceServices() ([]models.DeviceService, error) {
	ret := _m.Called()

	var r0 []models.DeviceService
	if rf, ok := ret.Get(0).(func() []models.DeviceService); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.DeviceService)
		}
	}

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

	return r0, r1
}
939480
func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
	logrus.Debugf("devmapper: AddDevice(hash=%s basehash=%s)", hash, baseHash)
	defer logrus.Debugf("devmapper: AddDevice(hash=%s basehash=%s) END", hash, baseHash)

	// If a deleted device exists, return error.
	baseInfo, err := devices.lookupDeviceWithLock(baseHash)
	if err != nil {
		return err
	}

	if baseInfo.Deleted {
		return fmt.Errorf("devmapper: Base device %v has been marked for deferred deletion", baseInfo.Hash)
	}

	baseInfo.lock.Lock()
	defer baseInfo.lock.Unlock()

	devices.Lock()
	defer devices.Unlock()

	// Also include deleted devices in case hash of new device is
	// same as one of the deleted devices.
	if info, _ := devices.lookupDevice(hash); info != nil {
		return fmt.Errorf("devmapper: device %s already exists. Deleted=%v", hash, info.Deleted)
	}

	if err := devices.createRegisterSnapDevice(hash, baseInfo); err != nil {
		return err
	}

	return nil
}
988237
func (c *Client) GetDevices() (devices []common.Device, err error) {
	return c.protocol.GetDevices()
}
209034
func (m *metadataTracker) Counts(dev protocol.DeviceID, flag uint32) Counts {
	if bits.OnesCount32(flag) > 1 {
		panic("incorrect usage: set at most one bit in flag")
	}

	m.mut.RLock()
	defer m.mut.RUnlock()

	idx, ok := m.indexes[metaKey{dev, flag}]
	if !ok {
		return Counts{}
	}

	return m.counts.Counts[idx]
}
155386
func convertStructDeviceGroupsStats(in []*DeviceGroupStats) []*proto.DeviceGroupStats {
	if in == nil {
		return nil
	}

	out := make([]*proto.DeviceGroupStats, len(in))
	for i, m := range in {
		out[i] = convertStructDeviceGroupStats(m)
	}

	return out
}
103135
func (devices *DeviceSet) registerDevice(id int, hash string, size uint64, transactionID uint64) (*devInfo, error) {
	logrus.Debugf("devmapper: registerDevice(%v, %v)", id, hash)
	info := &devInfo{
		Hash:          hash,
		DeviceID:      id,
		Size:          size,
		TransactionID: transactionID,
		Initialized:   false,
		devices:       devices,
	}

	devices.Devices[hash] = info

	if err := devices.saveMetadata(info); err != nil {
		// Try to remove unused device
		delete(devices.Devices, hash)
		return nil, err
	}

	return info, nil
}
481215
func (d *driver) LocalDevices(
	ctx types.Context,
	opts *types.LocalDevicesOpts) (*types.LocalDevices, error) {

	lvm, err := getLocalVolumeMap()
	if err != nil {
		return nil, err
	}

	return &types.LocalDevices{
		Driver:    scaleio.Name,
		DeviceMap: lvm,
	}, nil
}
1211147
func (d *driver) LocalDevices(
	ctx types.Context,
	opts *types.LocalDevicesOpts) (*types.LocalDevices, error) {

	ctx.WithFields(log.Fields{
		"vfs.root": d.rootDir,
		"dev.path": d.devFilePath,
	}).Debug("config info")

	var devFileRWL *sync.RWMutex
	func() {
		devFileLocksRWL.RLock()
		defer devFileLocksRWL.RUnlock()
		devFileRWL = devFileLocks[d.devFilePath]
	}()
	devFileRWL.Lock()
	defer devFileRWL.Unlock()

	if !gotil.FileExists(d.devFilePath) {
		return nil, goof.New("device file missing")
	}

	f, err := os.Open(d.devFilePath)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	localDevs := map[string]string{}

	scn := bufio.NewScanner(f)
	for {
		if !scn.Scan() {
			break
		}

		m := devRX.FindSubmatch(scn.Bytes())
		if len(m) == 0 {
			continue
		}

		dev := m[1]
		var mountPoint []byte
		if len(m) > 2 {
			mountPoint = m[2]
		}

		localDevs[string(dev)] = string(mountPoint)
	}

	return &types.LocalDevices{Driver: vfs.Name, DeviceMap: localDevs}, nil
}
260892
func (s deviceService) FetchDevices(opts ...DeviceRequestOption) (*DeviceResponse, error) {
	request := &deviceRequestOpts{}
	for _, option := range opts {
		if err := option(request); err != nil {
			return nil, err
		}
	}
	var response DeviceResponse
	req, err := s.client.NewRequest("POST", fetchDevicesPath, request)
	if err != nil {
		return nil, err
	}
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
661903
func deviceStatsToDatapoints(stats []IODeviceStats, prefix string, baseTags map[string]string, ts string) []producers.Datapoint {
	var datapoints []producers.Datapoint

	for _, stat := range stats {
		dev := devTotal
		if stat.Device.Major > 0 {
			dev = fmt.Sprintf("%d:%d", stat.Device.Major, stat.Device.Minor)
		}
		// Create a new tags map for these datapoints
		tags := map[string]string{blkioDevice: dev}
		for k, v := range baseTags {
			tags[k] = v
		}
		datapoints = append(datapoints, statValuesToDatapoints(stat.Serviced, prefix+"."+serviced, tags, ts)...)
		datapoints = append(datapoints, statValuesToDatapoints(stat.ServiceBytes, prefix+"."+serviceBytes, tags, ts)...)
		datapoints = append(datapoints, statValuesToDatapoints(stat.ServiceTime, prefix+"."+serviceTime, tags, ts)...)
		datapoints = append(datapoints, statValuesToDatapoints(stat.Merged, prefix+"."+merged, tags, ts)...)
		datapoints = append(datapoints, statValuesToDatapoints(stat.Queued, prefix+"."+queued, tags, ts)...)
		datapoints = append(datapoints, statValuesToDatapoints(stat.WaitTime, prefix+"."+waitTime, tags, ts)...)
	}

	return datapoints
}
205024
func convertProtoDevice(in *proto.DetectedDevice) *Device {
	if in == nil {
		return nil
	}

	return &Device{
		ID:         in.ID,
		Healthy:    in.Healthy,
		HealthDesc: in.HealthDescription,
		HwLocality: convertProtoDeviceLocality(in.HwLocality),
	}
}