mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #5404 from swordqiu/automated-cherry-pick-of-#5403-upstream-release-3.1
Automated cherry pick of #5403: fix: cloudprovider performEnable should also enable its cloudaccount
This commit is contained in:
@@ -227,6 +227,10 @@ func (self *SCloudaccount) ValidateDeleteCondition(ctx context.Context) error {
|
||||
return self.SEnabledStatusStandaloneResourceBase.ValidateDeleteCondition(ctx)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) enableAccountOnly(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
return self.SEnabledStatusStandaloneResourceBase.PerformEnable(ctx, userCred, query, data)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if strings.Index(self.Status, "delet") >= 0 {
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot enable deleting account")
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -1239,21 +1240,17 @@ func (self *SCloudprovider) ClearSchedDescCache() error {
|
||||
}
|
||||
|
||||
func (self *SCloudprovider) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (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, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
account := self.GetCloudaccount()
|
||||
if account != nil {
|
||||
allEnabled := true
|
||||
providers := account.GetCloudproviders()
|
||||
for i := range providers {
|
||||
if !providers[i].Enabled {
|
||||
allEnabled = false
|
||||
}
|
||||
}
|
||||
if allEnabled && !account.Enabled {
|
||||
return account.PerformEnable(ctx, userCred, nil, nil)
|
||||
if !account.Enabled {
|
||||
return account.enableAccountOnly(ctx, userCred, nil, nil)
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user