mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
add service tag for actionlog
This commit is contained in:
@@ -283,7 +283,8 @@ func (model *SVirtualResourceBase) PerformCancelDelete(ctx context.Context, user
|
||||
func (model *SVirtualResourceBase) DoCancelPendingDelete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
err := model.CancelPendingDelete(ctx, userCred)
|
||||
if err == nil {
|
||||
OpsLog.LogEvent(model, ACT_CANCEL_DELETE, nil, userCred)
|
||||
OpsLog.LogEvent(model, ACT_CANCEL_DELETE, model.GetShortDesc(ctx), userCred)
|
||||
logclient.AddActionLogWithContext(ctx, model, logclient.ACT_CANCEL_DELETE, model.GetShortDesc(ctx), userCred, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (self *GuestDeployTask) OnDeployGuestComplete(ctx context.Context, obj db.I
|
||||
}
|
||||
if !_log {
|
||||
// 如果 deploy 有其他事件,统一记在这里。
|
||||
logclient.AddActionLogWithStartable(self, guest, "misc部署", self.Params, self.UserCred, true)
|
||||
logclient.AddActionLogWithStartable(self, guest, "misc部署", "", self.UserCred, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ type SActionlogManager struct {
|
||||
type SActionlog struct {
|
||||
db.SOpsLog
|
||||
|
||||
StartTime time.Time `nullable:"false" list:"user" create:"optional"` // = Column(DateTime, nullable=False)
|
||||
Success bool `default:"true" list:"user" create:"required"` // = Column(Boolean, default=True)
|
||||
// Action string `width:"32" charset:"utf8" nullable:"false" list:"user"` //= Column(VARCHAR(32, charset='utf8'), nullable=False)
|
||||
StartTime time.Time `nullable:"false" list:"user" create:"optional"` // = Column(DateTime, nullable=False)
|
||||
Success bool `default:"true" list:"user" create:"required"` // = Column(Boolean, default=True)
|
||||
Service string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"optional"` //= Column(VARCHAR(32, charset='utf8'), nullable=False)
|
||||
}
|
||||
|
||||
var ActonLog *SActionlogManager
|
||||
|
||||
@@ -6,7 +6,7 @@ var (
|
||||
|
||||
func init() {
|
||||
Actions = NewActionManager("action", "actions",
|
||||
[]string{"id", "start_time", "ops_time", "obj_id", "obj_type", "obj_name", "user", "user_id", "tenant", "tenant_id", "owner_tenant_id", "action", "success", "notes"},
|
||||
[]string{"id", "start_time", "service", "ops_time", "obj_id", "obj_type", "obj_name", "user", "user_id", "tenant", "tenant_id", "owner_tenant_id", "action", "success", "notes"},
|
||||
[]string{})
|
||||
register(&Actions)
|
||||
}
|
||||
|
||||
@@ -158,6 +158,11 @@ func addLog(model IObject, action string, iNotes interface{}, userCred mcclient.
|
||||
logentry.Add(jsonutils.NewString(token.GetDomainName()), "domain")
|
||||
logentry.Add(jsonutils.NewString(strings.Join(token.GetRoles(), ",")), "roles")
|
||||
|
||||
service := consts.GetServiceType()
|
||||
if len(service) > 0 {
|
||||
logentry.Add(jsonutils.NewString(service), "service")
|
||||
}
|
||||
|
||||
if !startTime.IsZero() {
|
||||
logentry.Add(jsonutils.NewString(timeutils.FullIsoTime(startTime)), "start_time")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user