Merge pull request #1342 in YUNIONIO/onecloud from ~WANYAOQI/onecloud:bugfix/wyq/reslove-conflict0326 to release/2.8.0

* commit '51b40e9ade4a63027b92586e7a120c5f52b7a591':
  梳理 logclient 事件,增加黑名单
This commit is contained in:
张东亮
2019-03-26 18:12:02 +08:00
10 changed files with 29 additions and 16 deletions

View File

@@ -1634,7 +1634,7 @@ func (self *SNetwork) PerformMerge(ctx context.Context, userCred mcclient.TokenC
}
note = map[string]string{"network": self.Id}
db.OpsLog.LogEvent(self, db.ACT_DELETE, note, userCred)
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_DELETE, note, userCred, true)
logclient.AddActionLogWithContext(ctx, self, logclient.ACT_DELOCATE, note, userCred, true)
return nil, nil
}

View File

@@ -234,7 +234,7 @@ func (self *GuestDeleteTask) DoDeleteGuest(ctx context.Context, guest *models.SG
func (self *GuestDeleteTask) OnFailed(ctx context.Context, guest *models.SGuest, err jsonutils.JSONObject) {
guest.SetStatus(self.UserCred, models.VM_DELETE_FAIL, err.String())
db.OpsLog.LogEvent(guest, db.ACT_DELOCATE_FAIL, err, self.UserCred)
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_DELETE, err, self.UserCred, false)
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_DELOCATE, err, self.UserCred, false)
self.SetStageFailed(ctx, err.String())
}
@@ -258,7 +258,7 @@ func (self *GuestDeleteTask) DeleteGuest(ctx context.Context, guest *models.SGue
guest.RealDelete(ctx, self.UserCred)
guest.RemoveAllMetadata(ctx, self.UserCred)
db.OpsLog.LogEvent(guest, db.ACT_DELOCATE, nil, self.UserCred)
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_DELOCATE, nil, self.UserCred, true)
if !guest.IsSystem && !isPendingDeleted {
self.NotifyServerDeleted(ctx, guest)
}

View File

@@ -294,7 +294,7 @@ func (self *SnapshotDeleteTask) OnReloadDiskSnapshot(ctx context.Context, snapsh
func (self *SnapshotDeleteTask) TaskComplete(ctx context.Context, snapshot *models.SSnapshot, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(snapshot, db.ACT_SNAPSHOT_DELETE, snapshot.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, snapshot, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, snapshot, logclient.ACT_DELOCATE, nil, self.UserCred, true)
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerAclDeleteTask) taskFail(ctx context.Context, lbacl *models.SLoadbalancerAcl, reason string) {
lbacl.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lbacl, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lbacl.Id, lbacl.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerAclDeleteTask) OnInit(ctx context.Context, obj db.IStand
func (self *LoadbalancerAclDeleteTask) OnLoadbalancerAclDeleteComplete(ctx context.Context, lbacl *models.SLoadbalancerAcl, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lbacl, db.ACT_DELETE, lbacl.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lbacl, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lbacl.DoPendingDelete(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerBackendGroupDeleteTask) taskFail(ctx context.Context, lbbg *models.SLoadbalancerBackendGroup, reason string) {
lbbg.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lbbg, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lbbg.Id, lbbg.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerBackendGroupDeleteTask) OnInit(ctx context.Context, obj
func (self *LoadbalancerBackendGroupDeleteTask) OnLoadbalancerBackendGroupDeleteComplete(ctx context.Context, lbbg *models.SLoadbalancerBackendGroup, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lbbg, db.ACT_DELETE, lbbg.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lbbg, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lbbg.PreDeleteSubs(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerCertificateDeleteTask) taskFail(ctx context.Context, lbcert *models.SLoadbalancerCertificate, reason string) {
lbcert.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lbcert, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lbcert.Id, lbcert.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerCertificateDeleteTask) OnInit(ctx context.Context, obj d
func (self *LoadbalancerCertificateDeleteTask) OnLoadbalancerCertificateDeleteComplete(ctx context.Context, lbcert *models.SLoadbalancerCertificate, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lbcert, db.ACT_DELETE, lbcert.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lbcert, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lbcert.DoPendingDelete(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerDeleteTask) taskFail(ctx context.Context, lb *models.SLoadbalancer, reason string) {
lb.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lb, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lb.Id, lb.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerDeleteTask) OnInit(ctx context.Context, obj db.IStandalo
func (self *LoadbalancerDeleteTask) OnLoadbalancerDeleteComplete(ctx context.Context, lb *models.SLoadbalancer, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lb, db.ACT_DELETE, lb.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lb, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lb.PendingDelete(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerListenerDeleteTask) taskFail(ctx context.Context, lblis *models.SLoadbalancerListener, reason string) {
lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lblis, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lblis.Id, lblis.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerListenerDeleteTask) OnInit(ctx context.Context, obj db.I
func (self *LoadbalancerListenerDeleteTask) OnLoadbalancerListenerDeleteComplete(ctx context.Context, lblis *models.SLoadbalancerListener, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lblis, db.ACT_DELETE, lblis.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lblis.PreDeleteSubs(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -25,7 +25,7 @@ func init() {
func (self *LoadbalancerListenerRuleDeleteTask) taskFail(ctx context.Context, lbr *models.SLoadbalancerListenerRule, reason string) {
lbr.SetStatus(self.GetUserCred(), api.LB_STATUS_DELETE_FAILED, reason)
db.OpsLog.LogEvent(lbr, db.ACT_DELOCATE_FAIL, reason, self.UserCred)
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_DELETE, reason, self.UserCred, false)
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_DELOCATE, reason, self.UserCred, false)
notifyclient.NotifySystemError(lbr.Id, lbr.Name, api.LB_STATUS_DELETE_FAILED, reason)
self.SetStageFailed(ctx, reason)
}
@@ -45,7 +45,7 @@ func (self *LoadbalancerListenerRuleDeleteTask) OnInit(ctx context.Context, obj
func (self *LoadbalancerListenerRuleDeleteTask) OnLoadbalancerListenerRuleDeleteComplete(ctx context.Context, lbr *models.SLoadbalancerListenerRule, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(lbr, db.ACT_DELETE, lbr.GetShortDesc(ctx), self.UserCred)
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_DELETE, nil, self.UserCred, true)
logclient.AddActionLogWithStartable(self, lbr, logclient.ACT_DELOCATE, nil, self.UserCred, true)
lbr.DoPendingDelete(ctx, self.GetUserCred())
self.SetStageComplete(ctx, nil)
}

View File

@@ -21,6 +21,19 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
// 这些状态不做 websocket 通知
var BlackList = []string{
ACT_CLOUD_FULLSYNC,
ACT_CREATE,
ACT_DELETE,
ACT_PENDING_DELETE,
ACT_PRIVATE,
ACT_PUBLIC,
ACT_UPDATE,
ACT_VM_SYNC_STATUS,
ACT_VM_SYNC_CONF,
}
const (
ACT_ADDTAG = "添加标签"
ACT_ALLOCATE = "分配"