mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #19213 from gouqi11/fixNotifyMissingTopForOperationSuccessed
fix(notify): fix host webhook err
This commit is contained in:
@@ -65,7 +65,9 @@ func init() {
|
||||
Obj: obj,
|
||||
Action: api.SAction(action),
|
||||
ObjDetailsDecorator: func(ctx context.Context, details *jsonutils.JSONDict) {
|
||||
details.Set("customize_details", details)
|
||||
if moreDetails != nil {
|
||||
details.Set("customize_details", moreDetails)
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -90,7 +90,7 @@ func init() {
|
||||
}
|
||||
HostManager.SetVirtualObject(HostManager)
|
||||
HostManager.SetAlias("baremetal", "baremetals")
|
||||
notifyclient.AddNotifyDBHookResources(HostManager.KeywordPlural(), GuestManager.AliasPlural())
|
||||
notifyclient.AddNotifyDBHookResources(HostManager.KeywordPlural(), HostManager.AliasPlural())
|
||||
GuestManager.NameRequireAscii = false
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ func (self *InstanceBackupCreateTask) taskFailed(ctx context.Context, ib *models
|
||||
func (self *InstanceBackupCreateTask) taskSuccess(ctx context.Context, ib *models.SInstanceBackup, guest *models.SGuest) {
|
||||
ib.SetStatus(self.UserCred, compute.INSTANCE_BACKUP_STATUS_READY, "")
|
||||
logclient.AddActionLogWithStartable(self, ib, logclient.ACT_CREATE, nil, self.UserCred, true)
|
||||
self.SetStageComplete(ctx, nil)
|
||||
notifyclient.EventNotify(ctx, self.UserCred, notifyclient.SEventNotifyParam{
|
||||
Obj: guest,
|
||||
Action: notifyclient.ActionCreateBackupServer,
|
||||
})
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
func (self *InstanceBackupCreateTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
|
||||
@@ -394,5 +394,20 @@ func init() {
|
||||
"successfully",
|
||||
"成功",
|
||||
},
|
||||
sI18nElme{
|
||||
string(api.ActionAttach),
|
||||
"attach",
|
||||
"挂载",
|
||||
},
|
||||
sI18nElme{
|
||||
string(api.ActionDetach),
|
||||
"detach",
|
||||
"卸载",
|
||||
},
|
||||
sI18nElme{
|
||||
string(api.ActionCreateBackupServer),
|
||||
"add_backup_server",
|
||||
"添加主机备份",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -273,10 +273,13 @@ func (nm *SNotificationManager) PerformEventNotify(ctx context.Context, userCred
|
||||
}
|
||||
|
||||
receiverIdList := []string{}
|
||||
for k, _ := range receiverIds {
|
||||
for k := range receiverIds {
|
||||
receiverIdList = append(receiverIdList, k)
|
||||
}
|
||||
receivers, err := ReceiverManager.FetchByIdOrNames(ctx, receiverIdList...)
|
||||
if err != nil {
|
||||
return output, errors.Wrap(err, "fetch receiver")
|
||||
}
|
||||
webconsoleContacts := sets.NewString()
|
||||
idSet := sets.NewString()
|
||||
for i := range receivers {
|
||||
@@ -626,7 +629,7 @@ func (n *SNotification) ReceiverNotificationsNotOK() ([]SReceiverNotification, e
|
||||
|
||||
func (n *SNotification) receiveDetails(userCred mcclient.TokenCredential, scope string) ([]api.ReceiveDetail, error) {
|
||||
RQ := ReceiverManager.Query("id", "name")
|
||||
q := ReceiverNotificationManager.Query("receiver_id", "notification_id", "receiver_type", "contact", "send_at", "send_by", "status", "failed_reason").Equals("notification_id", n.Id)
|
||||
q := ReceiverNotificationManager.Query("receiver_id", "notification_id", "receiver_type", "contact", "send_at", "send_by", "status", "failed_reason").Equals("notification_id", n.Id).IsNotEmpty("receiver_id").IsNullOrEmpty("contact")
|
||||
s := rbacscope.TRbacScope(scope)
|
||||
|
||||
switch s {
|
||||
|
||||
+36
-30
@@ -292,6 +292,7 @@ func (sm *STopicManager) InitializeData() error {
|
||||
t.addAction(
|
||||
notify.ActionCreateBackupServer,
|
||||
)
|
||||
t.Results = tristate.True
|
||||
t.Type = notify.TOPIC_TYPE_RESOURCE
|
||||
case DefaultResourceSync:
|
||||
t.addResources(
|
||||
@@ -823,36 +824,41 @@ func init() {
|
||||
)
|
||||
converter.registerAction(
|
||||
map[notify.SAction]int{
|
||||
notify.ActionCreate: 0,
|
||||
notify.ActionDelete: 1,
|
||||
notify.ActionPendingDelete: 2,
|
||||
notify.ActionUpdate: 3,
|
||||
notify.ActionRebuildRoot: 4,
|
||||
notify.ActionResetPassword: 5,
|
||||
notify.ActionChangeConfig: 6,
|
||||
notify.ActionExpiredRelease: 7,
|
||||
notify.ActionExecute: 8,
|
||||
notify.ActionChangeIpaddr: 9,
|
||||
notify.ActionSyncStatus: 10,
|
||||
notify.ActionCleanData: 11,
|
||||
notify.ActionMigrate: 12,
|
||||
notify.ActionCreateBackupServer: 13,
|
||||
notify.ActionDelBackupServer: 14,
|
||||
notify.ActionSyncCreate: 15,
|
||||
notify.ActionSyncUpdate: 16,
|
||||
notify.ActionSyncDelete: 17,
|
||||
notify.ActionOffline: 18,
|
||||
notify.ActionSystemPanic: 19,
|
||||
notify.ActionSystemException: 20,
|
||||
notify.ActionChecksumTest: 21,
|
||||
notify.ActionLock: 22,
|
||||
notify.ActionExceedCount: 23,
|
||||
notify.ActionSyncAccountStatus: 24,
|
||||
notify.ActionPasswordExpireSoon: 25,
|
||||
notify.ActionNetOutOfSync: 26,
|
||||
notify.ActionMysqlOutOfSync: 27,
|
||||
notify.ActionServiceAbnormal: 28,
|
||||
notify.ActionServerPanicked: 29,
|
||||
notify.ActionCreate: 0,
|
||||
notify.ActionDelete: 1,
|
||||
notify.ActionPendingDelete: 2,
|
||||
notify.ActionUpdate: 3,
|
||||
notify.ActionRebuildRoot: 4,
|
||||
notify.ActionResetPassword: 5,
|
||||
notify.ActionChangeConfig: 6,
|
||||
notify.ActionExpiredRelease: 7,
|
||||
notify.ActionExecute: 8,
|
||||
notify.ActionChangeIpaddr: 9,
|
||||
notify.ActionSyncStatus: 10,
|
||||
notify.ActionCleanData: 11,
|
||||
notify.ActionMigrate: 12,
|
||||
notify.ActionCreateBackupServer: 13,
|
||||
notify.ActionDelBackupServer: 14,
|
||||
notify.ActionSyncCreate: 15,
|
||||
notify.ActionSyncUpdate: 16,
|
||||
notify.ActionSyncDelete: 17,
|
||||
notify.ActionOffline: 18,
|
||||
notify.ActionSystemPanic: 19,
|
||||
notify.ActionSystemException: 20,
|
||||
notify.ActionChecksumTest: 21,
|
||||
notify.ActionLock: 22,
|
||||
notify.ActionExceedCount: 23,
|
||||
notify.ActionSyncAccountStatus: 24,
|
||||
notify.ActionPasswordExpireSoon: 25,
|
||||
notify.ActionNetOutOfSync: 26,
|
||||
notify.ActionMysqlOutOfSync: 27,
|
||||
notify.ActionServiceAbnormal: 28,
|
||||
notify.ActionServerPanicked: 29,
|
||||
notify.ActionAttach: 30,
|
||||
notify.ActionDetach: 31,
|
||||
notify.ActionIsolatedDeviceCreate: 32,
|
||||
notify.ActionIsolatedDeviceUpdate: 33,
|
||||
notify.ActionIsolatedDeviceDelete: 34,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user