fix: guest save image inherit projects of guest (#14041)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2022-04-16 09:34:33 +08:00
committed by GitHub
co-authored by Qiu Jian
parent b36786220d
commit 16c74db9c8
2 changed files with 8 additions and 0 deletions
+5
View File
@@ -1036,6 +1036,8 @@ func (self *SDisk) PrepareSaveImage(ctx context.Context, userCred mcclient.Token
OsArch string
Properties map[string]string
ProjectId string
EncryptKeyId string
}{
Name: input.Name,
@@ -1048,6 +1050,9 @@ func (self *SDisk) PrepareSaveImage(ctx context.Context, userCred mcclient.Token
"os_type": input.OsType,
"os_arch": input.OsArch,
},
// inherit the ownership of disk
ProjectId: self.ProjectId,
}
if self.IsEncrypted() {
+3
View File
@@ -235,6 +235,9 @@ func (self *SGuest) PerformSaveGuestImage(ctx context.Context, userCred mcclient
kwargs := imageapi.GuestImageCreateInput{}
kwargs.GuestImageCreateInputBase = input.GuestImageCreateInputBase
kwargs.Properties = make(map[string]string)
if len(kwargs.ProjectId) == 0 {
kwargs.ProjectId = self.ProjectId
}
for _, disk := range diskList {
kwargs.Images = append(kwargs.Images, imageapi.GuestImageCreateInputSubimage{