mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
fix: turn delete prepaid vm to postpaid, so as to allow deleting the vm
This commit is contained in:
@@ -1826,6 +1826,18 @@ func (self *SGuest) syncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
|
||||
lockman.LockObject(ctx, self)
|
||||
defer lockman.ReleaseObject(ctx, self)
|
||||
|
||||
if self.BillingType == BILLING_TYPE_PREPAID {
|
||||
diff, err := db.Update(self, func() error {
|
||||
self.BillingType = BILLING_TYPE_POSTPAID
|
||||
self.ExpiredAt = time.Time{}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
}
|
||||
|
||||
return self.SetStatus(userCred, VM_UNKNOWN, "Sync lost")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user