feat(notify): support project notify (#19259)

Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
gouqi11
2024-01-15 19:35:07 +08:00
committed by GitHub
co-authored by 马鸿飞
parent e5829292e9
commit 4b2509d72b
5 changed files with 28 additions and 1 deletions
+1
View File
@@ -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"
+4
View File
@@ -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
}
+15 -1
View File
@@ -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 {
+5
View File
@@ -294,6 +294,11 @@ func init() {
"action log",
"操作日志",
},
sI18nElme{
api.TOPIC_RESOURCE_PROJECT,
"project",
"项目",
},
sI18nElme{
api.TOPIC_RESOURCE_CLOUDPODS_COMPONENT,
"cloudpods component",
+3
View File
@@ -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(