mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +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 {
|
func (model *SVirtualResourceBase) DoCancelPendingDelete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||||
err := model.CancelPendingDelete(ctx, userCred)
|
err := model.CancelPendingDelete(ctx, userCred)
|
||||||
if err == nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ func (self *GuestDeployTask) OnDeployGuestComplete(ctx context.Context, obj db.I
|
|||||||
}
|
}
|
||||||
if !_log {
|
if !_log {
|
||||||
// 如果 deploy 有其他事件,统一记在这里。
|
// 如果 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 {
|
type SActionlog struct {
|
||||||
db.SOpsLog
|
db.SOpsLog
|
||||||
|
|
||||||
StartTime time.Time `nullable:"false" list:"user" create:"optional"` // = Column(DateTime, 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)
|
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)
|
Service string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"optional"` //= Column(VARCHAR(32, charset='utf8'), nullable=False)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ActonLog *SActionlogManager
|
var ActonLog *SActionlogManager
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Actions = NewActionManager("action", "actions",
|
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{})
|
[]string{})
|
||||||
register(&Actions)
|
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(token.GetDomainName()), "domain")
|
||||||
logentry.Add(jsonutils.NewString(strings.Join(token.GetRoles(), ",")), "roles")
|
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() {
|
if !startTime.IsZero() {
|
||||||
logentry.Add(jsonutils.NewString(timeutils.FullIsoTime(startTime)), "start_time")
|
logentry.Add(jsonutils.NewString(timeutils.FullIsoTime(startTime)), "start_time")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user