mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): add post delete hook (#22302)
This commit is contained in:
@@ -1980,6 +1980,9 @@ func deleteItem(manager IModelManager, model IModel, ctx context.Context, userCr
|
||||
|
||||
// 删除后钩子
|
||||
model.PostDelete(ctx, userCred)
|
||||
if err := model.GetModelManager().GetExtraHook().AfterPostDelete(ctx, userCred, model, query); err != nil {
|
||||
logclient.AddActionLogWithContext(ctx, model, logclient.ACT_POST_DELETE_HOOK, err, userCred, false)
|
||||
}
|
||||
|
||||
// 避免设置删除状态没有正常返回
|
||||
jsonutils.Update(details, model)
|
||||
|
||||
@@ -152,6 +152,7 @@ type IModelManager interface {
|
||||
|
||||
type IModelManagerExtraHook interface {
|
||||
AfterPostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, model IModel, query jsonutils.JSONObject, data jsonutils.JSONObject) error
|
||||
AfterPostDelete(ctx context.Context, userCred mcclient.TokenCredential, model IModel, query jsonutils.JSONObject) error
|
||||
}
|
||||
|
||||
type IModel interface {
|
||||
|
||||
@@ -876,3 +876,7 @@ func NewEmptyExtraHook() *SEmptyExtraHook {
|
||||
func (e SEmptyExtraHook) AfterPostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, model IModel, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e SEmptyExtraHook) AfterPostDelete(ctx context.Context, userCred mcclient.TokenCredential, model IModel, query jsonutils.JSONObject) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -723,6 +723,7 @@ type ServerDeleteOptions struct {
|
||||
DeleteSnapshots *bool `help:"Delete server snapshots"`
|
||||
DeleteDisks *bool `help:"Delete server disks"`
|
||||
DeleteEip *bool `help:"Delete eip"`
|
||||
DeleteBastionServer *bool `help:"Remove from bastion host"`
|
||||
}
|
||||
|
||||
func (o *ServerDeleteOptions) QueryParams() (jsonutils.JSONObject, error) {
|
||||
|
||||
@@ -29,6 +29,7 @@ const (
|
||||
ACT_CLOUD_SYNC = "cloud_sync"
|
||||
ACT_CREATE = "create"
|
||||
ACT_POST_CREATE_HOOK = "post_create_hook"
|
||||
ACT_POST_DELETE_HOOK = "post_delete_hook"
|
||||
ACT_DELETE = "delete"
|
||||
ACT_PENDING_DELETE = "pending_delete"
|
||||
ACT_DISABLE = "disable"
|
||||
|
||||
Reference in New Issue
Block a user