Skip to content

Commit

Permalink
feat(common): log support rebilling (#18737)
Browse files Browse the repository at this point in the history
Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
  • Loading branch information
gouqi11 and 马鸿飞 authored Nov 20, 2023
1 parent 677e0f9 commit 91dac7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/cloudcommon/db/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const (
TAG_DELETE_RANGE_ALL = "all"

OBJECT_TYPE_ID_SEP = "::"

RE_BILLING_AT = "__re_billing_at"
)

type SMetadataManager struct {
Expand Down Expand Up @@ -524,6 +526,14 @@ func (manager *SMetadataManager) SetValuesWithLog(ctx context.Context, obj IMode
}
if len(changes) > 0 {
OpsLog.LogEvent(obj.GetIModel(), ACT_SET_METADATA, jsonutils.Marshal(changes), userCred)
for _, change := range changes {
if change.Key == RE_BILLING_AT {
desc := obj.GetIModel().GetShortDesc(ctx)
desc.Set("created_at", jsonutils.Marshal(change.NValue))
OpsLog.LogEvent(obj.GetIModel(), ACT_RE_BILLING, desc, userCred)
break
}
}
}
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloudcommon/db/opslog_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,6 @@ const (
ACT_STOP_RESCUE = "stop_rescue"
ACT_START_RESCUE_FAILED = "start_rescue_failed"
ACT_STOP_RESCUE_FAILED = "stop_rescue_failed"

ACT_RE_BILLING = "re_billing"
)

0 comments on commit 91dac7f

Please sign in to comment.