fix: image upload not clean pending usage

This commit is contained in:
Qiu Jian
2020-07-21 01:43:40 +08:00
parent 1d1674faf9
commit 2a892fd845
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -252,7 +252,7 @@ func init() {
}
type ImageDeleteOptions struct {
ID []string `help:"Image ID or name"`
ID []string `help:"Image ID or name" json:"-"`
OverridePendingDelete *bool `help:"Delete image directly instead of pending delete" short-token:"f"`
}
R(&ImageDeleteOptions{}, "image-delete", "Delete a image", func(s *mcclient.ClientSession, args *ImageDeleteOptions) error {
+2 -1
View File
@@ -538,7 +538,8 @@ func (self *SImage) PostCreate(ctx context.Context, userCred mcclient.TokenCrede
// if SImage belong to a guest image, pending quota will not be set.
if self.IsGuestImage.IsFalse() {
pendingUsage := SQuota{Image: 1}
keys := imageCreateInput2QuotaKeys(self.DiskFormat, ownerId)
inputDiskFormat, _ := data.GetString("disk_format")
keys := imageCreateInput2QuotaKeys(inputDiskFormat, ownerId)
pendingUsage.SetKeys(keys)
cancelUsage := SQuota{Image: 1}
keys = self.GetQuotaKeys()