mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #12176 from ioito/hotfix/qx-huawei-region-id
fix(region): huawei region id with project name
This commit is contained in:
@@ -204,19 +204,22 @@ func (self *SHuaweiClient) fetchRegions() error {
|
||||
return err
|
||||
}
|
||||
|
||||
regionId := strings.Split(project.Name, "_")[0]
|
||||
for _, region := range self.regions {
|
||||
if region.ID == regionId {
|
||||
if strings.Count(project.Name, region.ID) >= 1 {
|
||||
filtedRegions = append(filtedRegions, region)
|
||||
}
|
||||
}
|
||||
if regionId == project.Name {
|
||||
self.isMainProject = true
|
||||
if project.Name == region.ID {
|
||||
self.isMainProject = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filtedRegions = self.regions
|
||||
}
|
||||
|
||||
if len(filtedRegions) == 0 {
|
||||
return errors.Wrapf(cloudprovider.ErrNotFound, "empty regions")
|
||||
}
|
||||
|
||||
self.iregions = make([]cloudprovider.ICloudRegion, len(filtedRegions))
|
||||
for i := 0; i < len(filtedRegions); i += 1 {
|
||||
filtedRegions[i].client = self
|
||||
@@ -327,14 +330,15 @@ func (self *SHuaweiClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error)
|
||||
continue
|
||||
}
|
||||
// https://www.huaweicloud.com/notice/2018/20190618171312411.html
|
||||
expiredAt, _ := timeutils.ParseTimeStr("2020-09-16 00:00:00")
|
||||
if !self.ownerCreateTime.IsZero() && self.ownerCreateTime.After(expiredAt) && strings.ToLower(project.Name) == "cn-north-1" {
|
||||
continue
|
||||
}
|
||||
// expiredAt, _ := timeutils.ParseTimeStr("2020-09-16 00:00:00")
|
||||
// if !self.ownerCreateTime.IsZero() && self.ownerCreateTime.After(expiredAt) && strings.ToLower(project.Name) == "cn-north-1" {
|
||||
// continue
|
||||
// }
|
||||
s := cloudprovider.SSubAccount{
|
||||
Name: fmt.Sprintf("%s-%s", self.cpcfg.Name, project.Name),
|
||||
Account: fmt.Sprintf("%s/%s", self.accessKey, project.ID),
|
||||
HealthStatus: project.GetHealthStatus(),
|
||||
Name: fmt.Sprintf("%s-%s", self.cpcfg.Name, project.Name),
|
||||
Account: fmt.Sprintf("%s/%s", self.accessKey, project.ID),
|
||||
HealthStatus: project.GetHealthStatus(),
|
||||
DefaultProjectId: "0",
|
||||
}
|
||||
|
||||
subAccounts = append(subAccounts, s)
|
||||
|
||||
@@ -73,10 +73,8 @@ func (self *SRegion) getECSClient() (*client.Client, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
regionId := strings.Split(project.Name, "_")[0]
|
||||
if regionId != self.ID {
|
||||
// log.Debugf("project %s not in region %s", self.client.projectId, self.ID)
|
||||
return nil, errors.Error("region and project mismatch")
|
||||
if !strings.Contains(project.Name, self.ID) {
|
||||
return nil, errors.Errorf("region %s and project %s mismatch", self.ID, project.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user