mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-09 16:07:36 +08:00
fix(region): sync auzre subscription health status
This commit is contained in:
@@ -16,7 +16,6 @@ package cloudprovider
|
||||
|
||||
type SSubAccount struct {
|
||||
Name string
|
||||
State string
|
||||
Account string
|
||||
HealthStatus string // 云端服务健康状态。例如欠费、项目冻结都属于不健康状态。
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user