可根据代理过滤云账号

This commit is contained in:
Qu Xuan
2020-05-18 12:05:46 +08:00
parent eb56db7b00
commit 2cdccfcf65
3 changed files with 20 additions and 0 deletions
+4
View File
@@ -55,6 +55,7 @@ func init() {
Capability []string `help:"capability filter" choices:"project|compute|network|loadbalancer|objectstore|rds|cache|event"`
DistinctField string `help:"distinct field"`
ProxySetting string `help:"Proxy setting id or name"`
}
R(&CloudaccountListOptions{}, "cloud-account-list", "List cloud accounts", func(s *mcclient.ClientSession, args *CloudaccountListOptions) error {
var params *jsonutils.JSONDict
@@ -67,6 +68,9 @@ func init() {
if len(args.Capability) > 0 {
params.Add(jsonutils.NewStringArray(args.Capability), "capability")
}
if len(args.ProxySetting) > 0 {
params.Add(jsonutils.NewString(args.ProxySetting), "proxy_setting")
}
}
if len(args.DistinctField) > 0 {
params.Add(jsonutils.NewString(args.DistinctField), "extra_field")
+5
View File
@@ -223,6 +223,11 @@ type CloudaccountListInput struct {
// 共享模式
ShareMode []string `json:"share_mode"`
// 代理
ProxySetting string `json:"proxy_setting"`
// swagger:ignore
ProxySettingId string `json:"proxy_setting_id" "yunion:deprecated-by":"proxy_setting"`
}
type ProviderProject struct {
+11
View File
@@ -1496,6 +1496,17 @@ func (manager *SCloudaccountManager) ListItemFilter(
return nil, errors.Wrap(err, "SSyncableBaseResourceManager.ListItemFilter")
}
if len(query.ProxySetting) > 0 {
proxy, err := proxy.ProxySettingManager.FetchByIdOrName(nil, query.ProxySetting)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2("proxy_setting", query.ProxySetting)
}
return nil, httperrors.NewGeneralError(err)
}
q = q.Equals("proxy_setting_id", proxy.GetId())
}
managerStr := query.Cloudprovider
if len(managerStr) > 0 {
providerObj, err := CloudproviderManager.FetchByIdOrName(userCred, managerStr)