fix: notify message use brand insteand of hypervisor

This commit is contained in:
Qiu Jian
2019-07-11 18:24:26 +08:00
parent 63e645c377
commit b799682ac2
14 changed files with 36 additions and 17 deletions
@@ -1 +1 @@
您的{{ .hypervisor }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
您的{{ .brand }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
@@ -1 +1 @@
您的{{ .hypervisor }}主机{{ .name }}已经创建成功,服务器IP地址为{{ .ips }},{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问ssh密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
您的{{ .brand }}主机{{ .name }}已经创建成功,服务器IP地址为{{ .ips }},{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问ssh密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
@@ -1 +1 @@
项目{{ .tenant }}的{{ .hypervisor }}主机{{ .name }}已经创建成功。
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经创建成功。
@@ -1 +1 @@
您的{{ .hypervisor }}主机{{ .name }}已经删除。
您的{{ .brand }}主机{{ .name }}已经删除。
@@ -1 +1 @@
项目{{ .tenant }}的{{ .hypervisor }}主机{{ .name }}已经删除。
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经删除。
@@ -1 +1 @@
您的{{ .hypervisor }}主机{{ .name }}重装系统成功,{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
您的{{ .brand }}主机{{ .name }}重装系统成功,{{ if .account }}初始帐号为{{ .account }},{{ end }}{{ if .keypair }}访问密钥为{{ .keypair }},{{ end }}{{ if .password }}初始密码为{{ .password }},{{ end }}请使用{{ if .windows }}远程桌面连接器(RDC){{ else }}SSH{{ end }}或控制面板控制台访问云主机。
@@ -1 +1 @@
您的{{ .hypervisor }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
您的{{ .brand }}主机{{ .name }}的套餐类型已经更改为 CPU:{{ index .flavor_info "cpu" }}核,内存:{{ index .flavor_info "memory" }}M,数据盘:{{ index .flavor_info "datadisk" }}G,带宽: {{ index .flavor_info "ebw" }}M。
@@ -1 +1 @@
{{ .hypervisor }}主机{{ .Name }}创建成功
{{ .brand }}主机{{ .Name }}创建成功
@@ -1 +1 @@
项目{{ .tenant }}的{{ .hypervisor }}主机{{ .name }}已经创建成功
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经创建成功
@@ -1 +1 @@
{{ .hypervisor }}主机{{ .name }}删除通知
{{ .brand }}主机{{ .name }}删除通知
@@ -1 +1 @@
项目{{ .tenant }}的{{ .hypervisor }}主机{{ .name }}已经删除
项目{{ .tenant }}的{{ .brand }}主机{{ .name }}已经删除
@@ -1 +1 @@
{{ .hypervisor }}主机{{ .name }}重装系统成功
{{ .brand }}主机{{ .name }}重装系统成功
+4
View File
@@ -686,6 +686,10 @@ func (self *SGuest) NotifyServerEvent(userCred mcclient.TokenCredential, event s
kwargs := jsonutils.NewDict()
kwargs.Add(jsonutils.NewString(self.Name), "name")
kwargs.Add(jsonutils.NewString(self.Hypervisor), "hypervisor")
host := self.GetHost()
if host != nil {
kwargs.Add(jsonutils.NewString(host.GetBrand()), "brand")
}
if loginInfo {
kwargs.Add(jsonutils.NewString(self.getNotifyIps()), "ips")
osName := meta[api.VM_METADATA_OS_NAME]
+20 -5
View File
@@ -58,7 +58,6 @@ func (self *SManagedResourceBase) GetCustomizeColumns(ctx context.Context, userC
info := map[string]string{
"manager": provider.GetName(),
"manager_id": provider.GetId(),
"provider": provider.Provider,
}
if len(provider.ProjectId) > 0 {
info["manager_project_id"] = provider.ProjectId
@@ -73,6 +72,14 @@ func (self *SManagedResourceBase) GetCustomizeColumns(ctx context.Context, userC
account := provider.GetCloudaccount()
info["account"] = account.GetName()
info["account_id"] = account.GetId()
info["provider"] = account.Provider
info["brand"] = account.Brand
info["account_domain_id"] = account.DomainId
dc, err := db.TenantCacheManager.FetchDomainById(appctx.Background, account.DomainId)
if err == nil {
info["account_domain"] = dc.Name
}
return jsonutils.Marshal(info).(*jsonutils.JSONDict)
}
@@ -100,11 +107,19 @@ func (self *SManagedResourceBase) GetDriver() (cloudprovider.ICloudProvider, err
}
func (self *SManagedResourceBase) GetProviderName() string {
driver := self.GetCloudprovider()
if driver != nil {
return driver.Provider
account := self.GetCloudaccount()
if account != nil {
return account.Provider
}
return ""
return api.CLOUD_PROVIDER_ONECLOUD
}
func (self *SManagedResourceBase) GetBrand() string {
account := self.GetCloudaccount()
if account != nil {
return account.Brand
}
return api.CLOUD_PROVIDER_ONECLOUD
}
func (self *SManagedResourceBase) IsManaged() bool {