mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #786 from wanyaoqi/bugfix/wyq/fix-guest-delete-backup-logevent
bugfix: fix guest delele backup log event
This commit is contained in:
@@ -49,6 +49,8 @@ const (
|
||||
ACT_START_CREATE_BACKUP = "start_create_backup"
|
||||
ACT_CREATE_BACKUP = "create_backup"
|
||||
ACT_CREATE_BACKUP_FAILED = "create_backup_failed"
|
||||
ACT_DELETE_BACKUP = "delete_backup"
|
||||
ACT_DELETE_BACKUP_FAILED = "delete_backup_failed"
|
||||
|
||||
ACT_UPDATE_STATUS = "updatestatus"
|
||||
ACT_STARTING = "starting"
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -90,6 +91,10 @@ func (self *GuestDeleteOnHostTask) OnStopGuest(ctx context.Context, guest *model
|
||||
}
|
||||
}
|
||||
|
||||
func (self *GuestDeleteOnHostTask) OnUnDeployGuestFailed(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
|
||||
self.OnFail(ctx, guest, data.String())
|
||||
}
|
||||
|
||||
func (self *GuestDeleteOnHostTask) OnUnDeployGuest(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
|
||||
hostId, _ := self.Params.GetString("host_id")
|
||||
if guest.BackupHostId == hostId {
|
||||
@@ -101,6 +106,8 @@ func (self *GuestDeleteOnHostTask) OnUnDeployGuest(ctx context.Context, guest *m
|
||||
self.OnFail(ctx, guest, err.Error())
|
||||
return
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_DELETE_BACKUP, "GuestDeleteOnHost", self.UserCred, true)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_DELETE_BACKUP, "GuestDeleteOnHost", self.UserCred)
|
||||
}
|
||||
self.SetStage("OnSync", nil)
|
||||
guest.StartSyncTask(ctx, self.UserCred, false, self.GetTaskId())
|
||||
@@ -111,6 +118,11 @@ func (self *GuestDeleteOnHostTask) OnSync(ctx context.Context, guest *models.SGu
|
||||
}
|
||||
|
||||
func (self *GuestDeleteOnHostTask) OnFail(ctx context.Context, guest *models.SGuest, reason string) {
|
||||
hostId, _ := self.Params.GetString("host_id")
|
||||
if guest.BackupHostId == hostId {
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_DELETE_BACKUP, "GuestDeleteOnHost", self.UserCred, false)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_DELETE_BACKUP_FAILED, "GuestDeleteOnHost", self.UserCred)
|
||||
}
|
||||
failedStatus, _ := self.Params.GetString("failed_status")
|
||||
if len(failedStatus) > 0 {
|
||||
guest.SetStatus(self.UserCred, failedStatus, reason)
|
||||
|
||||
@@ -135,6 +135,7 @@ const (
|
||||
ACT_LB_REMOVE_BACKEND = "移除后端服务器"
|
||||
ACT_LB_ADD_LISTENER_RULE = "添加负载均衡转发规则"
|
||||
ACT_LB_REMOVE_LISTENER_RULE = "移除负载均衡转发规则"
|
||||
ACT_DELETE_BACKUP = "删除备份机"
|
||||
|
||||
ACT_IMAGE_SAVE = "上传镜像"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user