mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
避免续费时未刷新虚拟机状态
This commit is contained in:
@@ -36,6 +36,8 @@ const (
|
||||
VM_START_STOP = "start_stop"
|
||||
VM_STOPPING = "stopping"
|
||||
VM_STOP_FAILED = "stop_fail" // # = running
|
||||
VM_RENEWING = "renewing"
|
||||
VM_RENEW_FAILED = "renew_failed"
|
||||
|
||||
VM_BACKUP_STARTING = "backup_starting"
|
||||
VM_BACKUP_CREATING = "backup_creating"
|
||||
|
||||
@@ -99,6 +99,7 @@ const (
|
||||
ACT_BACKUP_ALLOCATE = "backup_allocate"
|
||||
ACT_ALLOCATE_FAIL = "alloc_fail"
|
||||
ACT_BACKUP_ALLOCATE_FAIL = "backup_alloc_fail"
|
||||
ACT_REW_FAIL = "renew_fail"
|
||||
|
||||
ACT_DELOCATING = "delocating"
|
||||
ACT_DELOCATE = "delocate"
|
||||
|
||||
@@ -2711,6 +2711,7 @@ func (self *SGuest) PerformRenew(ctx context.Context, userCred mcclient.TokenCre
|
||||
}
|
||||
|
||||
func (self *SGuest) startGuestRenewTask(ctx context.Context, userCred mcclient.TokenCredential, duration string, parentTaskId string) error {
|
||||
self.SetStatus(userCred, VM_RENEWING, "")
|
||||
data := jsonutils.NewDict()
|
||||
data.Add(jsonutils.NewString(duration), "duration")
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "GuestRenewTask", self, userCred, data, parentTaskId, "", nil)
|
||||
|
||||
@@ -77,6 +77,8 @@ const (
|
||||
VM_START_STOP = api.VM_START_STOP
|
||||
VM_STOPPING = api.VM_STOPPING
|
||||
VM_STOP_FAILED = api.VM_STOP_FAILED // # = running
|
||||
VM_RENEWING = api.VM_RENEWING
|
||||
VM_RENEW_FAILED = api.VM_RENEW_FAILED
|
||||
|
||||
VM_BACKUP_STARTING = api.VM_BACKUP_STARTING
|
||||
VM_BACKUP_CREATING = api.VM_BACKUP_CREATING
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
type GuestRenewTask struct {
|
||||
@@ -46,6 +47,9 @@ func (self *GuestRenewTask) OnInit(ctx context.Context, obj db.IStandaloneModel,
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("RequestRenewInstance failed %s", err)
|
||||
log.Errorf(msg)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_REW_FAIL, msg, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_RENEW, msg, self.UserCred, false)
|
||||
guest.SetStatus(self.GetUserCred(), models.VM_RENEW_FAILED, msg)
|
||||
self.SetStageFailed(ctx, msg)
|
||||
return
|
||||
}
|
||||
@@ -58,6 +62,9 @@ func (self *GuestRenewTask) OnInit(ctx context.Context, obj db.IStandaloneModel,
|
||||
return
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_RENEW, nil, self.UserCred, true)
|
||||
|
||||
guest.StartSyncstatus(ctx, self.UserCred, "")
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ const (
|
||||
ACT_SYNC_CONF = "同步配置"
|
||||
ACT_CREATE_BACKUP = "创建备份机"
|
||||
ACT_SWITCH_TO_BACKUP = "主备切换"
|
||||
ACT_RENEW = "续费"
|
||||
|
||||
ACT_IMAGE_SAVE = "上传镜像"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user