// LocalDevices returns a map of the system's local devices.
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
}
1152807
func (s *SharedStore) getLocalKeys() []Key {
	s.mutex.RLock()
	defer s.mutex.RUnlock()

	keys := make([]Key, len(s.localKeys))
	idx := 0
	for _, key := range s.localKeys {
		keys[idx] = key
		idx++
	}

	return keys
}
476360
func LocalDevices(
	ctx types.Context,
	opts *types.LocalDevicesOpts) (*types.LocalDevices, error) {

	f, err := os.Open(procPartitions)
	if err != nil {
		return nil, goof.WithError("error reading "+procPartitions, err)
	}
	defer f.Close()

	devMap := map[string]string{}

	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		fields := strings.Fields(scanner.Text())
		if len(fields) != 4 {
			continue
		}
		devName := fields[3]
		if !xvdRX.MatchString(devName) {
			continue
		}
		devPath := path.Join("/dev/", devName)
		devMap[devPath] = devPath
	}

	ld := &types.LocalDevices{Driver: fittedcloud.Name}
	if len(devMap) > 0 {
		ld.DeviceMap = devMap
	}

	return ld, nil
}
1284700
func makeDevices(opts *kubecontainer.RunContainerOptions) []*runtimeapi.Device {
	devices := make([]*runtimeapi.Device, len(opts.Devices))

	for idx := range opts.Devices {
		device := opts.Devices[idx]
		devices[idx] = &runtimeapi.Device{
			HostPath:      device.PathOnHost,
			ContainerPath: device.PathInContainer,
			Permissions:   device.Permissions,
		}
	}

	return devices
}
154835
func (st *State) AllLinkLayerDevices() (devices []*LinkLayerDevice, err error) {
	devicesCollection, closer := st.db().GetCollection(linkLayerDevicesC)
	defer closer()

	sdocs := []linkLayerDeviceDoc{}
	err = devicesCollection.Find(nil).All(&sdocs)
	if err != nil {
		return nil, errors.Errorf("cannot get all link layer devices")
	}
	for _, d := range sdocs {
		devices = append(devices, newLinkLayerDevice(st, d))
	}
	return devices, nil
}
561441
func (vm VirtualMachine) WalkDevices(f func(Device), types ...BusType) {
	p := func(d Device) bool { f(d); return false }
	vm.walkDevices(p, types...)
}
554304
func Devices() ([]*DeviceInfo, error) {
	_, devs, err := hostsAndDevices()
	if err != nil {
		return nil, err
	}
	return devs, nil
}
610278
func LocalDevices(ctx context.Context) (*types.LocalDevices, bool) {
	v, ok := ctx.Value(LocalDevicesKey).(*types.LocalDevices)
	return v, ok
}
1019146
func WithDevices(ids ...int) Opts {
	return func(c *config) error {
		for _, i := range ids {
			c.Devices = append(c.Devices, strconv.Itoa(i))
		}
		return nil
	}
}
1202914
func WithDeviceUUIDs(uuids ...string) Opts {
	return func(c *config) error {
		c.Devices = append(c.Devices, uuids...)
		return nil
	}
}
789599
func (d *driver) NextDevice(
	ctx types.Context,
	opts types.Store) (string, error) {
	// All possible device paths on Linux instances are /dev/sd[c-z]

	// Find which letters are used for local devices
	localDeviceNames := make(map[string]bool)

	localDevices, err := d.LocalDevices(
		ctx, &types.LocalDevicesOpts{Opts: opts})
	if err != nil {
		return "", goof.WithError("error getting local devices", err)
	}
	localDeviceMapping := localDevices.DeviceMap

	for localDevice := range localDeviceMapping {
		res := nextDevRe.FindStringSubmatch(localDevice)
		if len(res) > 0 {
			localDeviceNames[res[1]] = true
		}
	}

	// Find next available letter for device path
	for _, letter := range availLetters {
		if localDeviceNames[letter] {
			continue
		}
		return fmt.Sprintf(
			"/dev/%s%s", utils.NextDeviceInfo.Prefix, letter), nil
	}
	return "", errNoAvaiDevice
}
1081
func convertStructDevices(in []*Device) []*proto.DetectedDevice {
	if in == nil {
		return nil
	}

	out := make([]*proto.DetectedDevice, len(in))
	for i, d := range in {
		out[i] = convertStructDevice(d)
	}

	return out
}
1348610
func (pb *Pushbullet) GetDevices() ([]*responses.Device, error) {
	req, err := http.NewRequest("GET", ENDPOINT_DEVICES, nil)
	if err != nil {
		return nil, err
	}

	req.SetBasicAuth(pb.token, "")

	res, err := pb.client.Do(req)
	if err != nil {
		return nil, err
	}

	// TODO: Return an error value with human friendly message.
	if res.StatusCode != 200 {
		return nil, errors.New(res.Status)
	}

	var devices *devicesResponse

	decoder := json.NewDecoder(res.Body)
	if err := decoder.Decode(&devices); err != nil {
		return nil, err
	}

	return devices.Devices, nil
}
576063
func (_m *Protocol) GetDevices() ([]common.Device, error) {
	ret := _m.Called()

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

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

	return r0, r1
}
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
}
856686
func DevicesEquals(d1, d2 []*NodeDeviceResource) bool {
	if len(d1) != len(d2) {
		return false
	}
	idMap := make(map[DeviceIdTuple]*NodeDeviceResource, len(d1))
	for _, d := range d1 {
		idMap[*d.ID()] = d
	}
	for _, otherD := range d2 {
		if d, ok := idMap[*otherD.ID()]; !ok || !d.Equals(otherD) {
			return false
		}
	}

	return true
}
515495
func (p *V2) GetDevices() ([]common.Device, error) {
	p.RLock()
	defer p.RUnlock()
	if len(p.devices) == 0 {
		return nil, common.ErrNotFound
	}
	devices := make([]common.Device, len(p.devices))
	i := 0
	for _, device := range p.devices {
		devices[i] = device
		i++
	}

	return devices, nil
}