// GetSupportedVolumeFromSnapshotDataSpec gets supported volume from snapshot data spec
492015
func GetSupportedVolumeFromSnapshotDataSpec(spec *VolumeSnapshotDataSpec) string {
	if spec.HostPath != nil {
		return "hostPath"
	}
	if spec.AWSElasticBlockStore != nil {
		return "aws_ebs"
	}
	if spec.GCEPersistentDiskSnapshot != nil {
		return "gce-pd"
	}
	if spec.CinderSnapshot != nil {
		return "cinder"
	}
	if spec.GlusterSnapshotVolume != nil {
		return "glusterfs"
	}
	return ""
}
25358
func NewVolumeSnapshotter(
	restClient *rest.RESTClient,
	scheme *runtime.Scheme,
	clientset kubernetes.Interface,
	asw cache.ActualStateOfWorld,
	volumePlugins *map[string]volume.Plugin) VolumeSnapshotter {
	return &volumeSnapshotter{
		restClient:         restClient,
		coreClient:         clientset,
		scheme:             scheme,
		actualStateOfWorld: asw,
		runningOperation:   goroutinemap.NewGoRoutineMap(defaultExponentialBackOffOnError),
		volumePlugins:      volumePlugins,
	}
}
496878
func (client *RenderingControl2) GetVolumeDB(InstanceID uint32, Channel string) (CurrentVolume int16, err error) {
	// Request structure.
	request := &struct {
		InstanceID string
		Channel    string
	}{}
	// BEGIN Marshal arguments into request.

	if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
		return
	}
	if request.Channel, err = soap.MarshalString(Channel); err != nil {
		return
	}
	// END Marshal arguments into request.

	// Response structure.
	response := &struct {
		CurrentVolume string
	}{}

	// Perform the SOAP call.
	if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVolumeDB", request, response); err != nil {
		return
	}

	// BEGIN Unmarshal arguments from response.

	if CurrentVolume, err = soap.UnmarshalI2(response.CurrentVolume); err != nil {
		return
	}
	// END Unmarshal arguments from response.
	return
}
333039
func (d *DeviceMapperDriver) getVolume(volumeName string, create bool) (*DeviceMapperVolume, error) {
	tenant := getTenant(volumeName)
	metadata, err := NewMetadata(d.MetadataPath(tenant), create)
	if err != nil {
		return nil, err
	}
	vol := &DeviceMapperVolume{
		name:     volumeName,
		path:     d.volumeDir(volumeName),
		tenant:   tenant,
		driver:   d,
		Metadata: metadata,
	}

	// if create is false, check to make sure the metadata info isn't empty or equal to base
	if !create {
		deviceHash := vol.deviceHash()
		if deviceHash == "" || deviceHash == "base" {
			return nil, ErrBaseDeviceHash
		}
	}

	return vol, nil
}
904551
func (c *sioClient) GetVolumeRefs(volID sioVolumeID) (refs int, err error) {
	files, err := c.getSioDiskPaths()
	if err != nil {
		return 0, err
	}
	for _, file := range files {
		if strings.Contains(file.Name(), string(volID)) {
			refs++
		}
	}
	return
}
114088
func (attacher *rbdAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) {
	img, err := getVolumeSourceImage(spec)
	if err != nil {
		return "", err
	}
	pool, err := getVolumeSourcePool(spec)
	if err != nil {
		return "", err
	}
	return makePDNameInternal(attacher.plugin.host, pool, img), nil
}
449677
func (s *VolumeService) GetVolumeByName(name string, opts ...OptionFunc) (*Volume, int, error) {
	id, count, err := s.GetVolumeID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetVolumeByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
1170290
func (vm *volumeManager) verifyVolumesMountedFunc(podName types.UniquePodName, expectedVolumes []string) wait.ConditionFunc {
	return func() (done bool, err error) {
		return len(vm.getUnmountedVolumes(podName, expectedVolumes)) == 0, nil
	}
}
783803
func (v *NFSVolume) GetSnapshotWithTag(tagName string) (*volume.SnapshotInfo, error) {
	return nil, ErrNotSupported
}
203515
func (s *VolumeService) GetUploadParamsForVolume(p *GetUploadParamsForVolumeParams) (*GetUploadParamsForVolumeResponse, error) {
	resp, err := s.cs.newRequest("getUploadParamsForVolume", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
411532
func (we *WorkflowExecutor) GetSecretFromVolMount(accessKeyName string, accessKey string) ([]byte, error) {
	return ioutil.ReadFile(filepath.Join(common.SecretVolMountPath, accessKeyName, accessKey))
}
111432
func (d *driver) VolumeSnapshot(
	ctx types.Context,
	volumeID, snapshotName string,
	opts types.Store) (*types.Snapshot, error) {
	// TODO Snapshots are not implemented yet
	return nil, types.ErrNotImplemented
}
1111353
func (ts *SignedTimestamp) GetSnapshot() (*FileMeta, error) {
	snapshotExpected, ok := ts.Signed.Meta[CanonicalSnapshotRole.String()]
	if !ok {
		return nil, ErrMissingMeta{Role: CanonicalSnapshotRole.String()}
	}
	return &snapshotExpected, nil
}
1038964
func (vs *volumeSnapshotter) updateSnapshotIfExists(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) (string, *crdv1.VolumeSnapshot, error) {
	snapshotName := snapshot.Metadata.Name
	var snapshotDataObj *crdv1.VolumeSnapshotData
	var snapshotDataSource *crdv1.VolumeSnapshotDataSource
	var conditions *[]crdv1.VolumeSnapshotCondition
	var err error

	tags := vs.findVolumeSnapshotMetadata(snapshot)
	// If there is no tag returned, snapshotting is not triggered yet, return new state
	if tags == nil {
		glog.Infof("No tag can be found in snapshot metadata %s", uniqueSnapshotName)
		return statusNew, snapshot, nil
	}
	// Check whether snapshotData object is already created or not. If yes, snapshot is already
	// triggered through cloud provider, bind it and return pending state
	if snapshotDataObj = vs.getSnapshotDataFromSnapshotName(uniqueSnapshotName); snapshotDataObj != nil {
		glog.Infof("Find snapshot data object %s from snapshot %s", snapshotDataObj.Metadata.Name, uniqueSnapshotName)
		snapshotObj, err := vs.bindandUpdateVolumeSnapshot(snapshot, snapshotDataObj.Metadata.Name, nil)
		if err != nil {
			return statusError, snapshot, err
		}
		return statusPending, snapshotObj, nil
	}
	// Find snapshot through cloud provider by existing tags, and create VolumeSnapshotData if such snapshot is found
	snapshotDataSource, conditions, err = vs.findSnapshotByTags(snapshotName, snapshot)
	if err != nil {
		return statusNew, snapshot, nil
	}
	// Snapshot is found. Create VolumeSnapshotData, bind VolumeSnapshotData to VolumeSnapshot, and update VolumeSnapshot status
	glog.Infof("updateSnapshotIfExists: create VolumeSnapshotData object for VolumeSnapshot %s.", uniqueSnapshotName)
	pvName, ok := snapshot.Metadata.Labels[pvNameLabel]
	if !ok {
		return statusError, snapshot, fmt.Errorf("Could not find pv name from snapshot, this should not happen.")
	}
	snapshotDataObj, err = vs.createVolumeSnapshotData(snapshotName, pvName, snapshotDataSource, conditions)
	if err != nil {
		return statusError, snapshot, err
	}
	glog.Infof("updateSnapshotIfExists: update VolumeSnapshot status and bind VolumeSnapshotData to VolumeSnapshot %s.", uniqueSnapshotName)
	snapshotObj, err := vs.bindandUpdateVolumeSnapshot(snapshot, snapshotDataObj.Metadata.Name, conditions)
	if err != nil {
		return statusError, nil, err
	}
	return statusPending, snapshotObj, nil
}
630092
func (vs *volumeSnapshotter) getSnapshotDataFromSnapshot(snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshotData, error) {
	var snapshotDataObj crdv1.VolumeSnapshotData
	snapshotDataName := snapshot.Spec.SnapshotDataName
	if snapshotDataName == "" {
		return nil, fmt.Errorf("Could not find snapshot data object: SnapshotDataName in snapshot spec is empty")
	}
	err := vs.restClient.Get().
		Name(snapshotDataName).
		Resource(crdv1.VolumeSnapshotDataResourcePlural).
		Do().Into(&snapshotDataObj)
	if err != nil {
		glog.Errorf("Error retrieving the VolumeSnapshotData objects from API server: %v", err)
		return nil, fmt.Errorf("Could not get snapshot data object %s: %v", snapshotDataName, err)
	}
	return &snapshotDataObj, nil
}
1135606
func (s *VolumeServer) SnapshotEnumerateWithFilters(
	ctx context.Context,
	req *api.SdkVolumeSnapshotEnumerateWithFiltersRequest,
) (*api.SdkVolumeSnapshotEnumerateWithFiltersResponse, error) {
	if s.cluster() == nil || s.driver(ctx) == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	// Get access rights
	var volReq []string
	if len(req.GetVolumeId()) != 0 {
		if err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Read); err != nil {
			return nil, err
		}
		volReq = []string{req.GetVolumeId()}
	} else {
		volReq = nil
	}

	snapshots, err := s.driver(ctx).SnapEnumerate(volReq, req.GetLabels())
	if err != nil {
		return nil, status.Errorf(
			codes.Internal,
			"Failed to enumerate snapshots in volume %s: %v",
			req.GetVolumeId(),
			err.Error())
	}

	ids := make([]string, 0)
	for _, snapshot := range snapshots {
		// Check access
		if snapshot.IsPermitted(ctx, api.Ownership_Read) {
			ids = append(ids, snapshot.GetId())
		}
	}

	return &api.SdkVolumeSnapshotEnumerateWithFiltersResponse{
		VolumeSnapshotIds: ids,
	}, nil
}
1001159
func (s *VolumeService) GetPathForVolume(p *GetPathForVolumeParams) (*GetPathForVolumeResponse, error) {
	resp, err := s.cs.newRequest("getPathForVolume", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}