Skip to content

Commit

Permalink
可根据代理过滤云账号
Browse files Browse the repository at this point in the history
  • Loading branch information
Qu Xuan committed May 18, 2020
1 parent 66168cb commit 6ea25e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/climc/shell/compute/cloudaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/compute/cloudaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions pkg/compute/models/cloudaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,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)
Expand Down

0 comments on commit 6ea25e6

Please sign in to comment.