mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #15527 from ioito/automated-cherry-pick-of-#15526-upstream-release-3.10
Automated cherry pick of #15526: fix(common): limit request
This commit is contained in:
@@ -47,6 +47,7 @@ func init() {
|
||||
"apsara",
|
||||
"cloudpods",
|
||||
"hcso",
|
||||
"hcsop",
|
||||
"hcs",
|
||||
"nutanix",
|
||||
"s3",
|
||||
|
||||
@@ -94,7 +94,7 @@ func (manager *SCloudaccountManager) GetICloudaccounts() ([]SCloudaccount, error
|
||||
offset := int64(0)
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("scope", jsonutils.NewString("system"))
|
||||
params.Set("limit", jsonutils.NewInt(1024))
|
||||
params.Set("limit", jsonutils.NewInt(20))
|
||||
for {
|
||||
params.Set("offset", jsonutils.NewInt(offset))
|
||||
result, err := modules.Cloudaccounts.List(s, params)
|
||||
@@ -102,10 +102,10 @@ func (manager *SCloudaccountManager) GetICloudaccounts() ([]SCloudaccount, error
|
||||
return nil, errors.Wrap(err, "modules.Cloudaccounts.List")
|
||||
}
|
||||
data = append(data, result.Data...)
|
||||
if len(data) >= result.Total {
|
||||
if len(data) >= result.Total || len(result.Data) == 0 {
|
||||
break
|
||||
}
|
||||
offset += 1024
|
||||
offset += 20
|
||||
}
|
||||
|
||||
accounts := []SCloudaccount{}
|
||||
|
||||
@@ -608,7 +608,7 @@ func ListAllResources(manager modulebase.Manager, params *jsonutils.JSONDict) ([
|
||||
params = jsonutils.NewDict()
|
||||
}
|
||||
params.Add(jsonutils.NewString("system"), "scope")
|
||||
params.Add(jsonutils.NewInt(0), "limit")
|
||||
params.Add(jsonutils.NewInt(20), "limit")
|
||||
params.Add(jsonutils.NewBool(true), "details")
|
||||
var count int
|
||||
session := auth.GetAdminSession(context.Background(), "")
|
||||
|
||||
@@ -36,7 +36,7 @@ func FetchAllRemoteDomainProjects(ctx context.Context) ([]*db.STenant, []*db.STe
|
||||
for {
|
||||
listParam := jsonutils.NewDict()
|
||||
listParam.Add(jsonutils.NewString("system"), "scope")
|
||||
listParam.Add(jsonutils.NewInt(0), "limit")
|
||||
listParam.Add(jsonutils.NewInt(20), "limit")
|
||||
listParam.Add(jsonutils.NewInt(int64(count)), "offset")
|
||||
listParam.Add(jsonutils.JSONTrue, "details")
|
||||
result, err := identity.Projects.List(s, listParam)
|
||||
|
||||
@@ -106,7 +106,7 @@ func (man *SMeterAlertManager) getAllBillAccounts(ctx context.Context) ([]jsonut
|
||||
q := jsonutils.NewDict()
|
||||
q.Add(jsonutils.NewString("system"), "scope")
|
||||
q.Add(jsonutils.NewInt(int64(len(results))), "offset")
|
||||
q.Add(jsonutils.NewInt(2048), "limit")
|
||||
q.Add(jsonutils.NewInt(20), "limit")
|
||||
ret, err := compute.Cloudaccounts.List(s, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -337,7 +337,7 @@ func ListAllResources(manager modulebase.Manager, params *jsonutils.JSONDict) ([
|
||||
params = jsonutils.NewDict()
|
||||
}
|
||||
params.Add(jsonutils.NewString("system"), "scope")
|
||||
params.Add(jsonutils.NewInt(0), "limit")
|
||||
params.Add(jsonutils.NewInt(20), "limit")
|
||||
params.Add(jsonutils.NewBool(true), "details")
|
||||
var count int
|
||||
session := auth.GetAdminSession(context.Background(), "")
|
||||
|
||||
Reference in New Issue
Block a user