// NewMissingLocalDevicesError returns a new ErrMissingLocalDevices error.
771172
func NewMissingLocalDevicesError(service string) error {
	return &types.ErrMissingLocalDevices{
		Goof: goof.WithField("service", service, "missing local devices"),
	}
}
235847
func convertStructDeviceLocality(in *DeviceLocality) *proto.DeviceLocality {
	if in == nil {
		return nil
	}

	return &proto.DeviceLocality{
		PciBusId: in.PciBusID,
	}
}
1214770
func NewMissingInstanceIDError(service string) error {
	return &types.ErrMissingInstanceID{
		Goof: goof.WithField("service", service, "missing instance ID"),
	}
}
833774
func (this *FcmClient) newDevicesList(list []string) *FcmClient {
	this.Message.RegistrationIds = make([]string, len(list))
	copy(this.Message.RegistrationIds, list)

	return this

}
1176621
func (bc *BuildController) findMissingPod(build *buildv1.Build) *corev1.Pod {
	// Make one last attempt to fetch the pod using the REST client
	pod, err := bc.podClient.Pods(build.Namespace).Get(buildapihelpers.GetBuildPodName(build), metav1.GetOptions{})
	if err == nil {
		klog.V(2).Infof("Found missing pod for build %s by using direct client.", buildDesc(build))
		return pod
	}
	return nil
}
19137
func (d *Discoverer) DiscoverLocalVolumes() {
	for class, config := range d.DiscoveryMap {
		d.discoverVolumesAtPath(class, config)
	}
}
753572
func buildEphemeralDevices(cloud awsup.AWSCloud, machineType string) (map[string]*BlockDeviceMapping, error) {
	mt, err := awsup.GetMachineTypeInfo(machineType)
	if err != nil {
		return nil, fmt.Errorf("failed to find instance type details on: %s, error: %s", machineType, err)
	}

	blockDeviceMappings := make(map[string]*BlockDeviceMapping)

	for _, ed := range mt.EphemeralDevices() {
		blockDeviceMappings[ed.DeviceName] = &BlockDeviceMapping{VirtualName: fi.String(ed.VirtualName)}
	}

	return blockDeviceMappings, nil
}
989085
func convertProtoDeviceLocality(in *proto.DeviceLocality) *DeviceLocality {
	if in == nil {
		return nil
	}

	return &DeviceLocality{
		PciBusID: in.PciBusId,
	}
}
109386
func (dp *MockStaticDiscoveryProvider) CreateLocalDiscoveryService(mspID string) (fab.DiscoveryService, error) {
	return &MockStaticDiscoveryService{Error: dp.Error, Peers: dp.Peers}, nil
}
1299942
func NewEmmErrorDetails(ErrorDetails *FailureDetailsLogInfo) *EmmErrorDetails {
	s := new(EmmErrorDetails)
	s.ErrorDetails = ErrorDetails
	return s
}
610278
func LocalDevices(ctx context.Context) (*types.LocalDevices, bool) {
	v, ok := ctx.Value(LocalDevicesKey).(*types.LocalDevices)
	return v, ok
}
352736
func (n *NetworkServerAPI) AddDeviceToMulticastGroup(ctx context.Context, req *ns.AddDeviceToMulticastGroupRequest) (*empty.Empty, error) {
	var devEUI lorawan.EUI64
	var mgID uuid.UUID
	copy(devEUI[:], req.DevEui)
	copy(mgID[:], req.MulticastGroupId)

	if err := storage.AddDeviceToMulticastGroup(storage.DB(), devEUI, mgID); err != nil {
		return nil, errToRPCError(err)
	}

	return &empty.Empty{}, nil
}
936237
func NewEmmAddExceptionType(Description string) *EmmAddExceptionType {
	s := new(EmmAddExceptionType)
	s.Description = Description
	return s
}
417101
func NewMockLocalContext(client *MockContext, discoveryProvider fab.LocalDiscoveryProvider) *LocalContext {
	var localDiscovery fab.DiscoveryService
	if discoveryProvider != nil {
		var err error
		localDiscovery, err = discoveryProvider.CreateLocalDiscoveryService(client.Identifier().MSPID)
		if err != nil {
			panic(fmt.Sprintf("error creating local discovery service: %s", err))
		}

	}

	return &LocalContext{
		MockContext:    client,
		localDiscovery: localDiscovery,
	}
}
505081
func NewLocal(clientProvider context.ClientProvider) (*Local, error) {
	client, err := clientProvider()
	if err != nil {
		return nil, errors.WithMessage(err, "failed to get client context to create local context")
	}

	discoveryService, err := client.LocalDiscoveryProvider().CreateLocalDiscoveryService(client.Identifier().MSPID)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create local discovery service")
	}

	local := &Local{
		Client:         client,
		localDiscovery: discoveryService,
	}

	if ci, ok := discoveryService.(localServiceInit); ok {
		if err := ci.Initialize(local); err != nil {
			return nil, err
		}
	}

	return local, nil
}
749287
func (d *driver) NextDevice(
	ctx types.Context,
	opts types.Store) (string, error) {
	// All possible device paths on Linux EC2 instances are /dev/xvd[f-p]
	letters := []string{
		"f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"}

	// 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 {
		re, _ := regexp.Compile(`^/dev/` +
			ebsUtils.NextDeviceInfo.Prefix +
			`(` + ebsUtils.NextDeviceInfo.Pattern + `)`)
		res := re.FindStringSubmatch(localDevice)
		if len(res) > 0 {
			localDeviceNames[res[1]] = true
		}
	}

	// Find which letters are used for ephemeral devices
	ephemeralDevices, err := d.getEphemeralDevices(ctx)
	if err != nil {
		return "", goof.WithError("error getting ephemeral devices", err)
	}

	for _, ephemeralDevice := range ephemeralDevices {
		re, _ := regexp.Compile(`^` +
			ebsUtils.NextDeviceInfo.Prefix +
			`(` + ebsUtils.NextDeviceInfo.Pattern + `)`)
		res := re.FindStringSubmatch(ephemeralDevice)
		if len(res) > 0 {
			localDeviceNames[res[1]] = true
		}
	}

	// Find next available letter for device path
	for _, letter := range letters {
		if localDeviceNames[letter] {
			continue
		}
		return fmt.Sprintf(
			"/dev/%s%s", ebsUtils.NextDeviceInfo.Prefix, letter), nil
	}
	return "", errNoAvaiDevice
}
1308972
func NewDeviceID(rawCert []byte) DeviceID {
	var n DeviceID
	hf := sha256.New()
	hf.Write(rawCert)
	hf.Sum(n[:0])
	return n
}