diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index 09e9e64bee..41e4623983 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -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() { diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 74fa857c51..8a31aa1d95 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -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{