mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(notify): support project notify (#19259)
Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
@@ -137,6 +137,7 @@ const (
|
||||
TOPIC_RESOURCE_NET = "net"
|
||||
TOPIC_RESOURCE_SERVICE = "service"
|
||||
TOPIC_RESOURCE_VM_INTEGRITY_CHECK = "vm_integrity"
|
||||
TOPIC_RESOURCE_PROJECT = "project"
|
||||
|
||||
SUBSCRIBER_TYPE_ROLE = "role"
|
||||
SUBSCRIBER_TYPE_ROBOT = "robot"
|
||||
|
||||
@@ -6033,6 +6033,10 @@ func (host *SHost) SetStatus(userCred mcclient.TokenCredential, status string, r
|
||||
return err
|
||||
}
|
||||
host.ClearSchedDescCache()
|
||||
notifyclient.EventNotify(context.Background(), userCred, notifyclient.SEventNotifyParam{
|
||||
Obj: host,
|
||||
Action: notifyclient.ActionUpdate,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/keystone/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -59,6 +60,7 @@ func init() {
|
||||
),
|
||||
}
|
||||
ProjectManager.SetVirtualObject(ProjectManager)
|
||||
notifyclient.AddNotifyDBHookResources(ProjectManager.KeywordPlural(), ProjectManager.AliasPlural())
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -384,7 +386,15 @@ func (proj *SProject) ValidateDeleteCondition(ctx context.Context, info *api.Pro
|
||||
}
|
||||
|
||||
func (proj *SProject) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return proj.SIdentityBaseResource.Delete(ctx, userCred)
|
||||
err := proj.SIdentityBaseResource.Delete(ctx, userCred)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "project delete")
|
||||
}
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
Obj: proj,
|
||||
Action: notifyclient.ActionDelete,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (proj *SProject) IsAdminProject() bool {
|
||||
@@ -556,6 +566,10 @@ func (project *SProject) PostCreate(
|
||||
if err != nil {
|
||||
log.Errorf("CancelPendingUsage fail %s", err)
|
||||
}
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
Obj: project,
|
||||
Action: notifyclient.ActionCreate,
|
||||
})
|
||||
}
|
||||
|
||||
func threeMemberSystemValidatePolicies(userCred mcclient.TokenCredential, projectId string, assignPolicies rbacutils.TPolicyGroup) error {
|
||||
|
||||
@@ -294,6 +294,11 @@ func init() {
|
||||
"action log",
|
||||
"操作日志",
|
||||
},
|
||||
sI18nElme{
|
||||
api.TOPIC_RESOURCE_PROJECT,
|
||||
"project",
|
||||
"项目",
|
||||
},
|
||||
sI18nElme{
|
||||
api.TOPIC_RESOURCE_CLOUDPODS_COMPONENT,
|
||||
"cloudpods component",
|
||||
|
||||
@@ -195,6 +195,7 @@ func (sm *STopicManager) InitializeData() error {
|
||||
notify.TOPIC_RESOURCE_DNSRECORDSET,
|
||||
notify.TOPIC_RESOURCE_LOADBALANCERLISTENER,
|
||||
notify.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP,
|
||||
notify.TOPIC_RESOURCE_PROJECT,
|
||||
)
|
||||
t.addAction(
|
||||
notify.ActionCreate,
|
||||
@@ -228,6 +229,7 @@ func (sm *STopicManager) InitializeData() error {
|
||||
notify.TOPIC_RESOURCE_ELASTICCACHE,
|
||||
notify.TOPIC_RESOURCE_USER,
|
||||
notify.TOPIC_RESOURCE_HOST,
|
||||
notify.TOPIC_RESOURCE_PROJECT,
|
||||
)
|
||||
t.addAction(notify.ActionUpdate)
|
||||
t.addAction(notify.ActionRebuildRoot)
|
||||
@@ -820,6 +822,7 @@ func init() {
|
||||
notify.TOPIC_RESOURCE_NET: 39,
|
||||
notify.TOPIC_RESOURCE_SERVICE: 40,
|
||||
notify.TOPIC_RESOURCE_VM_INTEGRITY_CHECK: 41,
|
||||
notify.TOPIC_RESOURCE_PROJECT: 42,
|
||||
},
|
||||
)
|
||||
converter.registerAction(
|
||||
|
||||
Reference in New Issue
Block a user