Merge pull request #13243 from rainzm/notify/autorenew

feat(notify): judge whether to enable automatic renewal when the expiration notice is given
This commit is contained in:
Zexi Li
2022-01-20 09:53:59 +08:00
committed by GitHub
6 changed files with 88 additions and 64 deletions
@@ -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 }}如有其它变更,请尽快前往控制台处理
@@ -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.
+32 -31
View File
@@ -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"
@@ -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)
+5
View File
@@ -412,6 +412,11 @@ func init() {
"loadbalancer listener",
"负载均衡监听",
},
sI18nElme{
api.TOPIC_RESOURCE_LOADBALANCERBACKEDNGROUP,
"loadbalancer backendgroup",
"负载均衡服务器组",
},
sI18nElme{
api.TOPIC_RESOURCE_BUCKET,
"object storage bucket",
+34 -31
View File
@@ -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(