mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
feat: add WithCtx version to notifyclient function
This commit is contained in:
@@ -24,16 +24,19 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/notify"
|
||||
npk "yunion.io/x/onecloud/pkg/mcclient/modules/notify"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -51,7 +54,20 @@ func init() {
|
||||
templatesTable = make(map[string]*template.Template)
|
||||
}
|
||||
|
||||
func getTemplateString(topic string, contType string, channel notify.TNotifyChannel) ([]byte, error) {
|
||||
func getLangSuffix(ctx context.Context) string {
|
||||
lang := httperrors.Lang(ctx)
|
||||
switch lang {
|
||||
case language.English:
|
||||
return "en"
|
||||
case language.Chinese:
|
||||
return "cn"
|
||||
default:
|
||||
return "en"
|
||||
}
|
||||
}
|
||||
|
||||
func getTemplateString(ctx context.Context, topic string, contType string, channel npk.TNotifyChannel) ([]byte, error) {
|
||||
contType = contType + "@" + getLangSuffix(ctx)
|
||||
if len(channel) > 0 {
|
||||
path := filepath.Join(consts.NotifyTemplateDir, consts.GetServiceType(), contType, fmt.Sprintf("%s.%s", topic, string(channel)))
|
||||
cont, err := ioutil.ReadFile(path)
|
||||
@@ -63,13 +79,13 @@ func getTemplateString(topic string, contType string, channel notify.TNotifyChan
|
||||
return ioutil.ReadFile(path)
|
||||
}
|
||||
|
||||
func getTemplate(topic string, contType string, channel notify.TNotifyChannel) (*template.Template, error) {
|
||||
func getTemplate(ctx context.Context, topic string, contType string, channel npk.TNotifyChannel) (*template.Template, error) {
|
||||
key := fmt.Sprintf("%s.%s.%s", topic, contType, channel)
|
||||
templatesTableLock.Lock()
|
||||
defer templatesTableLock.Unlock()
|
||||
|
||||
if _, ok := templatesTable[key]; !ok {
|
||||
cont, err := getTemplateString(topic, contType, channel)
|
||||
cont, err := getTemplateString(ctx, topic, contType, channel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -82,8 +98,8 @@ func getTemplate(topic string, contType string, channel notify.TNotifyChannel) (
|
||||
return templatesTable[key], nil
|
||||
}
|
||||
|
||||
func getContent(topic string, contType string, channel notify.TNotifyChannel, data jsonutils.JSONObject) (string, error) {
|
||||
tmpl, err := getTemplate(topic, contType, channel)
|
||||
func getContent(ctx context.Context, topic string, contType string, channel npk.TNotifyChannel, data jsonutils.JSONObject) (string, error) {
|
||||
tmpl, err := getTemplate(ctx, topic, contType, channel)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -96,22 +112,36 @@ func getContent(topic string, contType string, channel notify.TNotifyChannel, da
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
func Notify(recipientId []string, isGroup bool, priority notify.TNotifyPriority, event string,
|
||||
data jsonutils.JSONObject) {
|
||||
func NotifyWithCtx(ctx context.Context, recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
notify(ctx, recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
func Notify(recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
notify(context.Background(), recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
func notify(ctx context.Context, recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
switch priority {
|
||||
case notify.NotifyPriorityCritical:
|
||||
NotifyCritical(recipientId, isGroup, event, data)
|
||||
case notify.NotifyPriorityImportant:
|
||||
NotifyImportant(recipientId, isGroup, event, data)
|
||||
case npk.NotifyPriorityCritical:
|
||||
notifyCritical(ctx, recipientId, isGroup, event, data)
|
||||
case npk.NotifyPriorityImportant:
|
||||
notifyImportant(ctx, recipientId, isGroup, event, data)
|
||||
default:
|
||||
NotifyNormal(recipientId, isGroup, event, data)
|
||||
notifyNormal(ctx, recipientId, isGroup, event, data)
|
||||
}
|
||||
}
|
||||
|
||||
func RawNotify(recipientId []string, isGroup bool, channel notify.TNotifyChannel, priority notify.TNotifyPriority,
|
||||
event string, data jsonutils.JSONObject) {
|
||||
func RawNotifyWithCtx(ctx context.Context, recipientId []string, isGroup bool, channel npk.TNotifyChannel, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
rawNotify(ctx, recipientId, isGroup, channel, priority, event, data)
|
||||
}
|
||||
|
||||
func RawNotify(recipientId []string, isGroup bool, channel npk.TNotifyChannel, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
rawNotify(context.Background(), recipientId, isGroup, channel, priority, event, data)
|
||||
}
|
||||
|
||||
func rawNotify(ctx context.Context, recipientId []string, isGroup bool, channel npk.TNotifyChannel, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
log.Infof("notify %s event %s priority %s", recipientId, event, priority)
|
||||
msg := notify.SNotifyMessage{}
|
||||
msg := npk.SNotifyMessage{}
|
||||
if isGroup {
|
||||
msg.Gid = recipientId
|
||||
} else {
|
||||
@@ -119,12 +149,12 @@ func RawNotify(recipientId []string, isGroup bool, channel notify.TNotifyChannel
|
||||
}
|
||||
msg.Priority = priority
|
||||
msg.ContactType = channel
|
||||
topic, _ := getContent(event, "title", channel, data)
|
||||
topic, _ := getContent(ctx, event, "title", channel, data)
|
||||
if len(topic) == 0 {
|
||||
topic = event
|
||||
}
|
||||
msg.Topic = topic
|
||||
body, _ := getContent(event, "content", channel, data)
|
||||
body, _ := getContent(ctx, event, "content", channel, data)
|
||||
if len(body) == 0 {
|
||||
body, _ = data.GetString()
|
||||
}
|
||||
@@ -132,69 +162,103 @@ func RawNotify(recipientId []string, isGroup bool, channel notify.TNotifyChannel
|
||||
// log.Debugf("send notification %s %s", topic, body)
|
||||
notifyClientWorkerMan.Run(func() {
|
||||
s := auth.GetAdminSession(context.Background(), consts.GetRegion(), "")
|
||||
notify.Notifications.Send(s, msg)
|
||||
npk.Notifications.Send(s, msg)
|
||||
}, nil, nil)
|
||||
}
|
||||
|
||||
func NotifyNormal(recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []notify.TNotifyChannel{
|
||||
notify.NotifyByEmail,
|
||||
notify.NotifyByDingTalk,
|
||||
notify.NotifyByWebConsole,
|
||||
notify.NotifyByFeishu,
|
||||
notify.NotifyByWorkwx,
|
||||
notifyNormal(context.Background(), recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func NotifyNormalWithCtx(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
notifyNormal(ctx, recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func notifyNormal(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []npk.TNotifyChannel{
|
||||
npk.NotifyByEmail,
|
||||
npk.NotifyByDingTalk,
|
||||
npk.NotifyByWebConsole,
|
||||
npk.NotifyByFeishu,
|
||||
npk.NotifyByWorkwx,
|
||||
} {
|
||||
RawNotify(recipientId, isGroup,
|
||||
rawNotify(ctx, recipientId, isGroup,
|
||||
c,
|
||||
notify.NotifyPriorityNormal,
|
||||
npk.NotifyPriorityNormal,
|
||||
event, data)
|
||||
}
|
||||
}
|
||||
|
||||
func NotifyImportant(recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []notify.TNotifyChannel{
|
||||
notify.NotifyByEmail,
|
||||
notify.NotifyByDingTalk,
|
||||
notify.NotifyByMobile,
|
||||
notify.NotifyByWebConsole,
|
||||
notify.NotifyByFeishu,
|
||||
notify.NotifyByWorkwx,
|
||||
notifyImportant(context.Background(), recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func NotifyImportantWithCtx(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
notifyImportant(ctx, recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func notifyImportant(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []npk.TNotifyChannel{
|
||||
npk.NotifyByEmail,
|
||||
npk.NotifyByDingTalk,
|
||||
npk.NotifyByMobile,
|
||||
npk.NotifyByWebConsole,
|
||||
npk.NotifyByFeishu,
|
||||
npk.NotifyByWorkwx,
|
||||
} {
|
||||
RawNotify(recipientId, isGroup,
|
||||
rawNotify(ctx, recipientId, isGroup,
|
||||
c,
|
||||
notify.NotifyPriorityImportant,
|
||||
npk.NotifyPriorityImportant,
|
||||
event, data)
|
||||
}
|
||||
}
|
||||
|
||||
func NotifyCritical(recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []notify.TNotifyChannel{
|
||||
notify.NotifyByEmail,
|
||||
notify.NotifyByDingTalk,
|
||||
notify.NotifyByMobile,
|
||||
notify.NotifyByWebConsole,
|
||||
notify.NotifyByFeishu,
|
||||
notify.NotifyByWorkwx,
|
||||
notifyCritical(context.Background(), recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func NotifyCriticalWithCtx(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
notifyCritical(ctx, recipientId, isGroup, event, data)
|
||||
}
|
||||
|
||||
func notifyCritical(ctx context.Context, recipientId []string, isGroup bool, event string, data jsonutils.JSONObject) {
|
||||
for _, c := range []npk.TNotifyChannel{
|
||||
npk.NotifyByEmail,
|
||||
npk.NotifyByDingTalk,
|
||||
npk.NotifyByMobile,
|
||||
npk.NotifyByWebConsole,
|
||||
npk.NotifyByFeishu,
|
||||
npk.NotifyByWorkwx,
|
||||
} {
|
||||
RawNotify(recipientId, isGroup,
|
||||
rawNotify(ctx, recipientId, isGroup,
|
||||
c,
|
||||
notify.NotifyPriorityCritical,
|
||||
npk.NotifyPriorityCritical,
|
||||
event, data)
|
||||
}
|
||||
}
|
||||
|
||||
// NotifyAllWithoutRobot will send messages via all contacnt type from exclude robot contact type such as dingtalk-robot.
|
||||
func NotifyAllWithoutRobot(recipientId []string, isGroup bool, priority notify.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot("no", recipientId, isGroup, priority, event, data)
|
||||
func NotifyAllWithoutRobot(recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot(context.Background(), "no", recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
// NotifyAllWithoutRobot will send messages via all contacnt type from exclude robot contact type such as dingtalk-robot.
|
||||
func NotifyAllWithoutRobotWithCtx(ctx context.Context, recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot(ctx, "no", recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
// NotifyRobot will send messages via all robot contact type such as dingtalk-robot.
|
||||
func NotifyRobot(recipientId []string, isGroup bool, priority notify.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot("only", recipientId, isGroup, priority, event, data)
|
||||
func NotifyRobot(recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot(context.Background(), "only", recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
func notifyRobot(robot string, recipientId []string, isGroup bool, priority notify.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
s := auth.GetAdminSession(context.Background(), consts.GetRegion(), "")
|
||||
// NotifyRobot will send messages via all robot contact type such as dingtalk-robot.
|
||||
func NotifyRobotWithCtx(ctx context.Context, recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
return notifyRobot(ctx, "only", recipientId, isGroup, priority, event, data)
|
||||
}
|
||||
|
||||
func notifyRobot(ctx context.Context, robot string, recipientId []string, isGroup bool, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) error {
|
||||
s := auth.GetAdminSession(ctx, consts.GetRegion(), "")
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("robot", jsonutils.NewString(robot))
|
||||
result, err := modules.NotifyConfig.PerformClassAction(s, "get-types", params)
|
||||
@@ -204,21 +268,37 @@ func notifyRobot(robot string, recipientId []string, isGroup bool, priority noti
|
||||
jarray, _ := result.Get("types")
|
||||
cTypes := jarray.(*jsonutils.JSONArray).GetStringArray()
|
||||
for _, ct := range cTypes {
|
||||
RawNotify(recipientId, isGroup, notify.TNotifyChannel(ct), priority, event, data)
|
||||
RawNotifyWithCtx(ctx, recipientId, isGroup, npk.TNotifyChannel(ct), priority, event, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SystemNotify(priority notify.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
func SystemNotify(priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
systemNotify(context.Background(), priority, event, data)
|
||||
}
|
||||
|
||||
func SystemNotifyWithCtx(ctx context.Context, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
systemNotify(ctx, priority, event, data)
|
||||
}
|
||||
|
||||
func systemNotify(ctx context.Context, priority npk.TNotifyPriority, event string, data jsonutils.JSONObject) {
|
||||
// userId
|
||||
Notify(notifyAdminUsers, false, priority, event, data)
|
||||
notify(ctx, notifyAdminUsers, false, priority, event, data)
|
||||
|
||||
// groupId
|
||||
Notify(notifyAdminGroups, true, priority, event, data)
|
||||
notify(ctx, notifyAdminGroups, true, priority, event, data)
|
||||
}
|
||||
|
||||
func NotifyGeneralSystemError(data jsonutils.JSONObject) {
|
||||
SystemNotify(notify.NotifyPriorityCritical, SYSTEM_ERROR, data)
|
||||
notifyGeneralSystemError(context.Background(), data)
|
||||
}
|
||||
|
||||
func NotifyGeneralSystemErrorWithCtx(ctx context.Context, data jsonutils.JSONObject) {
|
||||
notifyGeneralSystemError(ctx, data)
|
||||
}
|
||||
|
||||
func notifyGeneralSystemError(ctx context.Context, data jsonutils.JSONObject) {
|
||||
systemNotify(ctx, npk.NotifyPriorityCritical, SYSTEM_ERROR, data)
|
||||
}
|
||||
|
||||
type SSystemEventMsg struct {
|
||||
@@ -230,6 +310,14 @@ type SSystemEventMsg struct {
|
||||
}
|
||||
|
||||
func NotifySystemError(idstr string, name string, event string, reason string) {
|
||||
notifySystemError(context.Background(), idstr, name, event, reason)
|
||||
}
|
||||
|
||||
func NotifySystemErrorWithCtx(ctx context.Context, idstr string, name string, event string, reason string) {
|
||||
notifySystemError(ctx, idstr, name, event, reason)
|
||||
}
|
||||
|
||||
func notifySystemError(ctx context.Context, idstr string, name string, event string, reason string) {
|
||||
msg := SSystemEventMsg{
|
||||
Id: idstr,
|
||||
Name: name,
|
||||
@@ -237,10 +325,18 @@ func NotifySystemError(idstr string, name string, event string, reason string) {
|
||||
Reason: reason,
|
||||
Created: time.Now(),
|
||||
}
|
||||
SystemNotify(notify.NotifyPriorityCritical, SYSTEM_ERROR, jsonutils.Marshal(msg))
|
||||
systemNotify(ctx, npk.NotifyPriorityCritical, SYSTEM_ERROR, jsonutils.Marshal(msg))
|
||||
}
|
||||
|
||||
func NotifySystemWarning(idstr string, name string, event string, reason string) {
|
||||
notifySystemWarning(context.Background(), idstr, name, event, reason)
|
||||
}
|
||||
|
||||
func NotifySystemWarningWithCtx(ctx context.Context, idstr string, name string, event string, reason string) {
|
||||
notifySystemWarning(ctx, idstr, name, event, reason)
|
||||
}
|
||||
|
||||
func notifySystemWarning(ctx context.Context, idstr string, name string, event string, reason string) {
|
||||
msg := SSystemEventMsg{
|
||||
Id: idstr,
|
||||
Name: name,
|
||||
@@ -248,7 +344,7 @@ func NotifySystemWarning(idstr string, name string, event string, reason string)
|
||||
Reason: reason,
|
||||
Created: time.Now(),
|
||||
}
|
||||
SystemNotify(notify.NotifyPriorityImportant, SYSTEM_WARNING, jsonutils.Marshal(msg))
|
||||
systemNotify(ctx, npk.NotifyPriorityImportant, SYSTEM_WARNING, jsonutils.Marshal(msg))
|
||||
}
|
||||
|
||||
func parseIdName(idName string) (string, string) {
|
||||
|
||||
@@ -2286,7 +2286,7 @@ func (manager *SDiskManager) AutoDiskSnapshot(ctx context.Context, userCred mccl
|
||||
onFail:
|
||||
db.OpsLog.LogEvent(disk, db.ACT_DISK_AUTO_SNAPSHOT_FAIL, err.Error(), userCred)
|
||||
reason := fmt.Sprintf("Disk auto create snapshot failed: %s", err.Error())
|
||||
notifyclient.NotifySystemError(disk.Id, disk.Name, db.ACT_DISK_AUTO_SNAPSHOT_FAIL, reason)
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, disk.Id, disk.Name, db.ACT_DISK_AUTO_SNAPSHOT_FAIL, reason)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ func (self *SGuest) PerformEvent(ctx context.Context, userCred mcclient.TokenCre
|
||||
db.OpsLog.LogEvent(self, db.ACT_GUEST_PANICKED, data.String(), userCred)
|
||||
logclient.AddSimpleActionLog(self, logclient.ACT_GUEST_PANICKED, data.String(), userCred, true)
|
||||
self.NotifyServerEvent(
|
||||
ctx,
|
||||
userCred,
|
||||
notifyclient.SERVER_PANICKED,
|
||||
notify.NotifyPriorityNormal,
|
||||
@@ -820,7 +821,7 @@ func (self *SGuest) StartGuestDeployTask(
|
||||
}
|
||||
|
||||
func (self *SGuest) NotifyServerEvent(
|
||||
userCred mcclient.TokenCredential, event string, priority notify.TNotifyPriority,
|
||||
ctx context.Context, userCred mcclient.TokenCredential, event string, priority notify.TNotifyPriority,
|
||||
loginInfo bool, kwargs *jsonutils.JSONDict, notifyAdmin bool,
|
||||
) {
|
||||
meta, err := self.GetAllMetadata(nil)
|
||||
@@ -860,9 +861,9 @@ func (self *SGuest) NotifyServerEvent(
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyclient.Notify([]string{userCred.GetUserId()}, false, priority, event, kwargs)
|
||||
notifyclient.NotifyWithCtx(ctx, []string{userCred.GetUserId()}, false, priority, event, kwargs)
|
||||
if notifyAdmin {
|
||||
notifyclient.SystemNotify(priority, event, kwargs)
|
||||
notifyclient.SystemNotifyWithCtx(ctx, priority, event, kwargs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +877,7 @@ func (self *SGuest) NotifyAdminServerEvent(ctx context.Context, event string, pr
|
||||
} else {
|
||||
kwargs.Add(jsonutils.NewString(self.ProjectId), "tenant")
|
||||
}
|
||||
notifyclient.SystemNotify(priority, event, kwargs)
|
||||
notifyclient.SystemNotifyWithCtx(ctx, priority, event, kwargs)
|
||||
}
|
||||
|
||||
func (self *SGuest) StartGuestStopTask(ctx context.Context, userCred mcclient.TokenCredential, isForce bool, parentTaskId string) error {
|
||||
|
||||
@@ -129,7 +129,7 @@ func (self *DiskBatchCreateTask) SaveScheduleResult(ctx context.Context, obj ISc
|
||||
disk.SetStatus(self.UserCred, api.DISK_ALLOC_FAILED, err.Error())
|
||||
self.SetStageFailed(ctx, jsonutils.Marshal(err))
|
||||
db.OpsLog.LogEvent(disk, db.ACT_ALLOCATE_FAIL, err, self.UserCred)
|
||||
notifyclient.NotifySystemError(disk.Id, disk.Name, api.DISK_ALLOC_FAILED, err.Error())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, disk.Id, disk.Name, api.DISK_ALLOC_FAILED, err.Error())
|
||||
}
|
||||
|
||||
diskConfig, err := self.GetFirstDisk()
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAccountCreateTask) taskFail(ctx context.Context, elastic
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACCOUNT_STATUS_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACCOUNT_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_ACCOUNT_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAccountDeleteTask) taskFail(ctx context.Context, ea *mod
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ea, db.ACT_DELETE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_DELETE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ea.Id, ea.Name, api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ func (self *ElasticcacheAccountResetPasswordTask) taskFail(ctx context.Context,
|
||||
}
|
||||
db.OpsLog.LogEvent(ea, db.ACT_RESET_PASSWORD, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_RESET_PASSWORD, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ea.Id, ea.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAclCreateTask) taskFail(ctx context.Context, ea *models.
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACL_STATUS_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ea, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAclDeleteTask) taskFail(ctx context.Context, ea *models.
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACL_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ea, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_DELETE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAclUpdateTask) taskFail(ctx context.Context, ea *models.
|
||||
ea.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ea, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ea, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ea.Id, ea.Name, api.ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheAllocatePublicConnectionTask) taskFail(ctx context.Conte
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGING, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_ALLOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheBackupCreateTask) taskFail(ctx context.Context, elasticc
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheBackupRestoreInstanceTask) taskFail(ctx context.Context,
|
||||
eb.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(eb, db.ACT_CONVERT_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, eb, logclient.ACT_RESTORE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(eb.Id, eb.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, eb.Id, eb.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheChangeSpecTask) taskFail(ctx context.Context, ec *models
|
||||
ec.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ec, db.ACT_CHANGE_FLAVOR, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ec, logclient.ACT_VM_CHANGE_FLAVOR, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ec.Id, ec.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ec.Id, ec.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheCreateTask) taskFail(ctx context.Context, elasticcache *
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheDeleteTask) taskFail(ctx context.Context, elasticcache *
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RELEASE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_DELETE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_RELEASE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_RELEASE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheFlushInstanceTask) taskFail(ctx context.Context, elastic
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_FLUSHING_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_FLUSH_INSTANCE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_FLUSH_INSTANCE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_FLUSHING_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_FLUSHING_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheParameterUpdateTask) taskFail(ctx context.Context, ep *m
|
||||
ep.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_PARAMETER_STATUS_UPDATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(ep, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, ep, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(ep.Id, ep.Name, api.ELASTIC_CACHE_PARAMETER_STATUS_UPDATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, ep.Id, ep.Name, api.ELASTIC_CACHE_PARAMETER_STATUS_UPDATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheReleasePublicConnectionTask) taskFail(ctx context.Contex
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGING, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheRestartTask) taskFail(ctx context.Context, elasticcache
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_RESTART_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_RESTART_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_VM_RESTART, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_RESTART_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_RESTART_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheSetMaintainTimeTask) taskFail(ctx context.Context, elast
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheSyncTask) taskFail(ctx context.Context, elasticcache *mo
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_SYNC_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_SYNC_CONF, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_SYNC_CONF, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_SYNC_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_SYNC_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheUpdateAuthModeTask) taskFail(ctx context.Context, elasti
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *ElasticcacheUpdateBackupPolicyTask) taskFail(ctx context.Context, el
|
||||
elasticcache.SetStatus(self.GetUserCred(), api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(elasticcache, db.ACT_UPDATE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, elasticcache, logclient.ACT_UPDATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, elasticcache.Id, elasticcache.Name, api.ELASTIC_CACHE_STATUS_CHANGE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ func (self *GuestBatchCreateTask) SaveScheduleResult(ctx context.Context, obj IS
|
||||
self.clearPendingUsage(ctx, guest)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ALLOCATE_FAIL, err, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, obj, logclient.ACT_ALLOCATE, err, self.GetUserCred(), false)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_CREATE_FAILED, err.Error())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_CREATE_FAILED, err.Error())
|
||||
self.SetStageFailed(ctx, jsonutils.Marshal(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (self *GuestCreateTask) OnDiskPreparedFailed(ctx context.Context, obj db.IS
|
||||
guest.SetStatus(self.UserCred, api.VM_DISK_FAILED, "allocation failed")
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ALLOCATE_FAIL, data, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_ALLOCATE, data, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_DISK_FAILED, data.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_DISK_FAILED, data.String())
|
||||
self.SetStageFailed(ctx, data)
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (self *GuestCreateTask) OnCdromPreparedFailed(ctx context.Context, obj db.I
|
||||
guest.SetStatus(self.UserCred, api.VM_DISK_FAILED, "")
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ALLOCATE_FAIL, data, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_ALLOCATE, data, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_DISK_FAILED, fmt.Sprintf("cdrom_failed %s", data))
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_DISK_FAILED, fmt.Sprintf("cdrom_failed %s", data))
|
||||
self.SetStageFailed(ctx, data)
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func (self *GuestCreateTask) OnDeployGuestDescComplete(ctx context.Context, obj
|
||||
|
||||
func (self *GuestCreateTask) notifyServerCreated(ctx context.Context, guest *models.SGuest) {
|
||||
guest.NotifyServerEvent(
|
||||
self.UserCred, notifyclient.SERVER_CREATED,
|
||||
ctx, self.UserCred, notifyclient.SERVER_CREATED,
|
||||
notify.NotifyPriorityImportant, true, nil, false,
|
||||
)
|
||||
guest.NotifyAdminServerEvent(ctx, notifyclient.SERVER_CREATED_ADMIN, notify.NotifyPriorityImportant)
|
||||
@@ -152,7 +152,7 @@ func (self *GuestCreateTask) OnDeployGuestDescCompleteFailed(ctx context.Context
|
||||
guest.SetStatus(self.UserCred, api.VM_DEPLOY_FAILED, "deploy_failed")
|
||||
db.OpsLog.LogEvent(guest, db.ACT_ALLOCATE_FAIL, data, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_ALLOCATE, data, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_DEPLOY_FAILED, data.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_DEPLOY_FAILED, data.String())
|
||||
self.SetStageFailed(ctx, data)
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func (self *GuestCreateTask) OnDeployEipCompleteFailed(ctx context.Context, obj
|
||||
guest.SetStatus(self.UserCred, api.VM_ASSOCIATE_EIP_FAILED, "deploy_failed")
|
||||
db.OpsLog.LogEvent(guest, db.ACT_EIP_ATTACH, data, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_EIP_ASSOCIATE, data, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_ASSOCIATE_EIP_FAILED, data.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_ASSOCIATE_EIP_FAILED, data.String())
|
||||
self.SetStageFailed(ctx, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -321,6 +321,7 @@ func (self *GuestDeleteTask) DeleteGuest(ctx context.Context, guest *models.SGue
|
||||
|
||||
func (self *GuestDeleteTask) NotifyServerDeleted(ctx context.Context, guest *models.SGuest) {
|
||||
guest.NotifyServerEvent(
|
||||
ctx,
|
||||
self.UserCred,
|
||||
notifyclient.SERVER_DELETED,
|
||||
notify.NotifyPriorityImportant,
|
||||
|
||||
@@ -475,7 +475,7 @@ func (self *GuestMigrateTask) TaskFailed(ctx context.Context, guest *models.SGue
|
||||
db.OpsLog.LogEvent(guest, db.ACT_MIGRATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_MIGRATE, reason, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, reason)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_MIGRATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_MIGRATE_FAILED, reason.String())
|
||||
}
|
||||
|
||||
//ManagedGuestMigrateTask
|
||||
@@ -527,7 +527,7 @@ func (self *ManagedGuestMigrateTask) OnMigrateCompleteFailed(ctx context.Context
|
||||
db.OpsLog.LogEvent(guest, db.ACT_MIGRATE_FAIL, data, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_MIGRATE, data, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, data)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_MIGRATE_FAILED, data.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_MIGRATE_FAILED, data.String())
|
||||
}
|
||||
|
||||
//ManagedGuestLiveMigrateTask
|
||||
@@ -565,5 +565,5 @@ func (self *ManagedGuestLiveMigrateTask) OnMigrateCompleteFailed(ctx context.Con
|
||||
db.OpsLog.LogEvent(guest, db.ACT_MIGRATE_FAIL, data, self.UserCred)
|
||||
logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_MIGRATE, data, self.UserCred, false)
|
||||
self.SetStageFailed(ctx, data)
|
||||
notifyclient.NotifySystemError(guest.Id, guest.Name, api.VM_MIGRATE_FAILED, data.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.Id, guest.Name, api.VM_MIGRATE_FAILED, data.String())
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ func (self *GuestRebuildRootTask) OnRebuildAllDisksComplete(ctx context.Context,
|
||||
}
|
||||
db.OpsLog.LogEvent(guest, db.ACT_REBUILD_ROOT, "", self.UserCred)
|
||||
guest.NotifyServerEvent(
|
||||
ctx,
|
||||
self.UserCred,
|
||||
notifyclient.SERVER_REBUILD_ROOT,
|
||||
notify.NotifyPriorityImportant,
|
||||
|
||||
@@ -64,7 +64,7 @@ func (self *InstanceSnapshotCreateTask) taskFail(
|
||||
|
||||
db.OpsLog.LogEvent(isp, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, isp, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(isp.GetId(), isp.Name, compute.INSTANCE_SNAPSHOT_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, isp.GetId(), isp.Name, compute.INSTANCE_SNAPSHOT_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ func (self *InstanceSnapshotResetTask) taskFail(
|
||||
|
||||
db.OpsLog.LogEvent(guest, db.ACT_VM_RESET_SNAPSHOT_FAILED, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_VM_RESET, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(guest.GetId(), isp.Name, compute.VM_SNAPSHOT_RESET_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, guest.GetId(), isp.Name, compute.VM_SNAPSHOT_RESET_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerAclCreateTask) taskFail(ctx context.Context, lbacl *mode
|
||||
lbacl.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbacl, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbacl.Id, lbacl.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbacl.Id, lbacl.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerAclDeleteTask) taskFail(ctx context.Context, lbacl *mode
|
||||
lbacl.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbacl, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbacl.Id, lbacl.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbacl.Id, lbacl.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerAclSyncTask) taskFail(ctx context.Context, lbacl *models
|
||||
lbacl.SetStatus(self.GetUserCred(), api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbacl, db.ACT_SYNC_CONF, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_SYNC_CONF, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbacl.Id, lbacl.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbacl.Id, lbacl.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerBackendCreateTask) taskFail(ctx context.Context, lbb *mo
|
||||
lbb.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbb, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbb, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbb.Id, lbb.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbb.Id, lbb.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
lbbg := lbb.GetLoadbalancerBackendGroup()
|
||||
if lbbg != nil {
|
||||
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_LB_ADD_BACKEND, reason, self.UserCred, false)
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerBackendSyncTask) taskFail(ctx context.Context, lbb *mode
|
||||
lbb.SetStatus(self.GetUserCred(), api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbb, db.ACT_SYNC_CONF, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbb, logclient.ACT_SYNC_CONF, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbb.Id, lbb.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbb.Id, lbb.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
lbbg := lbb.GetLoadbalancerBackendGroup()
|
||||
if lbbg != nil {
|
||||
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACL_LB_SYNC_BACKEND_CONF, reason, self.UserCred, false)
|
||||
|
||||
@@ -56,7 +56,7 @@ func (self *LoadbalancerLoadbalancerBackendGroupCreateTask) taskFail(ctx context
|
||||
lbacl.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbacl, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbacl.Id, lbacl.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbacl.Id, lbacl.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerBackendGroupDeleteTask) taskFail(ctx context.Context, lb
|
||||
lbbg.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbbg, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbbg.Id, lbbg.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbbg.Id, lbbg.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerCertificateCreateTask) taskFail(ctx context.Context, lbc
|
||||
lbcert.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbcert, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbcert.Id, lbcert.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbcert.Id, lbcert.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerCertificateDeleteTask) taskFail(ctx context.Context, lbc
|
||||
lbcert.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbcert, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbcert.Id, lbcert.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbcert.Id, lbcert.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerCreateTask) taskFail(ctx context.Context, lb *models.SLo
|
||||
lb.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lb, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lb.Id, lb.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerDeleteTask) taskFail(ctx context.Context, lb *models.SLo
|
||||
lb.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lb, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lb.Id, lb.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ func (self *LoadbalancerListenerCreateTask) taskFail(ctx context.Context, lblis
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerDeleteTask) taskFail(ctx context.Context, lblis
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ func (self *LoadbalancerListenerRuleCreateTask) taskFail(ctx context.Context, lb
|
||||
lbr.SetStatus(self.GetUserCred(), api.LB_CREATE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbr, db.ACT_ALLOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_CREATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbr.Id, lbr.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbr.Id, lbr.Name, api.LB_CREATE_FAILED, reason.String())
|
||||
lblis := lbr.GetLoadbalancerListener()
|
||||
if lblis != nil {
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_LB_ADD_LISTENER_RULE, reason, self.UserCred, false)
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerRuleDeleteTask) taskFail(ctx context.Context, lb
|
||||
lbr.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lbr, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lbr.Id, lbr.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lbr.Id, lbr.Name, api.LB_STATUS_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerStartTask) taskFail(ctx context.Context, lblis *
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_DISABLED, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_ENABLE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_ENABLE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_STATUS_DISABLED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_STATUS_DISABLED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerStopTask) taskFail(ctx context.Context, lblis *m
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_DISABLE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DISABLE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_STATUS_ENABLED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_STATUS_ENABLED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerSyncTask) taskFail(ctx context.Context, lblis *m
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_SYNC_CONF, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_SYNC_CONF, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerListenerSyncstatusTask) taskFail(ctx context.Context, lb
|
||||
lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_UNKNOWN, reason.String())
|
||||
db.OpsLog.LogEvent(lblis, db.ACT_SYNC_STATUS, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_SYNC_STATUS, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lblis.Id, lblis.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerStartTask) taskFail(ctx context.Context, lb *models.SLoa
|
||||
lb.SetStatus(self.GetUserCred(), api.LB_STATUS_DISABLED, reason.String())
|
||||
db.OpsLog.LogEvent(lb, db.ACT_ENABLE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_ENABLE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_STATUS_DISABLED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lb.Id, lb.Name, api.LB_STATUS_DISABLED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerStopTask) taskFail(ctx context.Context, lb *models.SLoad
|
||||
lb.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, reason.String())
|
||||
db.OpsLog.LogEvent(lb, db.ACT_DISABLE, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DISABLE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_STATUS_ENABLED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lb.Id, lb.Name, api.LB_STATUS_ENABLED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (self *LoadbalancerSyncstatusTask) taskFail(ctx context.Context, lb *models
|
||||
lb.SetStatus(self.GetUserCred(), api.LB_STATUS_UNKNOWN, reason.String())
|
||||
db.OpsLog.LogEvent(lb, db.ACT_SYNC_STATUS, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_SYNC_STATUS, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, lb.Id, lb.Name, api.LB_SYNC_CONF_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func (self *SSchedTask) OnScheduleFailCallback(ctx context.Context, obj ISchedul
|
||||
obj.SetStatus(self.GetUserCred(), api.VM_SCHEDULE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(obj, db.ACT_ALLOCATE_FAIL, reason, self.GetUserCred())
|
||||
logclient.AddActionLogWithStartable(self, obj, logclient.ACT_ALLOCATE, reason, self.GetUserCred(), false)
|
||||
notifyclient.NotifySystemError(obj.GetId(), obj.GetName(), api.VM_SCHEDULE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, obj.GetId(), obj.GetName(), api.VM_SCHEDULE_FAILED, reason.String())
|
||||
}
|
||||
|
||||
func (self *SSchedTask) OnScheduleComplete(ctx context.Context, items []db.IStandaloneModel, data *jsonutils.JSONDict) {
|
||||
|
||||
@@ -39,7 +39,7 @@ func (self *SnapshotPolicyDeleteTask) taskFail(ctx context.Context, sp *models.S
|
||||
sp.SetStatus(self.GetUserCred(), api.SNAPSHOT_POLICY_DELETE_FAILED, reason.String())
|
||||
db.OpsLog.LogEvent(sp, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, sp, logclient.ACT_DELOCATE, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(sp.Id, sp.Name, api.SNAPSHOT_POLICY_DELETE_FAILED, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, sp.Id, sp.Name, api.SNAPSHOT_POLICY_DELETE_FAILED, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (self *SnapshotPolicyApplyTask) taskFail(ctx context.Context, disk *models.
|
||||
|
||||
db.OpsLog.LogEvent(disk, db.ACT_APPLY_SNAPSHOT_POLICY_FAILED, reason, self.UserCred)
|
||||
logclient.AddActionLogWithStartable(self, disk, logclient.ACT_APPLY_SNAPSHOT_POLICY, reason, self.UserCred, false)
|
||||
notifyclient.NotifySystemError(disk.GetId(), disk.Name, compute.DISK_APPLY_SNAPSHOT_FAIL, reason.String())
|
||||
notifyclient.NotifySystemErrorWithCtx(ctx, disk.GetId(), disk.Name, compute.DISK_APPLY_SNAPSHOT_FAIL, reason.String())
|
||||
self.SetStageFailed(ctx, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -100,15 +100,7 @@ func formatDetails(ctx context.Context, errData httputils.Error, msg string) str
|
||||
if errData.Id == "" {
|
||||
details = msg
|
||||
} else {
|
||||
var (
|
||||
langv = ctx.Value(ctxLangKey)
|
||||
lang language.Tag
|
||||
)
|
||||
if langv != nil {
|
||||
lang = langv.(language.Tag)
|
||||
} else {
|
||||
lang = language.English
|
||||
}
|
||||
lang := Lang(ctx)
|
||||
a := make([]interface{}, len(errData.Fields))
|
||||
for i := range errData.Fields {
|
||||
a[i] = errData.Fields[i]
|
||||
@@ -118,6 +110,19 @@ func formatDetails(ctx context.Context, errData httputils.Error, msg string) str
|
||||
return details
|
||||
}
|
||||
|
||||
func Lang(ctx context.Context) language.Tag {
|
||||
var (
|
||||
langv = ctx.Value(ctxLangKey)
|
||||
lang language.Tag
|
||||
)
|
||||
if langv != nil {
|
||||
lang = langv.(language.Tag)
|
||||
} else {
|
||||
lang = language.English
|
||||
}
|
||||
return lang
|
||||
}
|
||||
|
||||
func HTTPError(ctx context.Context, w http.ResponseWriter, msg string, statusCode int, class string, errData httputils.Error) {
|
||||
details := formatDetails(ctx, errData, msg)
|
||||
if statusCode >= 300 && statusCode <= 400 {
|
||||
|
||||
@@ -61,8 +61,8 @@ func (self *ImageConvertTask) OnInit(ctx context.Context, obj db.IStandaloneMode
|
||||
if err == nil {
|
||||
kwargs.Set("os_type", jsonutils.NewString(osType.Value))
|
||||
}
|
||||
notifyclient.SystemNotify(notify.NotifyPriorityNormal, notifyclient.IMAGE_ACTIVED, kwargs)
|
||||
notifyclient.NotifyImportant([]string{self.UserCred.GetUserId()}, false, notifyclient.IMAGE_ACTIVED, kwargs)
|
||||
notifyclient.SystemNotifyWithCtx(ctx, notify.NotifyPriorityNormal, notifyclient.IMAGE_ACTIVED, kwargs)
|
||||
notifyclient.NotifyImportantWithCtx(ctx, []string{self.UserCred.GetUserId()}, false, notifyclient.IMAGE_ACTIVED, kwargs)
|
||||
}
|
||||
return nil, err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user