mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
cloudaccount: provide proxysetting details
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
)
|
||||
@@ -180,4 +181,6 @@ type CloudaccountDetail struct {
|
||||
// 存储缓存数量
|
||||
// example: 10
|
||||
StoragecacheCount int `json:"storagecache_count,allowempty"`
|
||||
|
||||
ProxySetting proxyapi.SProxySetting `json:"proxy_setting"`
|
||||
}
|
||||
|
||||
@@ -1714,6 +1714,33 @@ func (manager *SCloudaccountManager) FetchCustomizeColumns(ctx context.Context,
|
||||
}
|
||||
}
|
||||
}
|
||||
proxySettings := make(map[string]proxy.SProxySetting)
|
||||
{
|
||||
proxySettingIds := make([]string, len(objs))
|
||||
for i := range objs {
|
||||
proxySettingId := objs[i].(*SCloudaccount).ProxySettingId
|
||||
if !utils.IsInStringArray(proxySettingId, proxySettingIds) {
|
||||
proxySettingIds = append(proxySettingIds, proxySettingId)
|
||||
}
|
||||
}
|
||||
q := proxy.ProxySettingManager.Query().In("id", proxySettingIds)
|
||||
r := []proxy.SProxySetting{}
|
||||
if err := db.FetchModelObjects(proxy.ProxySettingManager, q, &r); err != nil {
|
||||
log.Errorf("FetchModelObjects (%s) fail %s",
|
||||
proxy.ProxySettingManager.KeywordPlural(), err)
|
||||
return rows
|
||||
}
|
||||
for i := range r {
|
||||
proxySetting := r[i]
|
||||
proxySettings[proxySetting.Id] = proxySetting
|
||||
}
|
||||
}
|
||||
for i := range rows {
|
||||
account := objs[i].(*SCloudaccount)
|
||||
if proxySetting, ok := proxySettings[account.ProxySettingId]; ok {
|
||||
rows[i].Set("proxy_setting", jsonutils.Marshal(proxySetting))
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user