diff --git a/build/notify/root/opt/yunion/share/local-templates/content@cn/EXPIRED_RELEASE.tmpl b/build/notify/root/opt/yunion/share/local-templates/content@cn/EXPIRED_RELEASE.tmpl index b7ac9d6bd0..218e8c9a4b 100644 --- a/build/notify/root/opt/yunion/share/local-templates/content@cn/EXPIRED_RELEASE.tmpl +++ b/build/notify/root/opt/yunion/share/local-templates/content@cn/EXPIRED_RELEASE.tmpl @@ -11,4 +11,4 @@ {{- if $d.public_dns -}} ,外网地址为{{ $d.public_dns }}:{{ $d.public_connect_port }}的 {{- end -}} -{{ .resource_type_display }}{{ $d.name }}还有{{ .advance_days }}天就要到期释放,如需续期使用,请尽快前往控制台处理 +{{ .resource_type_display }}{{ $d.name }}还有{{ .advance_days }}天就要到期释放,{{ if $d.auto_renew }}到期已开启自动续费,{{ end }}如有其它变更,请尽快前往控制台处理 diff --git a/build/notify/root/opt/yunion/share/local-templates/content@en/EXPIRED_RELEASE.tmpl b/build/notify/root/opt/yunion/share/local-templates/content@en/EXPIRED_RELEASE.tmpl index 3bcf9d94e4..8eaa06debd 100644 --- a/build/notify/root/opt/yunion/share/local-templates/content@en/EXPIRED_RELEASE.tmpl +++ b/build/notify/root/opt/yunion/share/local-templates/content@en/EXPIRED_RELEASE.tmpl @@ -1,2 +1,2 @@ {{- $d := .resource_details -}} -Your {{ if $d.brand -}} {{ $d.brand }} {{ end -}} {{ .resource_type }} {{ $d.name }} {{ if $d.public_dns -}} with external address {{ $d.public_dns }}:{{ $d.public_connect_port }} {{ end -}} {{ if $d.project -}} in project {{ $d.project }} {{ end -}} will expire and be released in {{ .advance_days }} days. If you need to renew, please go to the console as soon as possible +Your {{ if $d.brand -}} {{ $d.brand }} {{ end -}} {{ .resource_type }} {{ $d.name }} {{ if $d.public_dns -}} with external address {{ $d.public_dns }}:{{ $d.public_connect_port }} {{ end -}} {{ if $d.project -}} in project {{ $d.project }} {{ end -}} will expire and be released in {{ .advance_days }} days. {{ if $d.auto_renew }}It has turned on automatic renewal. {{ end }}If there are other changes, please go to the console as soon as possible. diff --git a/pkg/apis/notify/const.go b/pkg/apis/notify/const.go index d2b0368dac..76870151b3 100644 --- a/pkg/apis/notify/const.go +++ b/pkg/apis/notify/const.go @@ -87,37 +87,38 @@ const ( TOPIC_TYPE_RESOURCE = "resource" TOPIC_TYPE_AUTOMATED_PROCESS = "automated_process" - TOPIC_RESOURCE_SERVER = "server" - TOPIC_RESOURCE_SCALINGGROUP = "scalinggroup" - TOPIC_RESOURCE_SCALINGPOLICY = "scalingpolicy" - TOPIC_RESOURCE_IMAGE = "image" - TOPIC_RESOURCE_DISK = "disk" - TOPIC_RESOURCE_SNAPSHOT = "snapshot" - TOPIC_RESOURCE_INSTANCESNAPSHOT = "instance_snapshot" - TOPIC_RESOURCE_SNAPSHOTPOLICY = "snapshotpolicy" - TOPIC_RESOURCE_NETWORK = "network" - TOPIC_RESOURCE_EIP = "eip" - TOPIC_RESOURCE_SECGROUP = "secgroup" - TOPIC_RESOURCE_LOADBALANCER = "loadbalancer" - TOPIC_RESOURCE_LOADBALANCERACL = "loadbalanceracl" - TOPIC_RESOURCE_LOADBALANCERCERTIFICATE = "loadbalancercertificate" - TOPIC_RESOURCE_BUCKET = "bucket" - TOPIC_RESOURCE_DBINSTANCE = "dbinstance" - TOPIC_RESOURCE_ELASTICCACHE = "elasticcache" - TOPIC_RESOURCE_SCHEDULEDTASK = "scheduledtask" - TOPIC_RESOURCE_BAREMETAL = "baremetal" - TOPIC_RESOURCE_VPC = "vpc" - TOPIC_RESOURCE_DNSZONE = "dns_zone" - TOPIC_RESOURCE_NATGATEWAY = "natgateway" - TOPIC_RESOURCE_WEBAPP = "webapp" - TOPIC_RESOURCE_CDNDOMAIN = "cdn_domain" - TOPIC_RESOURCE_FILESYSTEM = "file_system" - TOPIC_RESOURCE_WAF = "waf_instance" - TOPIC_RESOURCE_KAFKA = "kafka" - TOPIC_RESOURCE_ELASTICSEARCH = "elastic_search" - TOPIC_RESOURCE_MONGODB = "mongodb" - TOPIC_RESOURCE_DNSRECORDSET = "dns_recordset" - TOPIC_RESOURCE_LOADBALANCERLISTENER = "loadbalancerlistener" + TOPIC_RESOURCE_SERVER = "server" + TOPIC_RESOURCE_SCALINGGROUP = "scalinggroup" + TOPIC_RESOURCE_SCALINGPOLICY = "scalingpolicy" + TOPIC_RESOURCE_IMAGE = "image" + TOPIC_RESOURCE_DISK = "disk" + TOPIC_RESOURCE_SNAPSHOT = "snapshot" + TOPIC_RESOURCE_INSTANCESNAPSHOT = "instance_snapshot" + TOPIC_RESOURCE_SNAPSHOTPOLICY = "snapshotpolicy" + TOPIC_RESOURCE_NETWORK = "network" + TOPIC_RESOURCE_EIP = "eip" + TOPIC_RESOURCE_SECGROUP = "secgroup" + TOPIC_RESOURCE_LOADBALANCER = "loadbalancer" + TOPIC_RESOURCE_LOADBALANCERACL = "loadbalanceracl" + TOPIC_RESOURCE_LOADBALANCERCERTIFICATE = "loadbalancercertificate" + TOPIC_RESOURCE_BUCKET = "bucket" + TOPIC_RESOURCE_DBINSTANCE = "dbinstance" + TOPIC_RESOURCE_ELASTICCACHE = "elasticcache" + TOPIC_RESOURCE_SCHEDULEDTASK = "scheduledtask" + TOPIC_RESOURCE_BAREMETAL = "baremetal" + TOPIC_RESOURCE_VPC = "vpc" + TOPIC_RESOURCE_DNSZONE = "dns_zone" + TOPIC_RESOURCE_NATGATEWAY = "natgateway" + TOPIC_RESOURCE_WEBAPP = "webapp" + TOPIC_RESOURCE_CDNDOMAIN = "cdn_domain" + TOPIC_RESOURCE_FILESYSTEM = "file_system" + TOPIC_RESOURCE_WAF = "waf_instance" + TOPIC_RESOURCE_KAFKA = "kafka" + TOPIC_RESOURCE_ELASTICSEARCH = "elastic_search" + TOPIC_RESOURCE_MONGODB = "mongodb" + TOPIC_RESOURCE_DNSRECORDSET = "dns_recordset" + TOPIC_RESOURCE_LOADBALANCERLISTENER = "loadbalancerlistener" + TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP = "loadbalancerbackendgroup" SUBSCRIBER_TYPE_ROLE = "role" SUBSCRIBER_TYPE_ROBOT = "robot" diff --git a/pkg/compute/models/loadbalancerbackendgroups.go b/pkg/compute/models/loadbalancerbackendgroups.go index 263204d024..a32c56fca5 100644 --- a/pkg/compute/models/loadbalancerbackendgroups.go +++ b/pkg/compute/models/loadbalancerbackendgroups.go @@ -30,6 +30,7 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/cloudprovider" @@ -993,6 +994,10 @@ func (lbbg *SLoadbalancerBackendGroup) syncRemoveCloudLoadbalancerBackendgroup(c if err != nil { // cannot delete err = lbbg.SetStatus(userCred, api.LB_STATUS_UNKNOWN, "sync to delete") } else { + notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{ + Obj: lbbg, + Action: notifyclient.ActionSyncDelete, + }) lbbg.LBPendingDelete(ctx, userCred) } return err @@ -1014,6 +1019,12 @@ func (lbbg *SLoadbalancerBackendGroup) SyncWithCloudLoadbalancerBackendgroup( if err != nil { return err } + if len(diff) > 0 { + notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{ + Obj: lbbg, + Action: notifyclient.ActionSyncUpdate, + }) + } db.OpsLog.LogSyncUpdate(lbbg, diff, userCred) SyncCloudProject(userCred, lbbg, syncOwnerId, extLoadbalancerBackendgroup, provider.Id) @@ -1074,6 +1085,10 @@ func (man *SLoadbalancerBackendGroupManager) newFromCloudLoadbalancerBackendgrou } SyncCloudProject(userCred, lbbg, syncOwnerId, extLoadbalancerBackendgroup, provider.Id) + notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{ + Obj: lbbg, + Action: notifyclient.ActionSyncCreate, + }) db.OpsLog.LogEvent(lbbg, db.ACT_CREATE, lbbg.GetShortDesc(ctx), userCred) diff --git a/pkg/notify/models/event_template.go b/pkg/notify/models/event_template.go index b0bdc8b8ff..f7004a62b0 100644 --- a/pkg/notify/models/event_template.go +++ b/pkg/notify/models/event_template.go @@ -412,6 +412,11 @@ func init() { "loadbalancer listener", "负载均衡监听", }, + sI18nElme{ + api.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP, + "loadbalancer backendgroup", + "负载均衡服务器组", + }, sI18nElme{ api.TOPIC_RESOURCE_BUCKET, "object storage bucket", diff --git a/pkg/notify/models/topic.go b/pkg/notify/models/topic.go index d623879242..c46acc6a87 100644 --- a/pkg/notify/models/topic.go +++ b/pkg/notify/models/topic.go @@ -158,6 +158,7 @@ func (sm *STopicManager) InitializeData() error { notify.TOPIC_RESOURCE_DNSZONE, notify.TOPIC_RESOURCE_DNSRECORDSET, notify.TOPIC_RESOURCE_LOADBALANCERLISTENER, + notify.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP, ) t.addAction( notify.ActionCreate, @@ -271,6 +272,7 @@ func (sm *STopicManager) InitializeData() error { notify.TOPIC_RESOURCE_MONGODB, notify.TOPIC_RESOURCE_DNSRECORDSET, notify.TOPIC_RESOURCE_LOADBALANCERLISTENER, + notify.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP, ) t.addAction( notify.ActionSyncCreate, @@ -456,37 +458,38 @@ func init() { } converter.registerResource( map[string]int{ - notify.TOPIC_RESOURCE_SERVER: 0, - notify.TOPIC_RESOURCE_SCALINGGROUP: 1, - notify.TOPIC_RESOURCE_SCALINGPOLICY: 2, - notify.TOPIC_RESOURCE_IMAGE: 3, - notify.TOPIC_RESOURCE_DISK: 4, - notify.TOPIC_RESOURCE_SNAPSHOT: 5, - notify.TOPIC_RESOURCE_INSTANCESNAPSHOT: 6, - notify.TOPIC_RESOURCE_SNAPSHOTPOLICY: 7, - notify.TOPIC_RESOURCE_NETWORK: 8, - notify.TOPIC_RESOURCE_EIP: 9, - notify.TOPIC_RESOURCE_SECGROUP: 10, - notify.TOPIC_RESOURCE_LOADBALANCER: 11, - notify.TOPIC_RESOURCE_LOADBALANCERACL: 12, - notify.TOPIC_RESOURCE_LOADBALANCERCERTIFICATE: 13, - notify.TOPIC_RESOURCE_BUCKET: 14, - notify.TOPIC_RESOURCE_DBINSTANCE: 15, - notify.TOPIC_RESOURCE_ELASTICCACHE: 16, - notify.TOPIC_RESOURCE_SCHEDULEDTASK: 17, - notify.TOPIC_RESOURCE_BAREMETAL: 18, - notify.TOPIC_RESOURCE_VPC: 19, - notify.TOPIC_RESOURCE_DNSZONE: 20, - notify.TOPIC_RESOURCE_NATGATEWAY: 21, - notify.TOPIC_RESOURCE_WEBAPP: 22, - notify.TOPIC_RESOURCE_CDNDOMAIN: 23, - notify.TOPIC_RESOURCE_FILESYSTEM: 24, - notify.TOPIC_RESOURCE_WAF: 25, - notify.TOPIC_RESOURCE_KAFKA: 26, - notify.TOPIC_RESOURCE_ELASTICSEARCH: 27, - notify.TOPIC_RESOURCE_MONGODB: 28, - notify.TOPIC_RESOURCE_DNSRECORDSET: 29, - notify.TOPIC_RESOURCE_LOADBALANCERLISTENER: 30, + notify.TOPIC_RESOURCE_SERVER: 0, + notify.TOPIC_RESOURCE_SCALINGGROUP: 1, + notify.TOPIC_RESOURCE_SCALINGPOLICY: 2, + notify.TOPIC_RESOURCE_IMAGE: 3, + notify.TOPIC_RESOURCE_DISK: 4, + notify.TOPIC_RESOURCE_SNAPSHOT: 5, + notify.TOPIC_RESOURCE_INSTANCESNAPSHOT: 6, + notify.TOPIC_RESOURCE_SNAPSHOTPOLICY: 7, + notify.TOPIC_RESOURCE_NETWORK: 8, + notify.TOPIC_RESOURCE_EIP: 9, + notify.TOPIC_RESOURCE_SECGROUP: 10, + notify.TOPIC_RESOURCE_LOADBALANCER: 11, + notify.TOPIC_RESOURCE_LOADBALANCERACL: 12, + notify.TOPIC_RESOURCE_LOADBALANCERCERTIFICATE: 13, + notify.TOPIC_RESOURCE_BUCKET: 14, + notify.TOPIC_RESOURCE_DBINSTANCE: 15, + notify.TOPIC_RESOURCE_ELASTICCACHE: 16, + notify.TOPIC_RESOURCE_SCHEDULEDTASK: 17, + notify.TOPIC_RESOURCE_BAREMETAL: 18, + notify.TOPIC_RESOURCE_VPC: 19, + notify.TOPIC_RESOURCE_DNSZONE: 20, + notify.TOPIC_RESOURCE_NATGATEWAY: 21, + notify.TOPIC_RESOURCE_WEBAPP: 22, + notify.TOPIC_RESOURCE_CDNDOMAIN: 23, + notify.TOPIC_RESOURCE_FILESYSTEM: 24, + notify.TOPIC_RESOURCE_WAF: 25, + notify.TOPIC_RESOURCE_KAFKA: 26, + notify.TOPIC_RESOURCE_ELASTICSEARCH: 27, + notify.TOPIC_RESOURCE_MONGODB: 28, + notify.TOPIC_RESOURCE_DNSRECORDSET: 29, + notify.TOPIC_RESOURCE_LOADBALANCERLISTENER: 30, + notify.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP: 31, }, ) converter.registerAction(