//GetVolume returns a specific volume by name or ID
497482
func (c *Client) GetVolume(id string, name string) (Volume, error) {
	volume, err := c.api.GetVolume(id, name)
	if err != nil {
		return nil, err
	}
	return volume.Content, nil
}
440983
func httpGetVolume(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetVolume: %+v", vars)

	key := vars["key"]

	collections.volumeMutex.Lock()
	defer collections.volumeMutex.Unlock()
	obj := collections.volumes[key]
	if obj == nil {
		log.Infof("volume %s not found", key)
		return nil, errors.New("volume not found")
	}

	// Return the obj
	return obj, nil
}
312287
func GetVolumeFSType(v api.Volume) (policy.FSType, error) {
	switch {
	case v.HostPath != nil:
		return policy.HostPath, nil
	case v.EmptyDir != nil:
		return policy.EmptyDir, nil
	case v.GCEPersistentDisk != nil:
		return policy.GCEPersistentDisk, nil
	case v.AWSElasticBlockStore != nil:
		return policy.AWSElasticBlockStore, nil
	case v.GitRepo != nil:
		return policy.GitRepo, nil
	case v.Secret != nil:
		return policy.Secret, nil
	case v.NFS != nil:
		return policy.NFS, nil
	case v.ISCSI != nil:
		return policy.ISCSI, nil
	case v.Glusterfs != nil:
		return policy.Glusterfs, nil
	case v.PersistentVolumeClaim != nil:
		return policy.PersistentVolumeClaim, nil
	case v.RBD != nil:
		return policy.RBD, nil
	case v.FlexVolume != nil:
		return policy.FlexVolume, nil
	case v.Cinder != nil:
		return policy.Cinder, nil
	case v.CephFS != nil:
		return policy.CephFS, nil
	case v.Flocker != nil:
		return policy.Flocker, nil
	case v.DownwardAPI != nil:
		return policy.DownwardAPI, nil
	case v.FC != nil:
		return policy.FC, nil
	case v.AzureFile != nil:
		return policy.AzureFile, nil
	case v.ConfigMap != nil:
		return policy.ConfigMap, nil
	case v.VsphereVolume != nil:
		return policy.VsphereVolume, nil
	case v.Quobyte != nil:
		return policy.Quobyte, nil
	case v.AzureDisk != nil:
		return policy.AzureDisk, nil
	case v.PhotonPersistentDisk != nil:
		return policy.PhotonPersistentDisk, nil
	case v.StorageOS != nil:
		return policy.StorageOS, nil
	case v.Projected != nil:
		return policy.Projected, nil
	case v.PortworxVolume != nil:
		return policy.PortworxVolume, nil
	case v.ScaleIO != nil:
		return policy.ScaleIO, nil
	case v.CSI != nil:
		return policy.CSI, nil
	}

	return "", fmt.Errorf("unknown volume type for volume: %#v", v)
}
1238511
func GetVolumeSize(imageClient *gophercloud.ServiceClient, imageID string) (int, error) {
	sourceImage, err := images.Get(imageClient, imageID).Extract()
	if err != nil {
		return 0, err
	}

	if sourceImage.MinDiskGigabytes != 0 {
		return sourceImage.MinDiskGigabytes, nil
	}

	volumeSizeMB := sourceImage.SizeBytes / 1024 / 1024
	volumeSizeGB := int(sourceImage.SizeBytes / 1024 / 1024 / 1024)

	// Increment gigabytes size if the initial size can't be divided without
	// remainder.
	if volumeSizeMB%1024 > 0 {
		volumeSizeGB++
	}

	return volumeSizeGB, nil
}
779046
func (c *Host) GetVolume(volumeID string) (*volume.Info, error) {
	var volume volume.Info
	return &volume, c.c.Get(fmt.Sprintf("/storage/volumes/%s", volumeID), &volume)
}
737404
func (ga *openstackStorageAdapter) DeleteVolume(volumeId string) error {
	if err := ga.cinderClient.DeleteVolume(volumeId); err != nil {
		if gooseerrors.IsNotFound(err) {
			return errors.NotFoundf("volume %q", volumeId)
		}
		return err
	}
	return nil
}
1060663
func (c *Client) CopyVolume(
	ctx context.Context, src, dest string) (Volume, error) {

	_, err := apiv1.CopyIsiVolume(ctx, c.API, src, dest)
	if err != nil {
		return nil, err
	}

	return c.GetVolume(ctx, dest, dest)
}
463229
func GetIsiVolumes(
	ctx context.Context,
	client api.Client) (resp *getIsiVolumesResp, err error) {

	// PAPI call: GET https://1.2.3.4:8080/namespace/path/to/volumes/
	err = client.Get(ctx, realNamespacePath(client), "", nil, nil, &resp)
	return resp, err
}
274631
func (s *VolumesService) Get(ctx context.Context, name string, getOpts ...opts.GetOption) (*types.Volume, error) {
	v, err := s.vs.Get(ctx, name, getOpts...)
	if err != nil {
		return nil, err
	}
	vol := volumeToAPIType(v)

	var cfg opts.GetConfig
	for _, o := range getOpts {
		o(&cfg)
	}

	if cfg.ResolveStatus {
		vol.Status = v.Status()
	}
	return &vol, nil
}
919384
func (svc *googleService) getDisk(name string) (*googlecloud.Disk, error) {
	return svc.service.Disks.Get(svc.vm.Project, svc.vm.Zone, name).Do()
}
493217
func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListVolumesParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListVolumes(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.Volumes[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.Volumes {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
817606
func (c *Client) DeleteVolume(
	ctx context.Context, name string) error {
	_, err := apiv1.DeleteIsiVolume(ctx, c.API, name)
	return err
}
862624
func (c *Client) UnexportVolume(
	ctx context.Context, name string) error {

	return c.Unexport(ctx, name)
}
727388
func (c *Client) UploadVolume(p *UploadVolumeParameter) (*Volume, error) {
	obj, err := c.Request("uploadVolume", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Volume), err
}
497637
func (r *Root) Get(name string) (volume.Volume, error) {
	r.m.Lock()
	v, exists := r.volumes[name]
	r.m.Unlock()
	if !exists {
		return nil, ErrNotFound
	}
	return v, 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
}
985178
func (client QuobyteClient) GetVolumeUUID(volume, tenant string) (string, error) {
	if len(volume) != 0 && !IsValidUUID(volume) {
		tenantUUID, err := client.GetTenantUUID(tenant)
		if err != nil {
			return "", err
		}
		volUUID, err := client.ResolveVolumeNameToUUID(volume, tenantUUID)
		if err != nil {
			return "", err
		}

		return volUUID, nil
	}
	return volume, nil
}