// LocalVolumesSize gets all local volumes and fetches their size on disk
// Note that this intentionally skips volumes which have mount options. Typically
// volumes with mount options are not really local even if they are using the
// local driver.
330379
func (s *VolumesService) LocalVolumesSize(ctx context.Context) ([]*types.Volume, error) {
	ls, _, err := s.vs.Find(ctx, And(ByDriver(volume.DefaultDriverName), CustomFilter(func(v volume.Volume) bool {
		dv, ok := v.(volume.DetailedVolume)
		return ok && len(dv.Options()) == 0
	})))
	if err != nil {
		return nil, err
	}
	return s.volumesToAPI(ctx, ls, calcSize(true)), nil
}
853265
func (s *VolumeSource) ReleaseVolumes(ctx context.ProviderCallContext, volIds []string) ([]error, error) {
	s.MethodCall(s, "ReleaseVolumes", ctx, volIds)
	if s.ReleaseVolumesFunc != nil {
		return s.ReleaseVolumesFunc(ctx, volIds)
	}
	return nil, errors.NotImplementedf("ReleaseVolumes")
}
591259
func (c *Client) MigrateVolume(p *MigrateVolumeParameter) (*Volume, error) {
	obj, err := c.Request("migrateVolume", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Volume), err
}
664905
func populateVolumeOptions(pluginName, pvcName string, capacityGB resource.Quantity, tags map[string]string, storageParams map[string]string, node *v1.Node, allowedTopologies []v1.TopologySelectorTerm, zonesWithNodes sets.String) (*aws.VolumeOptions, error) {
	requestGiB, err := volumehelpers.RoundUpToGiBInt(capacityGB)
	if err != nil {
		return nil, err
	}

	volumeOptions := &aws.VolumeOptions{
		CapacityGB: requestGiB,
		Tags:       tags,
	}

	// Apply Parameters (case-insensitive). We leave validation of
	// the values to the cloud provider.
	zonePresent := false
	zonesPresent := false
	var zone string
	var zones sets.String
	for k, v := range storageParams {
		switch strings.ToLower(k) {
		case "type":
			volumeOptions.VolumeType = v
		case "zone":
			zonePresent = true
			zone = v
		case "zones":
			zonesPresent = true
			zones, err = volumehelpers.ZonesToSet(v)
			if err != nil {
				return nil, fmt.Errorf("error parsing zones %s, must be strings separated by commas: %v", zones, err)
			}
		case "iopspergb":
			volumeOptions.IOPSPerGB, err = strconv.Atoi(v)
			if err != nil {
				return nil, fmt.Errorf("invalid iopsPerGB value %q, must be integer between 1 and 30: %v", v, err)
			}
		case "encrypted":
			volumeOptions.Encrypted, err = strconv.ParseBool(v)
			if err != nil {
				return nil, fmt.Errorf("invalid encrypted boolean value %q, must be true or false: %v", v, err)
			}
		case "kmskeyid":
			volumeOptions.KmsKeyID = v
		case volume.VolumeParameterFSType:
			// Do nothing but don't make this fail
		default:
			return nil, fmt.Errorf("invalid option %q for volume plugin %s", k, pluginName)
		}
	}

	volumeOptions.AvailabilityZone, err = volumehelpers.SelectZoneForVolume(zonePresent, zonesPresent, zone, zones, zonesWithNodes, node, allowedTopologies, pvcName)
	if err != nil {
		return nil, err
	}
	return volumeOptions, nil
}
232093
func (c *Container) AddVolume(v ContainerVolume) {
	c.volumes = append(c.volumes, v)
}
1041027
func (ga *openstackStorageAdapter) GetVolume(volumeId string) (*cinder.Volume, error) {
	resp, err := ga.cinderClient.GetVolume(volumeId)
	if err != nil {
		if gooseerrors.IsNotFound(err) {
			return nil, errors.NotFoundf("volume %q", volumeId)
		}
		return nil, err
	}
	return &resp.Volume, nil
}
91736
func (d *DeviceMapperDriver) Resize(volumeName string, size uint64) error {
	vol, err := d.getVolume(volumeName, false)
	if err != nil {
		return err
	}
	if err := d.resize(vol.deviceHash(), size); err != nil {
		return err
	}
	newSize := volume.FilesystemBytesSize(vol.Path())
	human := units.BytesSize(float64(newSize))
	glog.Infof("Resized filesystem. New size: %s", human)
	return nil
}
71971
func (e *Engine) DiskSize() int64 {
	walDiskSizeBytes := e.WAL.DiskSizeBytes()
	return e.FileStore.DiskSizeBytes() + walDiskSizeBytes
}
746677
func (s *StorediSCSIVolume) SetVolumeSizeInBytes(v int64) *StorediSCSIVolume {
	s.VolumeSizeInBytes = &v
	return s
}
965696
func (s *IndicesExistsTemplateService) Local(local bool) *IndicesExistsTemplateService {
	s.local = &local
	return s
}
1168395
func podLocalVolumeUsage(volumeNames []string, podStats statsapi.PodStats) v1.ResourceList {
	disk := resource.Quantity{Format: resource.BinarySI}
	inodes := resource.Quantity{Format: resource.DecimalSI}
	for _, volumeName := range volumeNames {
		for _, volumeStats := range podStats.VolumeStats {
			if volumeStats.Name == volumeName {
				disk.Add(*diskUsage(&volumeStats.FsStats))
				inodes.Add(*inodeUsage(&volumeStats.FsStats))
				break
			}
		}
	}
	return v1.ResourceList{
		v1.ResourceEphemeralStorage: disk,
		resourceInodes:              inodes,
	}
}
665847
func (c *Client) GetVolume(
	ctx context.Context, id, name string) (Volume, error) {

	if id != "" {
		name = id
	}
	volume, err := apiv1.GetIsiVolume(ctx, c.API, name)
	if err != nil {
		return nil, err
	}
	var isiVolume = &apiv1.IsiVolume{Name: name, AttributeMap: volume.AttributeMap}
	return isiVolume, nil
}
1345324
func DefaultInstanceGroupVolumeSize(role kops.InstanceGroupRole) (int32, error) {
	switch role {
	case kops.InstanceGroupRoleMaster:
		return DefaultVolumeSizeMaster, nil
	case kops.InstanceGroupRoleNode:
		return DefaultVolumeSizeNode, nil
	case kops.InstanceGroupRoleBastion:
		return DefaultVolumeSizeBastion, nil
	default:
		return -1, fmt.Errorf("unknown InstanceGroup Role %s", role)
	}
}
403221
func (c *Client) CreateVolume(opts CreateVolumeOptions) (*Volume, error) {
	resp, err := c.do("POST", "/volumes/create", doOptions{
		data:    opts,
		context: opts.Context,
	})
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	var volume Volume
	if err := json.NewDecoder(resp.Body).Decode(&volume); err != nil {
		return nil, err
	}
	return &volume, nil
}
481669
func (os *OpenStack) getVolume(volumeID string) (Volume, error) {
	volumes, err := os.volumeService("")
	if err != nil {
		return Volume{}, fmt.Errorf("unable to initialize cinder client for region: %s, err: %v", os.region, err)
	}
	return volumes.getVolume(volumeID)
}
273148
func (c *Client) CreateVolume(p *CreateVolumeParameter) (*Volume, error) {
	obj, err := c.Request("createVolume", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Volume), err
}
367562
func (v *localVolume) Mount(id string) (string, error) {
	v.m.Lock()
	defer v.m.Unlock()
	if v.opts != nil {
		if !v.active.mounted {
			if err := v.mount(); err != nil {
				return "", errdefs.System(err)
			}
			v.active.mounted = true
		}
		v.active.count++
	}
	return v.path, nil
}