// getdeviceid finds out a TAP device from registry, it *may* requires privileged right to prevent some weird issue.
6283
func getdeviceid(componentID string, interfaceName string) (deviceid string, err error) {
	k, err := registry.OpenKey(registry.LOCAL_MACHINE, tapDriverKey, registry.READ)
	if err != nil {
		return "", fmt.Errorf("Failed to open the adapter registry, TAP driver may be not installed, %v", err)
	}
	defer k.Close()
	// read all subkeys, it should not return an err here
	keys, err := k.ReadSubKeyNames(-1)
	if err != nil {
		return "", err
	}
	// find the one matched ComponentId
	for _, v := range keys {
		key, err := registry.OpenKey(registry.LOCAL_MACHINE, tapDriverKey+"\\"+v, registry.READ)
		if err != nil {
			continue
		}
		val, _, err := key.GetStringValue("ComponentId")
		if err != nil {
			key.Close()
			continue
		}
		if val == componentID {
			val, _, err = key.GetStringValue("NetCfgInstanceId")
			if err != nil {
				key.Close()
				continue
			}
			if len(interfaceName) > 0 {
				key2 := fmt.Sprintf("%s\\%s\\Connection", tapDriverKey, val)
				k2, err := registry.OpenKey(registry.LOCAL_MACHINE, key2, registry.READ)
				if err != nil {
					continue
				}
				defer k2.Close()
				val, _, err := k2.GetStringValue("Name")
				if err != nil || val != interfaceName {
					continue
				}
			}
			key.Close()
			return val, nil
		}
		key.Close()
	}
	if len(interfaceName) > 0 {
		return "", fmt.Errorf("Failed to find the tap device in registry with specified ComponentId '%s' and InterfaceName '%s', TAP driver may be not installed or you may have specified an interface name that doesn't exist", componentID, interfaceName)
	}

	return "", fmt.Errorf("Failed to find the tap device in registry with specified ComponentId '%s', TAP driver may be not installed", componentID)
}
1150384
func (u *User) GetID() int64 {
	if u == nil || u.ID == nil {
		return 0
	}
	return *u.ID
}
1240082
func (_m *DBClient) GetDeviceReportById(id string) (models.DeviceReport, error) {
	ret := _m.Called(id)

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

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

	return r0, r1
}
1117973
func (d *Domain) GetID() (uint, error) {
	var err C.virError
	id := uint(C.virDomainGetIDWrapper(d.ptr, &err))
	if id == ^uint(0) {
		return id, makeError(&err)
	}
	return id, nil
}
849820
func (os *OpenStack) GetDevicePath(volumeID string) string {
	// Build a list of candidate device paths
	candidateDeviceNodes := []string{
		// KVM
		fmt.Sprintf("virtio-%s", volumeID[:20]),
		// KVM virtio-scsi
		fmt.Sprintf("scsi-0QEMU_QEMU_HARDDISK_%s", volumeID[:20]),
		// ESXi
		fmt.Sprintf("wwn-0x%s", strings.Replace(volumeID, "-", "", -1)),
	}

	files, _ := ioutil.ReadDir("/dev/disk/by-id/")

	for _, f := range files {
		for _, c := range candidateDeviceNodes {
			if c == f.Name() {
				glog.V(4).Infof("Found disk attached as %q; full devicepath: %s\n", f.Name(), path.Join("/dev/disk/by-id/", f.Name()))
				return path.Join("/dev/disk/by-id/", f.Name())
			}
		}
	}

	glog.Warningf("Failed to find device for the volumeID: %q\n", volumeID)
	return ""
}
1286959
func (s *RegisterDeviceOutput) SetDeviceId(v string) *RegisterDeviceOutput {
	s.DeviceId = &v
	return s
}
801884
func (r *RepoStatus) GetID() int64 {
	if r == nil || r.ID == nil {
		return 0
	}
	return *r.ID
}
962631
func (c *Client) GetDeviceProfileById(id string) (contract.DeviceProfile, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	var d contract.DeviceProfile
	err := getObjectById(conn, id, unmarshalDeviceProfile, &d)
	return d, err
}
784161
func (s *ListDeviceEventsInput) SetDeviceId(v string) *ListDeviceEventsInput {
	s.DeviceId = &v
	return s
}
1210783
func (g *Grant) GetID() int64 {
	if g == nil || g.ID == nil {
		return 0
	}
	return *g.ID
}
722689
func OptDeviceID(id int) Option {
	return func(h *HCI) error {
		h.id = id
		return nil
	}
}
302088
func (m *Milestone) GetID() int64 {
	if m == nil || m.ID == nil {
		return 0
	}
	return *m.ID
}
137382
func (_m *Protocol) GetDevice(id uint64) (common.Device, error) {
	ret := _m.Called(id)

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

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

	return r0, r1
}
152468
func (u *UserLDAPMapping) GetID() int64 {
	if u == nil || u.ID == nil {
		return 0
	}
	return *u.ID
}
751452
func (m *PoolMetadata) GetDevice(ctx context.Context, name string) (*DeviceInfo, error) {
	var (
		dev DeviceInfo
		err error
	)

	err = m.db.View(func(tx *bolt.Tx) error {
		bucket := tx.Bucket(devicesBucketName)
		return getObject(bucket, name, &dev)
	})

	return &dev, err
}
436026
func (ca *CertAuthorityV2) GetID() CertAuthID {
	return CertAuthID{Type: ca.Spec.Type, DomainName: ca.Metadata.Name}
}
1195520
func (_m *DBClient) GetDeviceServiceById(id string) (models.DeviceService, error) {
	ret := _m.Called(id)

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

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

	return r0, r1
}