//Disk can only modify tags.
359070
func (_ *Disk) RenderALI(t *aliup.ALIAPITarget, a, e, changes *Disk) error {
	if a == nil {
		glog.V(2).Infof("Creating Disk with Name:%q", fi.StringValue(e.Name))

		request := &ecs.CreateDiskArgs{
			DiskName:     fi.StringValue(e.Name),
			RegionId:     common.Region(t.Cloud.Region()),
			ZoneId:       fi.StringValue(e.ZoneId),
			Encrypted:    fi.BoolValue(e.Encrypted),
			DiskCategory: ecs.DiskCategory(fi.StringValue(e.DiskCategory)),
			Size:         fi.IntValue(e.SizeGB),
		}
		diskId, err := t.Cloud.EcsClient().CreateDisk(request)
		if err != nil {
			return fmt.Errorf("error creating disk: %v", err)
		}
		e.DiskId = fi.String(diskId)
	}

	if changes != nil && changes.Tags != nil {
		glog.V(2).Infof("Modifying tags of disk with Name:%q", fi.StringValue(e.Name))
		if err := t.Cloud.CreateTags(*e.DiskId, DiskResource, e.Tags); err != nil {
			return fmt.Errorf("error adding Tags to ALI YunPan: %v", err)
		}
	}

	if a != nil && (len(a.Tags) > 0) {

		tagsToDelete := e.getDiskTagsToDelete(a.Tags)
		if len(tagsToDelete) > 0 {
			glog.V(2).Infof("Deleting tags of disk with Name:%q", fi.StringValue(e.Name))
			if err := t.Cloud.RemoveTags(*e.DiskId, DiskResource, tagsToDelete); err != nil {
				return fmt.Errorf("error removing Tags from ALI YunPan: %v", err)
			}
		}
	}

	return nil
}
104810
func (p *PodContainer) Storage(disk float64) *PodContainer {
	p.Resources.Disk = disk
	return p
}
377012
func (v *vcsCmd) tags(dir string) ([]string, error) {
	var tags []string
	for _, tc := range v.tagCmd {
		out, err := v.runOutput(dir, tc.cmd)
		if err != nil {
			return nil, err
		}
		re := regexp.MustCompile(`(?m-s)` + tc.pattern)
		for _, m := range re.FindAllStringSubmatch(string(out), -1) {
			tags = append(tags, m[1])
		}
	}
	return tags, nil
}
1059140
func (gce *Connection) Disk(zone, name string) (*Disk, error) {
	d, err := gce.raw.GetDisk(gce.projectID, zone, name)
	if err != nil {
		return nil, errors.Annotatef(err, "cannot get disk %q in zone %q", name, zone)
	}
	return NewDisk(d), nil
}
1128975
func diskStats() (*disk, error) {
	var (
		freeBytes  uint64 = 0
		totalBytes uint64 = 0
	)

	// windows sets return value to 0 when function fails.
	ret, _, err := procGetDiskFreeSpaceExW.Call(
		0,
		uintptr(unsafe.Pointer(&freeBytes)),
		uintptr(unsafe.Pointer(&totalBytes)),
		0,
	)
	if ret == 0 {
		return nil, err
	}

	// diskStats functions from other platforms return disk usage in kiB.
	return &disk{
		Usage: (totalBytes - freeBytes) / 1024,
		Total: totalBytes / 1024,
	}, nil
}
1338637
func (a *Attachments) Storage(tag names.StorageTag) (jujuc.ContextStorageAttachment, error) {
	if attachment, ok := a.storageAttachments[tag]; ok {
		return attachment, nil
	}
	return nil, errors.NotFoundf("storage")
}
829493
func (d *Datastore) DiskUsage() (uint64, error) {
	var size uint64
	err := d.runOp(func() error {
		var err error
		size, err = ds.DiskUsage(d.Batching)
		return err
	})
	return size, err
}
373040
func (i *Index) DiskSizeBytes() int64 {
	fs, err := i.FileSet()
	if err != nil {
		i.logger.Warn("Index is closing down")
		return 0
	}
	defer fs.Release()

	var manifestSize int64
	// Get MANIFEST sizes from each partition.
	for _, p := range i.partitions {
		manifestSize += p.manifestSize
	}
	return fs.Size() + manifestSize
}
566876
func (d *Datastore) DiskUsage() (uint64, error) {
	var duTotal uint64 = 0
	for _, d := range d.mounts {
		du, err := ds.DiskUsage(d.Datastore)
		duTotal += du
		if err != nil {
			return duTotal, err
		}
	}
	return duTotal, nil
}
748586
func (spec DiskSpec) Bytes() []byte {
	b, err := json.Marshal(spec)
	if err != nil {
		// should not happen
		panic(err)
	}
	return bytes.TrimSpace(b)
}
210081
func (r *PURuntime) Tags() *TagStore {
	r.Lock()
	defer r.Unlock()

	return r.tags.Copy()
}
1069699
func (client *Client) ReplaceSystemDisk(args *ReplaceSystemDiskArgs) (diskId string, err error) {
	response := ReplaceSystemDiskResponse{}
	err = client.Invoke("ReplaceSystemDisk", args, &response)
	if err != nil {
		return "", err
	}
	return response.DiskId, nil
}
839890
func (sb *storageBackend) StorageInstanceFilesystem(tag names.StorageTag) (Filesystem, error) {
	f, err := sb.storageInstanceFilesystem(tag)
	return f, err
}
1290009
func (f disksFlag) Set(s string) error {
	for _, field := range strings.Fields(s) {
		cons, err := storage.ParseConstraints(field)
		if err != nil {
			return errors.Annotate(err, "cannot parse disk constraints")
		}
		*f.disks = append(*f.disks, cons)
	}
	return nil
}
1226240
func diskCount(disks []StorageAPI) int {
	diskCount := 0
	for _, disk := range disks {
		if disk == nil {
			continue
		}
		diskCount++
	}
	return diskCount
}
1293055
func (t *fileTracker) AddBytes(bytes uint64) {
	atomic.AddUint64(&t.diskBytes, bytes)

	labels := t.Labels()
	t.metrics.DiskSize.With(labels).Add(float64(bytes))
}
1237348
func (d *Disk) getDiskTagsToDelete(currentTags map[string]string) map[string]string {
	tagsToDelete := map[string]string{}
	for k, v := range currentTags {
		if _, ok := d.Tags[k]; !ok {
			tagsToDelete[k] = v
		}
	}

	return tagsToDelete
}