fix: turn delete prepaid vm to postpaid, so as to allow deleting the vm

This commit is contained in:
Qiu Jian
2019-03-19 20:00:22 +08:00
parent 4922d3a876
commit 29245c931c
+12
View File
@@ -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")
}