// AddDevice saves device info to database.
511135
func (m *PoolMetadata) AddDevice(ctx context.Context, info *DeviceInfo) error {
	return m.db.Update(func(tx *bolt.Tx) error {
		devicesBucket := tx.Bucket(devicesBucketName)

		// Make sure device name is unique
		if err := getObject(devicesBucket, info.Name, nil); err == nil {
			return ErrAlreadyExists
		}

		// Find next available device ID
		deviceID, err := getNextDeviceID(tx)
		if err != nil {
			return err
		}

		info.DeviceID = deviceID

		return putObject(devicesBucket, info.Name, info, false)
	})
}
55677
func (s *DeviceSummary) SetDeviceId(v string) *DeviceSummary {
	s.DeviceId = &v
	return s
}
1194591
func (devices *DeviceSet) MountDevice(hash, path string, moptions graphdriver.MountOpts) error {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return err
	}

	if info.Deleted {
		return fmt.Errorf("devmapper: Can't mount device %v as it has been marked for deferred deletion", info.Hash)
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	devices.Lock()
	defer devices.Unlock()

	if err := devices.activateDeviceIfNeeded(info, false); err != nil {
		return fmt.Errorf("devmapper: Error activating devmapper device for '%s': %s", hash, err)
	}

	fstype, err := ProbeFsType(info.DevName())
	if err != nil {
		return err
	}

	options := ""

	if fstype == "xfs" {
		// XFS needs nouuid or it can't mount filesystems with the same fs
		options = joinMountOptions(options, "nouuid")
	}

	mountOptions := devices.mountOptions
	if len(moptions.Options) > 0 {
		addNouuid := strings.Contains("nouuid", mountOptions)
		mountOptions = strings.Join(moptions.Options, ",")
		if addNouuid {
			mountOptions = fmt.Sprintf("nouuid,%s", mountOptions)
		}
	}

	options = joinMountOptions(options, mountOptions)
	options = joinMountOptions(options, label.FormatMountLabel("", moptions.MountLabel))

	if err := mount.Mount(info.DevName(), path, fstype, options); err != nil {
		return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s\n%v", info.DevName(), path, err, string(dmesg.Dmesg(256)))
	}

	if fstype == "xfs" && devices.xfsNospaceRetries != "" {
		if err := devices.xfsSetNospaceRetries(info); err != nil {
			unix.Unmount(path, unix.MNT_DETACH)
			devices.deactivateDevice(info)
			return err
		}
	}

	return nil
}
862182
func AddDeviceToMulticastGroup(db sqlx.Execer, devEUI lorawan.EUI64, multicastGroupID uuid.UUID) error {
	_, err := db.Exec(`
		insert into device_multicast_group (
			dev_eui,
			multicast_group_id,
			created_at
		) values ($1, $2, $3)`,
		devEUI, multicastGroupID, time.Now())
	if err != nil {
		return handlePSQLError(err, "insert error")
	}

	log.WithFields(log.Fields{
		"dev_eui":            devEUI,
		"multicast_group_id": multicastGroupID,
	}).Info("device added to multicast-group")

	return nil
}
182599
func (s *Volume) SetDevice(v string) *Volume {
	s.Device = &v
	return s
}
1031107
func (g *Generator) AddDevice(device rspec.LinuxDevice) {
	g.initConfigLinux()

	for i, dev := range g.Config.Linux.Devices {
		if dev.Path == device.Path {
			g.Config.Linux.Devices[i] = device
			return
		}
		if dev.Type == device.Type && dev.Major == device.Major && dev.Minor == device.Minor {
			fmt.Fprintln(os.Stderr, "WARNING: The same type, major and minor should not be used for multiple devices.")
		}
	}

	g.Config.Linux.Devices = append(g.Config.Linux.Devices, device)
}
702302
func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
	info, err := devices.lookupDeviceWithLock(hash)
	if err != nil {
		return err
	}

	if info.Deleted {
		return fmt.Errorf("devmapper: Can't mount device %v as it has been marked for deferred deletion", info.Hash)
	}

	info.lock.Lock()
	defer info.lock.Unlock()

	devices.Lock()
	defer devices.Unlock()

	if err := devices.activateDeviceIfNeeded(info, false); err != nil {
		return fmt.Errorf("devmapper: Error activating devmapper device for '%s': %s", hash, err)
	}

	fstype, err := ProbeFsType(info.DevName())
	if err != nil {
		return err
	}

	options := ""

	if fstype == "xfs" {
		// XFS needs nouuid or it can't mount filesystems with the same fs
		options = joinMountOptions(options, "nouuid")
	}

	options = joinMountOptions(options, devices.mountOptions)
	options = joinMountOptions(options, label.FormatMountLabel("", mountLabel))

	if err := mount.Mount(info.DevName(), path, fstype, options); err != nil {
		return errors.Wrapf(err, "Failed to mount; dmesg: %s", string(dmesg.Dmesg(256)))
	}

	if fstype == "xfs" && devices.xfsNospaceRetries != "" {
		if err := devices.xfsSetNospaceRetries(info); err != nil {
			unix.Unmount(path, unix.MNT_DETACH)
			devices.deactivateDevice(info)
			return err
		}
	}

	return nil
}
396268
func (s *NuageVSPService) AddNuageVspDevice(p *AddNuageVspDeviceParams) (*AddNuageVspDeviceResponse, error) {
	resp, err := s.cs.newRequest("addNuageVspDevice", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r AddNuageVspDeviceResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1101120
func (a *attacherDefaults) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string, mounter mount.Interface) error {
	klog.Warning(logPrefix(a.plugin.flexVolumePlugin), "using default MountDevice for volume ", spec.Name(), ", device ", devicePath, ", deviceMountPath ", deviceMountPath)

	volSourceFSType, err := getFSType(spec)
	if err != nil {
		return err
	}

	readOnly, err := getReadOnly(spec)
	if err != nil {
		return err
	}

	options := make([]string, 0)

	if readOnly {
		options = append(options, "ro")
	} else {
		options = append(options, "rw")
	}

	diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: a.plugin.host.GetExec(a.plugin.GetPluginName())}

	return diskMounter.FormatAndMount(devicePath, deviceMountPath, volSourceFSType, options)
}
171812
func DefaultInputDevice() (*DeviceInfo, error) {
	devs, err := Devices()
	if err != nil {
		return nil, err
	}
	i := C.Pa_GetDefaultInputDevice()
	if i < 0 {
		return nil, newError(C.PaError(i))
	}
	return devs[i], nil
}
1210134
func (v VirtualMachine) AddDevice(ctx context.Context, device ...types.BaseVirtualDevice) error {
	return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationAdd, types.VirtualDeviceConfigSpecFileOperationCreate, device...)
}
56190
func (d *driver) NextDevice(
	ctx types.Context,
	opts types.Store) (string, error) {

	return "", types.ErrNotImplemented
}
994059
func (s *AdminUpdateDeviceStatusInput) SetDeviceKey(v string) *AdminUpdateDeviceStatusInput {
	s.DeviceKey = &v
	return s
}
1008392
func GetDevice(ordinal int) (device Device, err error) {
	Cordinal := C.int(ordinal)
	var Cdevice C.CUdevice
	err = result(C.cuDeviceGet(&Cdevice, Cordinal))
	device = Device(Cdevice)

	return
}
551820
func (o *Disk) SetDeviceName(v *string) *Disk {
	if o.DeviceName = v; o.DeviceName == nil {
		o.nullFields = append(o.nullFields, "DeviceName")
	}
	return o
}
249466
func (_m *DBClient) AddDeviceReport(dr models.DeviceReport) (string, error) {
	ret := _m.Called(dr)

	var r0 string
	if rf, ok := ret.Get(0).(func(models.DeviceReport) string); ok {
		r0 = rf(dr)
	} else {
		r0 = ret.Get(0).(string)
	}

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

	return r0, r1
}
913957
func (s *GetDeviceOutput) SetDevice(v *DeviceType) *GetDeviceOutput {
	s.Device = v
	return s
}