//GetDatastorePathObjFromVMDiskPath gets the datastorePathObj from VM disk path.
770505
func GetDatastorePathObjFromVMDiskPath(vmDiskPath string) (*object.DatastorePath, error) {
	datastorePathObj := new(object.DatastorePath)
	isSuccess := datastorePathObj.FromString(vmDiskPath)
	if !isSuccess {
		klog.Errorf("Failed to parse volPath: %s", vmDiskPath)
		return nil, fmt.Errorf("Failed to parse volPath: %s", vmDiskPath)
	}
	return datastorePathObj, nil
}
547779
func (m *DatastoreFileManager) Path(name string) *DatastorePath {
	var p DatastorePath

	if !p.FromString(name) {
		p.Path = name
		p.Datastore = m.Datastore.Name()
	}

	return &p
}
43437
func (storageosVolume *storageos) GetPath() string {
	return getPath(storageosVolume.podUID, storageosVolume.volNamespace, storageosVolume.volName, storageosVolume.pvName, storageosVolume.plugin.host)
}
1255319
func GetJSONPathValue(obj interface{}, path string, allowMissingKeys bool) (interface{}, error) {
	j := jsonpath.New("GetJSONPathValue")
	// If the key is missing, return an empty string without errors
	j.AllowMissingKeys(allowMissingKeys)
	err := j.Parse(path)
	if err != nil {
		return "", errors.Wrapf(err, "JsonPath parse %s error", path)
	}
	values, err := j.FindResults(obj)
	if err != nil {
		return "", errors.Wrap(err, "JsonPath execute error")
	}
	if len(values) == 0 {
		return nil, nil
	}
	if len(values) > 1 {
		return nil, errors.Errorf("single result expected, got %d", len(values))
	}
	if values[0] == nil || len(values[0]) == 0 || values[0][0].IsNil() {
		return nil, nil
	}
	return values[0][0].Interface(), nil
}
78871
func IndexStoragePath() string {
	return path.Join(storage.BaseImagesPath, simplestreams.UnsignedIndex(currentStreamsVersion, IndexFileVersion))
}
973970
func GetIntelRdtPath(id string) (string, error) {
	rootPath, err := getIntelRdtRoot()
	if err != nil {
		return "", err
	}

	path := filepath.Join(rootPath, id)
	return path, 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 ""
}
922435
func (vm *VirtualMachine) GetAllAccessibleDatastores(ctx context.Context) ([]*DatastoreInfo, error) {
	host, err := vm.HostSystem(ctx)
	if err != nil {
		klog.Errorf("Failed to get host system for VM: %q. err: %+v", vm.InventoryPath, err)
		return nil, err
	}
	var hostSystemMo mo.HostSystem
	s := object.NewSearchIndex(vm.Client())
	err = s.Properties(ctx, host.Reference(), []string{DatastoreProperty}, &hostSystemMo)
	if err != nil {
		klog.Errorf("Failed to retrieve datastores for host: %+v. err: %+v", host, err)
		return nil, err
	}
	var dsRefList []types.ManagedObjectReference
	dsRefList = append(dsRefList, hostSystemMo.Datastore...)

	var dsMoList []mo.Datastore
	pc := property.DefaultCollector(vm.Client())
	properties := []string{DatastoreInfoProperty}
	err = pc.Retrieve(ctx, dsRefList, properties, &dsMoList)
	if err != nil {
		klog.Errorf("Failed to get Datastore managed objects from datastore objects."+
			" dsObjList: %+v, properties: %+v, err: %v", dsRefList, properties, err)
		return nil, err
	}
	klog.V(9).Infof("Result dsMoList: %+v", dsMoList)
	var dsObjList []*DatastoreInfo
	for _, dsMo := range dsMoList {
		dsObjList = append(dsObjList,
			&DatastoreInfo{
				&Datastore{object.NewDatastore(vm.Client(), dsMo.Reference()),
					vm.Datacenter},
				dsMo.Info.GetDatastoreInfo()})
	}
	return dsObjList, nil
}
149654
func (cephfsVolume *cephfs) GetKeyringPath() string {
	name := cephfsPluginName
	volumeDir := cephfsVolume.plugin.host.GetPodVolumeDir(cephfsVolume.podUID, utilstrings.EscapeQualifiedName(name), cephfsVolume.volName)
	volumeKeyringDir := volumeDir + "~keyring"
	return volumeKeyringDir
}
197066
func (attacher *vsphereVMDKAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) {
	volumeSource, _, err := getVolumeSource(spec)
	if err != nil {
		return "", err
	}

	return makeGlobalPDPath(attacher.host, volumeSource.VolumePath), nil
}
204812
func (f *Finder) datacenterPath(ctx context.Context, ref types.ManagedObjectReference) (string, error) {
	mes, err := mo.Ancestors(ctx, f.client, f.client.ServiceContent.PropertyCollector, ref)
	if err != nil {
		return "", err
	}

	// Chop leaves under the Datacenter
	for i := len(mes) - 1; i > 0; i-- {
		if mes[i].Self.Type == "Datacenter" {
			break
		}
		mes = mes[:i]
	}

	var p string

	for _, me := range mes {
		// Skip root entity in building inventory path.
		if me.Parent == nil {
			continue
		}

		p = p + "/" + me.Name
	}

	return p, nil
}
316200
func (c Config) GetIndexPath(base string) string {
	if c.IndexPath != "" {
		return c.IndexPath
	}
	return filepath.Join(base, DefaultIndexDirectoryName)
}
1034569
func getDiskByIDPaths(pdName string, partition string) []string {
	devicePaths := []string{
		filepath.Join(diskByIDPath, diskGooglePrefix+pdName),
		filepath.Join(diskByIDPath, diskScsiGooglePrefix+pdName),
	}

	if partition != "" {
		for i, path := range devicePaths {
			devicePaths[i] = path + diskPartitionSuffix + partition
		}
	}

	return devicePaths
}
120857
func (p *PartitionedMemoryIdx) GetPath(orgId uint32, path string) []idx.Archive {
	g, _ := errgroup.WithContext(context.Background())
	result := make([][]idx.Archive, len(p.Partition))
	var i int
	for _, m := range p.Partition {
		pos, m := i, m
		g.Go(func() error {
			result[pos] = m.GetPath(orgId, path)
			return nil
		})
		i++
	}
	if err := g.Wait(); err != nil {
		log.Errorf("memory-idx: failed to getPath: orgId=%d path=%s. %s", orgId, path, err)
		return nil
	}

	// get our total count, so we can allocate our response in one go.
	items := 0
	for _, r := range result {
		items += len(r)
	}
	response := make([]idx.Archive, 0, items)
	for _, r := range result {
		response = append(response, r...)
	}
	return response
}
13000
func (f *Facade) getServicePath(ctx datastore.Context, serviceID string) (tenantID string, servicePath string, err error) {
	gs := func(id string) (*service.ServiceDetails, error) {
		return f.GetServiceDetails(ctx, id)
	}
	return f.serviceCache.GetServicePath(serviceID, gs)
}
222893
func (l *RegistryListener) GetPath(nodes ...string) string {
	return path.Join(append([]string{zkregistrytags}, nodes...)...)
}
978028
func getSCSIDevPath(scsiAddr string) (string, error) {
	if err := scanSCSIBus(scsiAddr); err != nil {
		return "", err
	}

	devPath := filepath.Join(scsiDiskPrefix+scsiAddr, scsiDiskSuffix)

	checkUevent := func(uEv *uevent.Uevent) bool {
		devSubPath := filepath.Join(scsiHostChannel+scsiAddr, scsiBlockSuffix)
		return (uEv.Action == "add" &&
			strings.Contains(uEv.DevPath, devSubPath))
	}
	if err := waitForDevice(devPath, scsiAddr, checkUevent); err != nil {
		return "", err
	}

	scsiDiskName, err := findSCSIDisk(devPath)
	if err != nil {
		return "", err
	}

	return filepath.Join(devPrefix, scsiDiskName), nil
}