mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): show huawei cloudprovider with region name
This commit is contained in:
@@ -24,6 +24,8 @@ import (
|
||||
type SSubAccount struct {
|
||||
// 若Account不为空,可不传
|
||||
Name string
|
||||
// 描述信息
|
||||
Desc string
|
||||
// 输入必填,若为空,需要指定子账号名称
|
||||
Account string
|
||||
HealthStatus string // 云端服务健康状态。例如欠费、项目冻结都属于不健康状态。
|
||||
|
||||
@@ -1010,7 +1010,7 @@ func (self *SCloudaccount) importSubAccount(ctx context.Context, userCred mcclie
|
||||
return nil, isNew, errors.Wrapf(err, "q.First")
|
||||
}
|
||||
provider.markProviderConnected(ctx, userCred, subAccount.HealthStatus)
|
||||
provider.updateName(ctx, userCred, subAccount.Name)
|
||||
provider.updateName(ctx, userCred, subAccount.Name, subAccount.Desc)
|
||||
return provider, isNew, nil
|
||||
}
|
||||
// not found, create a new cloudprovider
|
||||
@@ -1024,6 +1024,7 @@ func (self *SCloudaccount) importSubAccount(ctx context.Context, userCred mcclie
|
||||
newCloudprovider.Provider = self.Provider
|
||||
newCloudprovider.AccessUrl = self.AccessUrl
|
||||
newCloudprovider.HealthStatus = subAccount.HealthStatus
|
||||
newCloudprovider.Description = subAccount.Desc
|
||||
if !options.Options.CloudaccountHealthStatusCheck {
|
||||
newCloudprovider.HealthStatus = api.CLOUD_PROVIDER_HEALTH_NORMAL
|
||||
}
|
||||
|
||||
@@ -1276,10 +1276,13 @@ func (provider *SCloudprovider) markProviderDisconnected(ctx context.Context, us
|
||||
return provider.ClearSchedDescCache()
|
||||
}
|
||||
|
||||
func (self *SCloudprovider) updateName(ctx context.Context, userCred mcclient.TokenCredential, name string) error {
|
||||
if self.Name != name {
|
||||
func (self *SCloudprovider) updateName(ctx context.Context, userCred mcclient.TokenCredential, name, desc string) error {
|
||||
if self.Name != name || self.Description != desc {
|
||||
diff, err := db.Update(self, func() error {
|
||||
self.Name = name
|
||||
if len(self.Description) == 0 {
|
||||
self.Description = desc
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -511,6 +511,13 @@ func (self *SHuaweiClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error)
|
||||
HealthStatus: project.GetHealthStatus(),
|
||||
DefaultProjectId: "0",
|
||||
}
|
||||
for j := range self.iregions {
|
||||
region := self.iregions[j].(*SRegion)
|
||||
if strings.Contains(project.Name, region.ID) {
|
||||
s.Desc = region.Locales.ZhCN
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
subAccounts = append(subAccounts, s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user