Merge pull request #5977 from ioito/automated-cherry-pick-of-#5975-upstream-release-3.1

Automated cherry pick of #5975: fix: 添加cloudevent过滤参数
This commit is contained in:
Zexi Li
2020-04-24 01:36:28 +08:00
committed by GitHub
2 changed files with 65 additions and 16 deletions
+49 -3
View File
@@ -18,13 +18,59 @@ import (
"time"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/apis/compute"
)
type CloudeventListInput struct {
apis.VirtualResourceListInput
apis.ModelBaseListInput
compute.ManagedResourceListInput
// 列出指定云平台的资源,支持的云平台如下
//
// | Provider | 开始支持版本 | 平台 |
// |-----------|------------|-------------------------------------|
// | OneCloud | 0.0 | OneCloud内置私有云,包括KVM和裸金属管理 |
// | VMware | 1.2 | VMware vCenter |
// | OpenStack | 2.6 | OpenStack M版本以上私有云 |
// | ZStack | 2.10 | ZStack私有云 |
// | Aliyun | 2.0 | 阿里云 |
// | Aws | 2.3 | Amazon AWS |
// | Azure | 2.2 | Microsoft Azure |
// | Google | 2.13 | Google Cloud Platform |
// | Qcloud | 2.3 | 腾讯云 |
// | Huawei | 2.5 | 华为公有云 |
// | Ucloud | 2.7 | UCLOUD |
// | Ctyun | 2.13 | 天翼云 |
// | S3 | 2.11 | 通用s3对象存储 |
// | Ceph | 2.11 | Ceph对象存储 |
// | Xsky | 2.11 | XSKY启明星辰Ceph对象存储 |
//
// enum: OneCloud,VMware,Aliyun,Qcloud,Azure,Aws,Huawei,OpenStack,Ucloud,ZStack,Google,Ctyun,S3,Ceph,Xsky"
Providers []string `json:"providers"`
// swagger:ignore
// Deprecated
Provider []string `json:"provider" "yunion:deprecated-by":"providers"`
// 列出指定云平台品牌的资源,一般来说brand和provider相同,除了以上支持的provider之外,还支持以下band
//
// | Brand | Provider | 说明 |
// |----------|----------|------------|
// | DStack | ZStack | 滴滴云私有云 |
//
Brands []string `json:"brands"`
// swagger:ignore
// Deprecated
Brand []string `json:"brand" "yunion:deprecated-by":"brands"`
// 服务类型
Service []string `json:"service"`
// 订阅
Manager []string `json:"manager"`
// 账号
Account []string `json:"account"`
// 操作类型
Action []string `json:"action"`
// 操作日志起始时间
Since time.Time `json:"since"`
+16 -13
View File
@@ -86,19 +86,6 @@ func (manager *SCloudeventManager) ListItemFilter(ctx context.Context, q *sqlche
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
}
/* input.Cloudprovider = input.CloudproviderStr()
if len(input.Cloudprovider) > 0 {
providerObj, err := CloudproviderManager.FetchByIdOrName(userCred, input.Cloudprovider)
if err != nil {
if err == sql.ErrNoRows {
return nil, httperrors.NewResourceNotFoundError2(CloudproviderManager.Keyword(), input.Cloudprovider)
} else {
return nil, httperrors.NewGeneralError(err)
}
}
q = q.Equals("cloudprovider_id", providerObj.GetId())
}*/
if len(input.Providers) > 0 {
q = q.In("provider", input.Providers)
}
@@ -107,6 +94,22 @@ func (manager *SCloudeventManager) ListItemFilter(ctx context.Context, q *sqlche
q = q.In("brand", input.Brands)
}
if len(input.Service) > 0 {
q = q.In("service", input.Service)
}
if len(input.Manager) > 0 {
q = q.In("manager", input.Manager)
}
if len(input.Account) > 0 {
q = q.In("account", input.Account)
}
if len(input.Action) > 0 {
q = q.In("action", input.Action)
}
if !input.Since.IsZero() {
q = q.GT("created_at", input.Since)
}