Merge pull request #11658 from ioito/hotfix/qx-azure-subscription-state

fix(region): sync auzre subscription health status
This commit is contained in:
Zexi Li
2021-07-16 11:24:08 +08:00
committed by GitHub
5 changed files with 13 additions and 6 deletions
-1
View File
@@ -16,7 +16,6 @@ package cloudprovider
type SSubAccount struct {
Name string
State string
Account string
HealthStatus string // 云端服务健康状态。例如欠费、项目冻结都属于不健康状态。
}
+1 -2
View File
@@ -793,9 +793,8 @@ func (self *SAzureClient) GetSubAccounts() (subAccounts []cloudprovider.SSubAcco
subAccounts = make([]cloudprovider.SSubAccount, len(self.subscriptions))
for i, subscription := range self.subscriptions {
subAccounts[i].Account = fmt.Sprintf("%s/%s", self.tenantId, subscription.SubscriptionId)
subAccounts[i].State = subscription.State
subAccounts[i].Name = subscription.DisplayName
subAccounts[i].HealthStatus = api.CLOUD_PROVIDER_HEALTH_NORMAL
subAccounts[i].HealthStatus = subscription.GetHealthStatus()
}
return subAccounts, nil
}
+12 -1
View File
@@ -14,7 +14,11 @@
package azure
import "net/url"
import (
"net/url"
api "yunion.io/x/onecloud/pkg/apis/compute"
)
type SSubscription struct {
SubscriptionId string `json:"subscriptionId"`
@@ -22,6 +26,13 @@ type SSubscription struct {
DisplayName string `json:"displayName"`
}
func (self *SSubscription) GetHealthStatus() string {
if self.State == "Enabled" {
return api.CLOUD_PROVIDER_HEALTH_NORMAL
}
return api.CLOUD_PROVIDER_HEALTH_SUSPENDED
}
func (self *SAzureClient) ListSubscriptions() ([]SSubscription, error) {
result := []SSubscription{}
err := self.list("subscriptions", url.Values{}, &result)
-1
View File
@@ -277,7 +277,6 @@ func (self *SCtyunClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error)
s := cloudprovider.SSubAccount{
Name: fmt.Sprintf("%s-%s", self.cpcfg.Name, iregion.GetId()),
State: api.CLOUD_PROVIDER_CONNECTED,
Account: fmt.Sprintf("%s/%s", self.accessKey, iregion.GetId()),
HealthStatus: api.CLOUD_PROVIDER_HEALTH_NORMAL,
}
-1
View File
@@ -333,7 +333,6 @@ func (self *SHuaweiClient) GetSubAccounts() ([]cloudprovider.SSubAccount, error)
}
s := cloudprovider.SSubAccount{
Name: fmt.Sprintf("%s-%s", self.cpcfg.Name, project.Name),
State: api.CLOUD_PROVIDER_CONNECTED,
Account: fmt.Sprintf("%s/%s", self.accessKey, project.ID),
HealthStatus: project.GetHealthStatus(),
}