mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #5403 from swordqiu/hotfix/qj-cloud-provider-perform-enable-should-enable-account
fix: cloudprovider performEnable should also enable its cloudaccount
This commit is contained in:
@@ -207,11 +207,15 @@ func (self *SCloudaccount) ValidateDeleteCondition(ctx context.Context) error {
|
||||
return self.SEnabledStatusDomainLevelResourceBase.ValidateDeleteCondition(ctx)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) enableAccountOnly(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) (jsonutils.JSONObject, error) {
|
||||
return self.SEnabledStatusDomainLevelResourceBase.PerformEnable(ctx, userCred, query, input)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) (jsonutils.JSONObject, error) {
|
||||
if strings.Index(self.Status, "delet") >= 0 {
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot enable deleting account")
|
||||
}
|
||||
_, err := self.SEnabledStatusDomainLevelResourceBase.PerformEnable(ctx, userCred, query, input)
|
||||
_, err := self.enableAccountOnly(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -1277,22 +1278,17 @@ func (self *SCloudprovider) ClearSchedDescCache() error {
|
||||
}
|
||||
|
||||
func (self *SCloudprovider) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) (jsonutils.JSONObject, error) {
|
||||
if strings.Index(self.Status, "delet") >= 0 {
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot enable deleting account")
|
||||
}
|
||||
_, err := self.SEnabledStatusStandaloneResourceBase.PerformEnable(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
account := self.GetCloudaccount()
|
||||
if account != nil {
|
||||
allEnabled := true
|
||||
providers := account.GetCloudproviders()
|
||||
for i := range providers {
|
||||
if !providers[i].GetEnabled() {
|
||||
allEnabled = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if allEnabled && !account.GetEnabled() {
|
||||
return account.PerformEnable(ctx, userCred, nil, input)
|
||||
if !account.GetEnabled() {
|
||||
return account.enableAccountOnly(ctx, userCred, nil, input)
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user