mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #5463 from swordqiu/hotfix/qj-fix-region-list-filters3
feature: fix region list filters
This commit is contained in:
@@ -130,7 +130,7 @@ require (
|
||||
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74
|
||||
yunion.io/x/jsonutils v0.0.0-20200303051356-aa609aba0cda
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d
|
||||
yunion.io/x/pkg v0.0.0-20200304112442-9dae9351325e
|
||||
yunion.io/x/pkg v0.0.0-20200312093207-f07f4cb157e0
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57
|
||||
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3
|
||||
|
||||
@@ -1114,8 +1114,8 @@ yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2
|
||||
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20200302034534-fdf44d54b070/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20200304112442-9dae9351325e h1:rBfX77+VEBVpe6Xxy2gDa4WB7qbtndWvXcrVKzleF84=
|
||||
yunion.io/x/pkg v0.0.0-20200304112442-9dae9351325e/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20200312093207-f07f4cb157e0 h1:ZgNhWrnxnVjw53rjx5uV5yQCYcwM8lpVHsrchmHWQI4=
|
||||
yunion.io/x/pkg v0.0.0-20200312093207-f07f4cb157e0/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
|
||||
yunion.io/x/sqlchemy v0.0.0-20200312002602-1177cd8fbc57 h1:KtQAuLJ00RSUVqkiRmJ1DiDABiw0U3xxXnzD3lGavaY=
|
||||
|
||||
@@ -98,15 +98,17 @@ func (input *BucketMetadataInput) Validate() error {
|
||||
|
||||
type BucketListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
// STORAGE_CLASS
|
||||
StorageClass string `json:"storage_class"`
|
||||
StorageClass []string `json:"storage_class"`
|
||||
|
||||
// 位置
|
||||
Location string `json:"location"`
|
||||
Location []string `json:"location"`
|
||||
|
||||
// ACL
|
||||
Acl string `json:"acl"`
|
||||
Acl []string `json:"acl"`
|
||||
}
|
||||
|
||||
@@ -212,8 +212,7 @@ type CloudaccountListInput struct {
|
||||
|
||||
CapabilityListInput
|
||||
|
||||
// 同步状态
|
||||
SyncStatus []string `json:"sync_status"`
|
||||
SyncableBaseResourceListInput
|
||||
|
||||
// 账号健康状态
|
||||
HealthStatus []string `json:"health_status"`
|
||||
|
||||
@@ -216,8 +216,7 @@ type CloudproviderListInput struct {
|
||||
|
||||
CapabilityListInput
|
||||
|
||||
// 同步状态
|
||||
SyncStatus []string `json:"sync_status"`
|
||||
SyncableBaseResourceListInput
|
||||
|
||||
// 账号健康状态
|
||||
HealthStatus []string `json:"health_status"`
|
||||
@@ -228,3 +227,8 @@ func (input *CapabilityListInput) AfterUnmarshal() {
|
||||
input.Capability = append(input.Capability, cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE)
|
||||
}
|
||||
}
|
||||
|
||||
type SyncableBaseResourceListInput struct {
|
||||
// 同步状态
|
||||
SyncStatus []string `json:"sync_status"`
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
type CloudproviderregionDetails struct {
|
||||
apis.JointResourceBaseDetails
|
||||
CloudregionResourceInfo
|
||||
|
||||
Cloudprovider string
|
||||
Cloudregion string
|
||||
Cloudprovider string `json:"cloudprovider"`
|
||||
|
||||
// 云账号Id
|
||||
// example: fa4aaf88-aed8-422d-84e7-56dea533b364
|
||||
@@ -39,3 +39,13 @@ type CloudproviderregionDetails struct {
|
||||
// example: 300
|
||||
SyncIntervalSeconds int `json:"sync_interval_seconds"`
|
||||
}
|
||||
|
||||
type CloudproviderregionListInput struct {
|
||||
apis.JointResourceBaseListInput
|
||||
SyncableBaseResourceListInput
|
||||
RegionalFilterListInput
|
||||
ManagedResourceListInput
|
||||
|
||||
// 是否启用
|
||||
Enabled *bool `json:"enabled"`
|
||||
}
|
||||
|
||||
@@ -164,6 +164,8 @@ type SDBInstanceRecoveryConfigInput struct {
|
||||
|
||||
type DBInstanceListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
apis.DeletePreventableResourceBaseListInput
|
||||
|
||||
VpcFilterListInput
|
||||
|
||||
@@ -188,6 +190,7 @@ type DBInstanceListInput struct {
|
||||
|
||||
type DBInstanceBackupListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
@@ -195,14 +198,14 @@ type DBInstanceBackupListInput struct {
|
||||
|
||||
// RDS引擎
|
||||
// example: MySQL
|
||||
Engine string `json:"engine"`
|
||||
Engine []string `json:"engine"`
|
||||
|
||||
// RDS引擎版本
|
||||
// example: 5.7
|
||||
EngineVersion string `json:"engine_version"`
|
||||
EngineVersion []string `json:"engine_version"`
|
||||
|
||||
// 备份模式
|
||||
BackupMode string `json:"backup_mode"`
|
||||
BackupMode []string `json:"backup_mode"`
|
||||
|
||||
// 数据库名称
|
||||
DBNames string `json:"db_names"`
|
||||
@@ -210,6 +213,7 @@ type DBInstanceBackupListInput struct {
|
||||
|
||||
type DBInstancePrivilegeListInput struct {
|
||||
apis.ResourceBaseListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
// filter by dbinstanceaccount
|
||||
Dbinstanceaccount string `json:"dbinstanceaccount"`
|
||||
@@ -217,12 +221,12 @@ type DBInstancePrivilegeListInput struct {
|
||||
Dbinstancedatabase string `json:"dbinstancedatabase"`
|
||||
|
||||
// 权限
|
||||
Privilege string `json:"privilege"`
|
||||
Privilege []string `json:"privilege"`
|
||||
}
|
||||
|
||||
type DBInstanceParameterListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
DBInstanceFilterListInput
|
||||
|
||||
// 参数名称
|
||||
@@ -234,6 +238,7 @@ type DBInstanceParameterListInput struct {
|
||||
|
||||
type DBInstanceDatabaseListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
DBInstanceFilterListInput
|
||||
|
||||
@@ -243,6 +248,7 @@ type DBInstanceDatabaseListInput struct {
|
||||
|
||||
type DBInstanceAccountListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
DBInstanceFilterListInput
|
||||
}
|
||||
|
||||
@@ -91,10 +91,14 @@ type SnapshotPolicyFilterListInput struct {
|
||||
// Deprecated
|
||||
// filter disk by snapshotpolicy_id
|
||||
SnapshotpolicyId string `json:"snapshotpolicy_id" deprecated-by:"snapshotpolicy"`
|
||||
|
||||
// 以快照策略名称排序
|
||||
OrderBySnapshotpolicy string `json:"order_by_snapshotpolicy"`
|
||||
}
|
||||
|
||||
type DiskListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
billing.BillingResourceListInput
|
||||
StorageFilterListInput
|
||||
|
||||
@@ -140,9 +144,7 @@ type DiskListInput struct {
|
||||
SnapshotId string `json:"snapshot_id" deprecated-by:"snapshot"`
|
||||
}
|
||||
|
||||
type DiskFilterListInput struct {
|
||||
StorageFilterListInput
|
||||
|
||||
type DiskFilterListInputBase struct {
|
||||
// 以指定虚拟磁盘(ID或Name)过滤列表结果
|
||||
Disk string `json:"disk"`
|
||||
// swagger:ignore
|
||||
@@ -155,6 +157,12 @@ type DiskFilterListInput struct {
|
||||
OrderByDisk string `json:"order_by_disk"`
|
||||
}
|
||||
|
||||
type DiskFilterListInput struct {
|
||||
StorageFilterListInput
|
||||
|
||||
DiskFilterListInputBase
|
||||
}
|
||||
|
||||
type SimpleGuest struct {
|
||||
Name string `json:"name"`
|
||||
Id string `json:"id"`
|
||||
|
||||
@@ -109,6 +109,8 @@ const (
|
||||
|
||||
type ElasticcacheListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
apis.DeletePreventableResourceBaseListInput
|
||||
VpcFilterListInput
|
||||
ZonalFilterListBase
|
||||
|
||||
@@ -162,6 +164,7 @@ type ElasticcacheListInput struct {
|
||||
|
||||
type ElasticcacheAccountListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ElasticcacheFilterListInput
|
||||
|
||||
@@ -174,6 +177,7 @@ type ElasticcacheAccountListInput struct {
|
||||
|
||||
type ElasticcacheAclListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ElasticcacheFilterListInput
|
||||
|
||||
@@ -183,6 +187,7 @@ type ElasticcacheAclListInput struct {
|
||||
|
||||
type ElasticcacheBackupListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ElasticcacheFilterListInput
|
||||
|
||||
@@ -195,6 +200,7 @@ type ElasticcacheBackupListInput struct {
|
||||
|
||||
type ElasticcacheParameterListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ElasticcacheFilterListInput
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ var (
|
||||
|
||||
type ElasticipListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
@@ -70,6 +70,7 @@ func (input ZonalFilterListInput) ZoneList() []string {
|
||||
|
||||
type CloudregionListInput struct {
|
||||
apis.EnabledStatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
apis.DomainizedResourceListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
@@ -82,12 +83,12 @@ type CloudregionListInput struct {
|
||||
Service string `json:"service"`
|
||||
|
||||
// 云环境
|
||||
Environment string `json:"environment"`
|
||||
Environment []string `json:"environment"`
|
||||
}
|
||||
|
||||
type ZoneListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.DomainizedResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
|
||||
@@ -98,6 +99,9 @@ type ZoneListInput struct {
|
||||
|
||||
// 过滤提供特定服务的可用区
|
||||
Service string `json:"service"`
|
||||
|
||||
Location []string `json:"location"`
|
||||
Contacts []string `json:"contacts"`
|
||||
}
|
||||
|
||||
type ZoneResourceInput struct {
|
||||
|
||||
@@ -25,6 +25,11 @@ type GroupJointResourceDetails struct {
|
||||
Instancegroup string `json:"instance_group"`
|
||||
}
|
||||
|
||||
type GroupJointsListInput struct {
|
||||
apis.VirtualJointResourceBaseListInput
|
||||
GroupFilterListInput
|
||||
}
|
||||
|
||||
type GroupguestDetails struct {
|
||||
GroupJointResourceDetails
|
||||
|
||||
@@ -33,3 +38,11 @@ type GroupguestDetails struct {
|
||||
|
||||
SGroupguest
|
||||
}
|
||||
|
||||
type GroupguestListInput struct {
|
||||
GroupJointsListInput
|
||||
GuestFilterListInput
|
||||
|
||||
// 标签
|
||||
Tag []string `json:"tag"`
|
||||
}
|
||||
|
||||
@@ -22,3 +22,12 @@ type GroupnetworkDetails struct {
|
||||
// IP子网名称
|
||||
Network string
|
||||
}
|
||||
|
||||
type GroupnetworkListInput struct {
|
||||
GroupJointsListInput
|
||||
|
||||
NetworkFilterListInput
|
||||
|
||||
// IP地址
|
||||
IpAddr []string `json:"ip_addr"`
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ type ServerFilterListInput struct {
|
||||
|
||||
type ServerListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
apis.DeletePreventableResourceBaseListInput
|
||||
|
||||
HostFilterListInput
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ type DiskSpec struct {
|
||||
|
||||
type HostListInput struct {
|
||||
apis.EnabledStatusStandaloneResourceListInput
|
||||
apis.DomainizedResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
ZonalFilterListInput
|
||||
|
||||
@@ -41,46 +41,71 @@ type KeypairListInput struct {
|
||||
|
||||
// list in admin mode
|
||||
Admin *bool `json:"admin"`
|
||||
|
||||
// 加密类型
|
||||
// example: RSA
|
||||
Scheme []string `json:"scheme"`
|
||||
|
||||
// 指纹信息
|
||||
// example: 1d:3a:83:4a:a1:f3:75:97:ec:d1:ef:f8:3f:a7:5d:9e
|
||||
Fingerprint []string `json:"fingerprint"`
|
||||
}
|
||||
|
||||
type CachedimageListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
ZonalFilterListInput
|
||||
|
||||
// 镜像类型,可能值为: system(公有云公共镜像), customized(自定义镜像)
|
||||
// example: system
|
||||
ImageType string `json:"image_type"`
|
||||
ImageType []string `json:"image_type"`
|
||||
}
|
||||
|
||||
type ExternalProjectListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ProjectizedResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
}
|
||||
|
||||
type RouteTableListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
VpcFilterListInput
|
||||
|
||||
// filter by type
|
||||
Type []string `json:"type"`
|
||||
}
|
||||
|
||||
type SnapshotPolicyCacheListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
SnapshotPolicyFilterListInput
|
||||
|
||||
// filter by snapshotpolicy Id or Name
|
||||
Snapshotpolicy string `json:"snapshotpolicy"`
|
||||
//Snapshotpolicy string `json:"snapshotpolicy"`
|
||||
}
|
||||
|
||||
type NetworkInterfaceListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
// MAC地址
|
||||
Mac []string `json:"mac"`
|
||||
// 绑定资源类型
|
||||
AssociateType []string `json:"associate_type"`
|
||||
// 绑定资源Id
|
||||
AssociateId []string `json:"associate_id"`
|
||||
}
|
||||
|
||||
type BaremetalagentListInput struct {
|
||||
@@ -88,11 +113,11 @@ type BaremetalagentListInput struct {
|
||||
ZonalFilterListInput
|
||||
|
||||
// 以状态过滤
|
||||
Status string `json:"status"`
|
||||
Status []string `json:"status"`
|
||||
// 以IP地址过滤
|
||||
AccessIp string `json:"access_ip"`
|
||||
AccessIp []string `json:"access_ip"`
|
||||
// 以AgentType过滤
|
||||
AgentType string `json:"agent_type"`
|
||||
AgentType []string `json:"agent_type"`
|
||||
}
|
||||
|
||||
type DnsRecordListInput struct {
|
||||
@@ -114,14 +139,33 @@ type GuestTemplateListInput struct {
|
||||
type SchedpolicyListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
SchedtagFilterListInput
|
||||
|
||||
//
|
||||
Strategy []string `json:"strategy"`
|
||||
|
||||
//
|
||||
Enabled *bool `json:"enabled"`
|
||||
}
|
||||
|
||||
type GuestTemplateFilterListInput struct {
|
||||
// 主机镜像
|
||||
GuestTemplate string `json:"guest_template"`
|
||||
// swagger:ignore
|
||||
// Deprecated
|
||||
GuestTemplateId string `json:"guest_template_id" deprecated-by:"guest_template"`
|
||||
}
|
||||
|
||||
type ServiceCatalogListInput struct {
|
||||
apis.SharableVirtualResourceListInput
|
||||
|
||||
GuestTemplateFilterListInput
|
||||
}
|
||||
|
||||
type SnapshotPolicyListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
|
||||
// 是否启用?
|
||||
IsActivated *bool `json:"is_activated"`
|
||||
}
|
||||
|
||||
type DnsRecordDetails struct {
|
||||
|
||||
@@ -48,7 +48,15 @@ type GroupFilterListInput struct {
|
||||
// 以指定实例组(ID或Name)过滤列表结果
|
||||
Group string `json:"group"`
|
||||
// swagger:ignore
|
||||
// deprecated: true
|
||||
// Deprecated
|
||||
// Filter by instance group Id
|
||||
GroupId string `json:"group_id" deprecated-by:"group"`
|
||||
|
||||
// 按组名排序
|
||||
OrderByGroup string `json:"order_by_group"`
|
||||
}
|
||||
|
||||
type GroupResourceInfo struct {
|
||||
// 实例组名称
|
||||
Group string `json:"group"`
|
||||
}
|
||||
|
||||
@@ -33,47 +33,86 @@ const (
|
||||
|
||||
type LoadbalancerListenerListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
LoadbalancerFilterListInput
|
||||
|
||||
// filter by backend_group
|
||||
BackendGroup string `json:"backend_group"`
|
||||
// filter by acl
|
||||
Acl string `json:"acl"`
|
||||
|
||||
ListenerType []string `json:"listener_type"`
|
||||
ListenerPort []int `json:"listener_port"`
|
||||
|
||||
Scheduler []string `json:"scheduler"`
|
||||
|
||||
SendProxy []string `json:"send_proxy"`
|
||||
|
||||
AclStatus []string `json:"acl_status"`
|
||||
AclType []string `json:"acl_type"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
LoadbalancerListenerFilterListInput
|
||||
|
||||
// filter by backend_group
|
||||
BackendGroup string `json:"backend_group"`
|
||||
|
||||
// 默认转发策略,目前只有aws用到其它云都是false
|
||||
IsDefault *bool `json:"is_default"`
|
||||
|
||||
Domain []string `json:"domain"`
|
||||
Path []string `json:"path"`
|
||||
}
|
||||
|
||||
type LoadbalancerListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
VpcFilterListInput
|
||||
ZonalFilterListBase
|
||||
NetworkFilterListBase
|
||||
|
||||
// filter by cluster
|
||||
Cluster string `json:"cluster"`
|
||||
|
||||
Address []string `json:"address"`
|
||||
// 地址类型
|
||||
AddressType []string `json:"address_type"`
|
||||
// 网络类型
|
||||
NetworkType []string `json:"network_type"`
|
||||
// 计费类型
|
||||
ChargeType []string `json:"charge_type"`
|
||||
// 套餐名称
|
||||
LoadbalancerSpec []string `json:"loadbalancer_spec"`
|
||||
}
|
||||
|
||||
type LoadbalancerAgentListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
LoadbalancerClusterFilterListInput
|
||||
|
||||
Version []string `json:"version"`
|
||||
IP []string `json:"ip"`
|
||||
HaState []string `json:"ha_state"`
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
UsableResourceListInput
|
||||
RegionalFilterListInput
|
||||
ManagedResourceListInput
|
||||
|
||||
CommonName []string `json:"common_name"`
|
||||
SubjectAlternativeNames []string `json:"subject_alternative_names"`
|
||||
}
|
||||
|
||||
type LoadbalancerBackendListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
LoadbalancerBackendGroupFilterListInput
|
||||
|
||||
@@ -82,15 +121,25 @@ type LoadbalancerBackendListInput struct {
|
||||
|
||||
// filter by backend group
|
||||
// BackendGroup string `json:"backend_group"`
|
||||
|
||||
BackendType []string `json:"backend_type"`
|
||||
BackendRole []string `json:"backend_role"`
|
||||
Address []string `json:"address"`
|
||||
|
||||
SendProxy []string `json:"send_proxy"`
|
||||
Ssl []string `json:"ssl"`
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGroupListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
LoadbalancerFilterListInput
|
||||
|
||||
// filter LoadbalancerBackendGroup with no reference
|
||||
NoRef *bool `json:"no_ref"`
|
||||
|
||||
Type []string `json:"type"`
|
||||
}
|
||||
|
||||
type LoadbalancerClusterListInput struct {
|
||||
@@ -102,9 +151,13 @@ type LoadbalancerClusterListInput struct {
|
||||
|
||||
type LoadbalancerAclListInput struct {
|
||||
apis.SharableVirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
//
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
}
|
||||
|
||||
type LoadbalancerDetails struct {
|
||||
|
||||
@@ -26,3 +26,12 @@ type LoadbalancernetworkDetails struct {
|
||||
// IP子网名称
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
type LoadbalancernetworkListInput struct {
|
||||
apis.VirtualJointResourceBaseListInput
|
||||
|
||||
LoadbalancerFilterListInput
|
||||
NetworkFilterListInput
|
||||
|
||||
IpAddr []string `json:"ip_addr"`
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ const (
|
||||
|
||||
type NatGetewayListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
VpcFilterListInput
|
||||
RegionalFilterListInput
|
||||
@@ -48,17 +49,28 @@ type NatGetewayListInput struct {
|
||||
|
||||
type NatEntryListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
NatGatewayFilterListInput
|
||||
ManagedResourceListInput
|
||||
}
|
||||
|
||||
type NatDEntryListInput struct {
|
||||
NatEntryListInput
|
||||
|
||||
ExternalIP []string `json:"external_ip"`
|
||||
ExternalPort []int `json:"external_port"`
|
||||
|
||||
InternalIP []string `json:"internal_ip"`
|
||||
InternalPort []int `json:"internal_port"`
|
||||
IpProtocol []string `json:"ip_protocol"`
|
||||
}
|
||||
|
||||
type NatSEntryListInput struct {
|
||||
NatEntryListInput
|
||||
NetworkFilterListBase
|
||||
|
||||
IP []string `json:"ip"`
|
||||
SourceCIDR []string `json:"source_cidr"`
|
||||
}
|
||||
|
||||
type NatGatewayResourceInfo struct {
|
||||
|
||||
@@ -75,6 +75,7 @@ type NetworkFilterListInput struct {
|
||||
|
||||
type NetworkListInput struct {
|
||||
apis.SharableVirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
WireFilterListInput
|
||||
|
||||
HostResourceInput
|
||||
@@ -84,6 +85,37 @@ type NetworkListInput struct {
|
||||
// description: search ip address in network.
|
||||
// example: 10.168.222.1
|
||||
Ip string `json:"ip"`
|
||||
|
||||
IfnameHint []string `json:"ifname_hint"`
|
||||
// 起始IP地址
|
||||
GuestIpStart []string `json:"guest_ip_start"`
|
||||
// 接收IP地址
|
||||
GuestIpEnd []string `json:"guest_ip_end"`
|
||||
// 掩码
|
||||
GuestIpMask []int8 `json:"guest_ip_mask"`
|
||||
// 网关地址
|
||||
GuestGateway string `json:"guest_gateway"`
|
||||
// DNS
|
||||
GuestDns []string `json:"guest_dns"`
|
||||
// allow multiple dhcp, seperated by ","
|
||||
GuestDhcp []string `json:"guest_dhcp"`
|
||||
|
||||
GuestDomain []string `json:"guest_domain"`
|
||||
|
||||
GuestIp6Start []string `json:"guest_ip6_start"`
|
||||
GuestIp6End []string `json:"guest_ip6_end"`
|
||||
GuestIp6Mask []int8 `json:"guest_ip6_mask"`
|
||||
GuestGateway6 []string `json:"guest_gateway6"`
|
||||
GuestDns6 []string `json:"guest_dns6"`
|
||||
|
||||
GuestDomain6 []string `json:"guest_domain6"`
|
||||
// vlanId 1~4096
|
||||
VlanId []int `json:"vlan_id"`
|
||||
// 服务器类型
|
||||
// example: server
|
||||
ServerType []string `json:"server_type"`
|
||||
// 分配策略
|
||||
AllocPolicy []string `json:"alloc_policy"`
|
||||
}
|
||||
|
||||
type NetworkResourceInfoBase struct {
|
||||
|
||||
@@ -22,3 +22,8 @@ type NetworkschedtagDetails struct {
|
||||
// IP子网名称
|
||||
Network string `json:"network"`
|
||||
}
|
||||
|
||||
type NetworkschedtagListInput struct {
|
||||
SchedtagJointsListInput
|
||||
NetworkFilterListInput
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ type ReservedipListInput struct {
|
||||
|
||||
// list all reserved ips, including expired ones
|
||||
All *bool `json:"all"`
|
||||
|
||||
// ip_addr
|
||||
IpAddr []string `json:"ip_addr"`
|
||||
// 状态
|
||||
Status []string `json:"status"`
|
||||
}
|
||||
|
||||
type ReservedipDetails struct {
|
||||
|
||||
@@ -58,6 +58,7 @@ type SchedtagFilterListInput struct {
|
||||
|
||||
type SchedtagListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ScopedResourceBaseListInput
|
||||
|
||||
// fitler by resource_type
|
||||
ResourceType string `json:"resource_type"`
|
||||
@@ -65,19 +66,23 @@ type SchedtagListInput struct {
|
||||
// Deprecated
|
||||
// filter by type, alias for resource_type
|
||||
Type string `json:"type" deprecated-by:"resource_type"`
|
||||
|
||||
DefaultStrategy []string `json:"default_strategy"`
|
||||
}
|
||||
|
||||
type SchedtagDetails struct {
|
||||
apis.StandaloneResourceDetails
|
||||
apis.ScopedResourceBaseInfo
|
||||
|
||||
SSchedtag
|
||||
|
||||
DynamicSchedtagCount int `json:"dynamic_schedtag_count"`
|
||||
SchedpolicyCount int `json:"schedpolicy_count"`
|
||||
ProjectId string `json:"project_id"`
|
||||
HostCount int `json:"host_count"`
|
||||
ServerCount int `json:"server_count"`
|
||||
OtherCount int `json:"other_count"`
|
||||
JoinModelKeyword string `json:"join_model_keyword"`
|
||||
DynamicSchedtagCount int `json:"dynamic_schedtag_count"`
|
||||
SchedpolicyCount int `json:"schedpolicy_count"`
|
||||
// ProjectId string `json:"project_id"`
|
||||
HostCount int `json:"host_count"`
|
||||
ServerCount int `json:"server_count"`
|
||||
OtherCount int `json:"other_count"`
|
||||
JoinModelKeyword string `json:"join_model_keyword"`
|
||||
}
|
||||
|
||||
type SchedtagResourceInfo struct {
|
||||
|
||||
@@ -144,13 +144,19 @@ type SecgroupListInput struct {
|
||||
// 按缓存关联主机数排序
|
||||
// pattern:asc|desc
|
||||
OrderByGuestCnt string `json:"order_by_guest_cnt"`
|
||||
|
||||
// 是否被修改
|
||||
IsDirty *bool `json:"is_dirty"`
|
||||
}
|
||||
|
||||
type SecurityGroupCacheListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
VpcFilterListInput
|
||||
SecgroupFilterListInput
|
||||
}
|
||||
|
||||
@@ -173,6 +179,9 @@ type SecgroupFilterListInput struct {
|
||||
// Deprecated
|
||||
// filter by secgroup_id
|
||||
SecgroupId string `json:"secgroup_id" deprecated-by:"secgroup"`
|
||||
|
||||
// 以安全组排序
|
||||
OrderBySecgroup string `json:"order_by_secgroup"`
|
||||
}
|
||||
|
||||
type SecgroupDetails struct {
|
||||
@@ -190,3 +199,13 @@ type SecgroupDetails struct {
|
||||
// 出方向规则信息
|
||||
OutRules string `json:"out_rules"`
|
||||
}
|
||||
|
||||
type SecurityGroupResourceInfo struct {
|
||||
// 安全组名称
|
||||
Secgroup string `json:"secgroup"`
|
||||
}
|
||||
|
||||
type GuestsecgroupListInput struct {
|
||||
GuestJointsListInput
|
||||
SecgroupFilterListInput
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ type ServerSkuListInput struct {
|
||||
|
||||
// filter sku by memory size in MB
|
||||
MemorySizeMb int `json:"memory_size_mb"`
|
||||
// filter sku by CPU core count
|
||||
CpuCoreCount []int `json:"cpu_core_count"`
|
||||
}
|
||||
|
||||
type ElasticcacheSkuListInput struct {
|
||||
apis.StatusStandaloneResourceListInput
|
||||
apis.DomainizedResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
|
||||
@@ -122,6 +124,7 @@ type ElasticcacheSkuListInput struct {
|
||||
|
||||
type DBInstanceSkuListInput struct {
|
||||
apis.EnabledStatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
apis.DomainizedResourceListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
@@ -130,15 +133,15 @@ type DBInstanceSkuListInput struct {
|
||||
billing.BillingResourceListInput
|
||||
|
||||
// StorageType
|
||||
StorageType string `json:"storage_type"`
|
||||
StorageType []string `json:"storage_type"`
|
||||
|
||||
VcpuCount int `json:"vcpu_count"`
|
||||
VcpuCount []int `json:"vcpu_count"`
|
||||
|
||||
VmemSizeMb int `json:"vmem_size_mb"`
|
||||
VmemSizeMb []int `json:"vmem_size_mb"`
|
||||
|
||||
Category string `json:"category"`
|
||||
Category []string `json:"category"`
|
||||
|
||||
Engine string `json:"engine"`
|
||||
Engine []string `json:"engine"`
|
||||
|
||||
EngineVersion string `json:"engine_version"`
|
||||
EngineVersion []string `json:"engine_version"`
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ type SSnapshotPolicyCreateInternalInput struct {
|
||||
|
||||
type SnapshotListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
|
||||
@@ -80,6 +82,12 @@ type SnapshotListInput struct {
|
||||
DiskType string `json:"disk_type"`
|
||||
// filter instance snapshot
|
||||
IsInstanceSnapshot *bool `json:"is_instance_snapshot"`
|
||||
|
||||
DiskFilterListInputBase
|
||||
StorageFilterListInputBase
|
||||
|
||||
OutOfChain *bool `json:"out_of_chain"`
|
||||
OsType []string `json:"os_type"`
|
||||
}
|
||||
|
||||
type SnapshotDetails struct {
|
||||
|
||||
@@ -28,3 +28,8 @@ type SnapshotPolicyDetails struct {
|
||||
|
||||
BindingDiskCount int `json:"binding_disk_count"`
|
||||
}
|
||||
|
||||
type SnapshotPolicyResourceInfo struct {
|
||||
// 快照策略名称
|
||||
Snapshotpolicy string `json:"snapshotpolicy"`
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ type SnapshotPolicyCacheDetails struct {
|
||||
apis.StatusStandaloneResourceDetails
|
||||
ManagedResourceInfo
|
||||
CloudregionResourceInfo
|
||||
|
||||
SnapshotPolicyResourceInfo
|
||||
SSnapshotPolicyCache
|
||||
}
|
||||
|
||||
@@ -25,3 +25,12 @@ type SnapshotPolicyDiskDetails struct {
|
||||
Snapshotpolicy string `json:"snapshotpolicy"`
|
||||
Disk DiskDetails `json:"disk"`
|
||||
}
|
||||
|
||||
type SnapshotPolicyDiskListInput struct {
|
||||
apis.VirtualJointResourceBaseListInput
|
||||
SnapshotPolicyFilterListInput
|
||||
DiskFilterListInput
|
||||
|
||||
// 状态
|
||||
Status []string `json:"status"`
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ var (
|
||||
SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD}
|
||||
)
|
||||
|
||||
type StorageFilterListInput struct {
|
||||
type StorageFilterListInputBase struct {
|
||||
// 过滤关联此存储(ID或Name)的列表结果
|
||||
Storage string `json:"storage"`
|
||||
// swagger:ignore
|
||||
@@ -149,6 +149,10 @@ type StorageFilterListInput struct {
|
||||
// 以存储名称排序
|
||||
// pattern:asc|desc
|
||||
OrderByStorage string `json:"order_by_storage"`
|
||||
}
|
||||
|
||||
type StorageFilterListInput struct {
|
||||
StorageFilterListInputBase
|
||||
|
||||
StorageShareFilterListInput
|
||||
|
||||
@@ -165,6 +169,7 @@ type StorageShareFilterListInput struct {
|
||||
|
||||
type StorageListInput struct {
|
||||
apis.EnabledStatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
ZonalFilterListInput
|
||||
|
||||
@@ -39,3 +39,23 @@ type StoragecachedimageDetails struct {
|
||||
// 引用次数
|
||||
Reference int `json:"reference"`
|
||||
}
|
||||
|
||||
type StoragecachedimageListInput struct {
|
||||
apis.JointResourceBaseListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
// 以镜像缓存存储过滤
|
||||
Storagecache string `json:"storagecache"`
|
||||
// Deprecated
|
||||
// swagger:ignore
|
||||
StoragecacheId string `json:"storagecache_id" deprecated-by:"storagecache"`
|
||||
|
||||
// 以镜像缓存过滤
|
||||
Cachedimage string `json:"cachedimage"`
|
||||
// Deprecated
|
||||
// swagger:ignore
|
||||
CachedimageId string `json:"cachedimage_id" deprecated-by:"cachedimage_id"`
|
||||
|
||||
// 镜像状态
|
||||
Status []string `json:"status"`
|
||||
}
|
||||
|
||||
@@ -22,3 +22,8 @@ type StorageschedtagDetails struct {
|
||||
// 存储名称
|
||||
Storage string `json:"storage"`
|
||||
}
|
||||
|
||||
type StorageschedtagListInput struct {
|
||||
SchedtagJointsListInput
|
||||
StorageFilterListInput
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ type UsableVpcResourceListInput struct {
|
||||
|
||||
type VpcListInput struct {
|
||||
apis.EnabledStatusStandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
ManagedResourceListInput
|
||||
RegionalFilterListInput
|
||||
@@ -59,10 +60,19 @@ type VpcListInput struct {
|
||||
|
||||
// filter by globalvpc
|
||||
Globalvpc string `json:"globalvpc"`
|
||||
|
||||
// 是否是默认VPC
|
||||
// example: true
|
||||
IsDefault *bool `json:"is_default"`
|
||||
|
||||
// CIDR地址段
|
||||
// example: 192.168.222.0/24
|
||||
CidrBlock []string `json:"cidr_block"`
|
||||
}
|
||||
|
||||
type WireListInput struct {
|
||||
apis.StandaloneResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
|
||||
VpcFilterListInput
|
||||
|
||||
|
||||
@@ -233,11 +233,10 @@ type SCloudproviderCapability struct {
|
||||
type SCloudproviderregion struct {
|
||||
apis.SJointResourceBase
|
||||
SSyncableBaseResource
|
||||
SCloudregionResourceBase
|
||||
// 云订阅ID
|
||||
CloudproviderId string `json:"cloudprovider_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
CloudregionId string `json:"cloudregion_id"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// SyncIntervalSeconds int `list:"domain"`
|
||||
SyncResults interface{} `json:"sync_results"`
|
||||
LastDeepSyncAt time.Time `json:"last_deep_sync_at"`
|
||||
@@ -370,7 +369,7 @@ type SDBInstanceDatabase struct {
|
||||
// SDBInstanceJointsBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SDBInstanceJointsBase.
|
||||
type SDBInstanceJointsBase struct {
|
||||
apis.SVirtualJointResourceBase
|
||||
DBInstanceId string `json:"dbinstance_id"`
|
||||
SDBInstanceResourceBase
|
||||
}
|
||||
|
||||
// SDBInstanceNetwork is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SDBInstanceNetwork.
|
||||
@@ -474,6 +473,11 @@ type SDisk struct {
|
||||
Nonpersistent bool `json:"nonpersistent"`
|
||||
}
|
||||
|
||||
// SDiskResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SDiskResourceBase.
|
||||
type SDiskResourceBase struct {
|
||||
DiskId string `json:"disk_id"`
|
||||
}
|
||||
|
||||
// SDnsRecord is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SDnsRecord.
|
||||
type SDnsRecord struct {
|
||||
apis.SAdminSharableVirtualResourceBase
|
||||
@@ -822,8 +826,7 @@ type SGuestTemplate struct {
|
||||
// SGuestdisk is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGuestdisk.
|
||||
type SGuestdisk struct {
|
||||
SGuestJointsBase
|
||||
// SDiskResourceBase `list:"user" create:"required"`
|
||||
DiskId string `json:"disk_id"`
|
||||
SDiskResourceBase
|
||||
ImagePath string `json:"image_path"`
|
||||
Driver string `json:"driver"`
|
||||
// Column(VARCHAR(32, charset='ascii'), nullable=True)
|
||||
@@ -864,7 +867,7 @@ type SGuestnetwork struct {
|
||||
// SGuestsecgroup is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SGuestsecgroup.
|
||||
type SGuestsecgroup struct {
|
||||
SGuestJointsBase
|
||||
SecgroupId string `json:"secgroup_id"`
|
||||
SSecurityGroupResourceBase
|
||||
}
|
||||
|
||||
// SHost is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SHost.
|
||||
@@ -875,16 +878,18 @@ type SHost struct {
|
||||
SManagedResourceBase
|
||||
SBillingResourceBase
|
||||
// 机架
|
||||
Rack string `json:"rack"`
|
||||
Slots string `json:"slots"`
|
||||
Rack string `json:"rack"`
|
||||
// 机位
|
||||
Slots string `json:"slots"`
|
||||
// 管理口MAC
|
||||
AccessMac string `json:"access_mac"`
|
||||
// Ip地址
|
||||
// 管理口Ip地址
|
||||
AccessIp string `json:"access_ip"`
|
||||
// 管理地址
|
||||
ManagerUri string `json:"manager_uri"`
|
||||
// 系统信息
|
||||
SysInfo interface{} `json:"sys_info"`
|
||||
// SN信息
|
||||
// 物理机序列号信息
|
||||
SN string `json:"sn"`
|
||||
// CPU大小
|
||||
CpuCount int `json:"cpu_count"`
|
||||
@@ -926,8 +931,10 @@ type SHost struct {
|
||||
// example: online
|
||||
HostStatus string `json:"host_status"`
|
||||
// 宿主机类型
|
||||
HostType string `json:"host_type"`
|
||||
Version string `json:"version"`
|
||||
HostType string `json:"host_type"`
|
||||
// host服务软件版本
|
||||
Version string `json:"version"`
|
||||
// OVN软件版本
|
||||
OvnVersion string `json:"ovn_version"`
|
||||
IsBaremetal bool `json:"is_baremetal"`
|
||||
// 是否处于维护状态
|
||||
@@ -935,10 +942,14 @@ type SHost struct {
|
||||
LastPingAt time.Time `json:"last_ping_at"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
RealExternalId string `json:"real_external_id"`
|
||||
IsImport bool `json:"is_import"`
|
||||
EnablePxeBoot *bool `json:"enable_pxe_boot,omitempty"`
|
||||
Uuid string `json:"uuid"`
|
||||
BootMode string `json:"boot_mode"`
|
||||
// 是否为导入的宿主机
|
||||
IsImport bool `json:"is_import"`
|
||||
// 是否允许PXE启动
|
||||
EnablePxeBoot *bool `json:"enable_pxe_boot,omitempty"`
|
||||
// 主机UUID
|
||||
Uuid string `json:"uuid"`
|
||||
// 主机启动模式, 可能值位PXE和ISO
|
||||
BootMode string `json:"boot_mode"`
|
||||
}
|
||||
|
||||
// SHostJointsBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SHostJointsBase.
|
||||
@@ -954,12 +965,13 @@ type SHostResourceBase struct {
|
||||
// SHostnetwork is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SHostnetwork.
|
||||
type SHostnetwork struct {
|
||||
SHostJointsBase
|
||||
// 宿主机ID
|
||||
BaremetalId string `json:"baremetal_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
// 网络ID
|
||||
NetworkId string `json:"network_id"`
|
||||
// Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
// IP地址
|
||||
IpAddr string `json:"ip_addr"`
|
||||
// Column(VARCHAR(16, charset='ascii'))
|
||||
// MAC地址
|
||||
MacAddr string `json:"mac_addr"`
|
||||
}
|
||||
|
||||
@@ -972,12 +984,12 @@ type SHostschedtag struct {
|
||||
// SHoststorage is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SHoststorage.
|
||||
type SHoststorage struct {
|
||||
SHostJointsBase
|
||||
// 挂载点
|
||||
MountPoint string `json:"mount_point"`
|
||||
// 宿主机Id
|
||||
HostId string `json:"host_id"`
|
||||
// 存储Id
|
||||
StorageId string `json:"storage_id"`
|
||||
// 挂载点
|
||||
MountPoint string `json:"mount_point"`
|
||||
// 配置信息
|
||||
Config interface{} `json:"config"`
|
||||
// 真实容量大小
|
||||
@@ -1047,6 +1059,8 @@ type SInstanceSnapshot struct {
|
||||
KeypairId string `json:"keypair_id"`
|
||||
// 操作系统类型
|
||||
OsType string `json:"os_type"`
|
||||
// 套餐名称
|
||||
InstanceType string `json:"instance_type"`
|
||||
}
|
||||
|
||||
// SInstanceSnapshotJoint is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SInstanceSnapshotJoint.
|
||||
@@ -1628,15 +1642,21 @@ type SSecurityGroupCache struct {
|
||||
apis.SExternalizedResourceBase
|
||||
SCloudregionResourceBase
|
||||
SManagedResourceBase
|
||||
// 安全组Id
|
||||
SecgroupId string `json:"secgroup_id"`
|
||||
SSecurityGroupResourceBase
|
||||
// 虚拟私有网络外部Id
|
||||
VpcId string `json:"vpc_id"`
|
||||
}
|
||||
|
||||
// SSecurityGroupResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SSecurityGroupResourceBase.
|
||||
type SSecurityGroupResourceBase struct {
|
||||
// 本地安全组ID
|
||||
SecgroupId string `json:"secgroup_id"`
|
||||
}
|
||||
|
||||
// SSecurityGroupRule is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SSecurityGroupRule.
|
||||
type SSecurityGroupRule struct {
|
||||
apis.SResourceBase
|
||||
SSecurityGroupResourceBase
|
||||
Id string `json:"id"`
|
||||
Priority int64 `json:"priority"`
|
||||
Protocol string `json:"protocol"`
|
||||
@@ -1645,7 +1665,6 @@ type SSecurityGroupRule struct {
|
||||
CIDR string `json:"cidr"`
|
||||
Action string `json:"action"`
|
||||
Description string `json:"description"`
|
||||
SecgroupID string `json:"secgroup_id"`
|
||||
}
|
||||
|
||||
// SServerSku is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SServerSku.
|
||||
@@ -1735,15 +1754,23 @@ type SSnapshotPolicyCache struct {
|
||||
apis.SExternalizedResourceBase
|
||||
SCloudregionResourceBase
|
||||
SManagedResourceBase
|
||||
SnapshotpolicyId string `json:"snapshotpolicy_id"`
|
||||
SSnapshotPolicyResourceBase
|
||||
}
|
||||
|
||||
// SSnapshotPolicyDisk is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SSnapshotPolicyDisk.
|
||||
type SSnapshotPolicyDisk struct {
|
||||
apis.SVirtualJointResourceBase
|
||||
SSnapshotPolicyResourceBase
|
||||
SDiskResourceBase
|
||||
// SnapshotpolicyId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
// DiskId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// SSnapshotPolicyResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SSnapshotPolicyResourceBase.
|
||||
type SSnapshotPolicyResourceBase struct {
|
||||
// 本地快照策略ID
|
||||
SnapshotpolicyId string `json:"snapshotpolicy_id"`
|
||||
DiskId string `json:"disk_id"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// SStorage is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SStorage.
|
||||
@@ -1791,12 +1818,11 @@ type SStoragecache struct {
|
||||
// SStoragecachedimage is an autogenerated struct via yunion.io/x/onecloud/pkg/compute/models.SStoragecachedimage.
|
||||
type SStoragecachedimage struct {
|
||||
apis.SJointResourceBase
|
||||
apis.SExternalizedResourceBase
|
||||
// 存储缓存Id
|
||||
StoragecacheId string `json:"storagecache_id"`
|
||||
// 镜像缓存Id
|
||||
CachedimageId string `json:"cachedimage_id"`
|
||||
// 外部Id
|
||||
ExternalId string `json:"external_id"`
|
||||
// 镜像状态
|
||||
Status string `json:"status"`
|
||||
Path string `json:"path"`
|
||||
|
||||
@@ -115,6 +115,8 @@ type ModelBaseListInput struct {
|
||||
Field []string `json:"field"`
|
||||
// 用于数据导出,指定导出的数据字段
|
||||
ExportKeys string `json:"export_keys"`
|
||||
// 返回结果携带delete_fail_reason和update_fail_reason字段
|
||||
ShowFailReason *bool `json:"show_fail_reason"`
|
||||
}
|
||||
|
||||
type IncrementalListInput struct {
|
||||
@@ -227,3 +229,12 @@ type ExternalizedResourceBaseListInput struct {
|
||||
// 以资源外部ID过滤
|
||||
ExternalId string `json:"external_id"`
|
||||
}
|
||||
|
||||
type DeletePreventableResourceBaseListInput struct {
|
||||
// 是否禁止删除
|
||||
DisableDelete *bool `json:"disable_delete"`
|
||||
}
|
||||
|
||||
type ScopedResourceBaseListInput struct {
|
||||
ProjectizedResourceListInput
|
||||
}
|
||||
|
||||
@@ -125,3 +125,7 @@ type ProjectizedResourceInfo struct {
|
||||
// Deprecated
|
||||
Tenant string `json:"project"`
|
||||
}
|
||||
|
||||
type ScopedResourceBaseInfo struct {
|
||||
ProjectizedResourceInfo
|
||||
}
|
||||
|
||||
@@ -100,8 +100,7 @@ type SResourceBase struct {
|
||||
|
||||
// SScopedResourceBase is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SScopedResourceBase.
|
||||
type SScopedResourceBase struct {
|
||||
DomainId string `json:"domain_id"`
|
||||
ProjectId string `json:"tenant_id"`
|
||||
SProjectizedResourceBase
|
||||
}
|
||||
|
||||
// SSharableBaseResource is an autogenerated struct via yunion.io/x/onecloud/pkg/cloudcommon/db.SSharableBaseResource.
|
||||
|
||||
@@ -246,7 +246,9 @@ func FetchCustomizeColumns(
|
||||
}
|
||||
retVal := make([]*jsonutils.JSONDict, ret[0].Len())
|
||||
for i := 0; i < ret[0].Len(); i += 1 {
|
||||
retVal[i] = ValueToJSONDict(ret[0].Index(i))
|
||||
jsonDict := ValueToJSONDict(ret[0].Index(i))
|
||||
jsonDict.Update(jsonutils.Marshal(objs[i]))
|
||||
retVal[i] = jsonDict
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
@@ -330,9 +330,10 @@ func mergeFields(metaFields, queryFields []string, isSysAdmin bool) stringutils2
|
||||
}
|
||||
|
||||
func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, q *sqlchemy.SQuery, query jsonutils.JSONObject, delayFetch bool) ([]jsonutils.JSONObject, error) {
|
||||
metaFields := listFields(manager, userCred)
|
||||
metaFields, excludeFields := listFields(manager, userCred)
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
listF := mergeFields(metaFields, fieldFilter, IsAllowList(rbacutils.ScopeSystem, userCred, manager))
|
||||
listExcludes, _, _ := stringutils2.Split(stringutils2.NewSortedStrings(excludeFields), listF)
|
||||
|
||||
showDetails := false
|
||||
showDetailsJson, _ := query.Get("details")
|
||||
@@ -342,7 +343,7 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
showDetails = true
|
||||
}
|
||||
items := make([]interface{}, 0)
|
||||
results := make([]jsonutils.JSONObject, 0)
|
||||
extraResults := make([]jsonutils.JSONObject, 0)
|
||||
rows, err := q.Rows()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return nil, err
|
||||
@@ -354,8 +355,8 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
return nil, err
|
||||
}
|
||||
|
||||
extraData := jsonutils.NewDict()
|
||||
if query.Contains("export_keys") {
|
||||
extraData := jsonutils.NewDict()
|
||||
RowMap, err := q.Row2Map(rows)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -368,6 +369,7 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
extraResults = append(extraResults, extraData)
|
||||
} else {
|
||||
err = q.Row2Struct(rows, item)
|
||||
if err != nil {
|
||||
@@ -381,9 +383,9 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
}
|
||||
|
||||
jsonDict := jsonutils.Marshal(item).(*jsonutils.JSONDict)
|
||||
jsonDict = jsonDict.CopyIncludes([]string(listF)...)
|
||||
jsonDict.Update(extraData)
|
||||
// jsonDict := jsonutils.Marshal(item).(*jsonutils.JSONDict)
|
||||
// jsonDict = jsonDict.CopyIncludes([]string(listF)...)
|
||||
// jsonDict.Update(extraData)
|
||||
// ignore GetExtraDetails
|
||||
/*if showDetails && !query.Contains("export_keys") {
|
||||
extraDict, _ := GetExtraDetails(item, ctx, userCred, query, true)
|
||||
@@ -394,9 +396,10 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
// jsonDict = getModelExtraDetails(item, ctx, jsonDict)
|
||||
}*/
|
||||
results = append(results, jsonDict)
|
||||
// results = append(results, jsonDict)
|
||||
items = append(items, item)
|
||||
}
|
||||
results := make([]jsonutils.JSONObject, len(items))
|
||||
if showDetails && !query.Contains("export_keys") {
|
||||
extraRows, err := FetchCustomizeColumns(manager, ctx, userCred, query, items, stringutils2.NewSortedStrings(fieldFilter), true)
|
||||
|
||||
@@ -405,9 +408,18 @@ func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
if len(extraRows) == len(results) {
|
||||
for i := range results {
|
||||
extraRows[i].Update(results[i])
|
||||
results[i] = extraRows[i]
|
||||
results[i] = extraRows[i].CopyExcludes(listExcludes...)
|
||||
}
|
||||
} else {
|
||||
return nil, httperrors.NewInternalServerError("FetchCustomizeColumns return incorrect number of results")
|
||||
}
|
||||
} else {
|
||||
for i := range items {
|
||||
jsonDict := jsonutils.Marshal(items[i]).(*jsonutils.JSONDict).CopyExcludes(listExcludes...)
|
||||
if i < len(extraResults) {
|
||||
jsonDict.Update(extraResults[i])
|
||||
}
|
||||
results[i] = jsonDict
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
@@ -727,7 +739,7 @@ func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.J
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func getModelExtraDetails(item IModel, ctx context.Context) apis.ModelBaseDetails {
|
||||
func getModelExtraDetails(item IModel, ctx context.Context, showReason bool) apis.ModelBaseDetails {
|
||||
out := apis.ModelBaseDetails{
|
||||
CanDelete: true,
|
||||
CanUpdate: true,
|
||||
@@ -735,12 +747,16 @@ func getModelExtraDetails(item IModel, ctx context.Context) apis.ModelBaseDetail
|
||||
err := item.ValidateDeleteCondition(ctx)
|
||||
if err != nil {
|
||||
out.CanDelete = false
|
||||
out.DeleteFailReason = err.Error()
|
||||
if showReason {
|
||||
out.DeleteFailReason = err.Error()
|
||||
}
|
||||
}
|
||||
err = item.ValidateUpdateCondition(ctx)
|
||||
if err != nil {
|
||||
out.CanUpdate = false
|
||||
out.UpdateFailReason = err.Error()
|
||||
if showReason {
|
||||
out.UpdateFailReason = err.Error()
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -779,13 +795,14 @@ func getItemDetails(manager IModelManager, item IModel, ctx context.Context, use
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
metaFields := GetDetailFields(manager, userCred)
|
||||
metaFields, excludeFields := GetDetailFields(manager, userCred)
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
getFields := mergeFields(metaFields, fieldFilter, IsAllowGet(rbacutils.ScopeSystem, userCred, item))
|
||||
excludes, _, _ := stringutils2.Split(stringutils2.NewSortedStrings(excludeFields), getFields)
|
||||
|
||||
jsonDict := jsonutils.Marshal(item).(*jsonutils.JSONDict)
|
||||
jsonDict = jsonDict.CopyIncludes(getFields...)
|
||||
extraDict.Update(jsonDict)
|
||||
//jsonDict := jsonutils.Marshal(item).(*jsonutils.JSONDict)
|
||||
//jsonDict = jsonDict.CopyIncludes(getFields...)
|
||||
// extraDict.Update(jsonDict)
|
||||
// jsonDict = getModelExtraDetails(item, ctx, jsonDict)
|
||||
|
||||
extraRows, err := FetchCustomizeColumns(manager, ctx, userCred, query, []interface{}{item}, stringutils2.NewSortedStrings(fieldFilter), false)
|
||||
@@ -793,11 +810,10 @@ func getItemDetails(manager IModelManager, item IModel, ctx context.Context, use
|
||||
return nil, errors.Wrap(err, "FetchCustomizeColumns")
|
||||
}
|
||||
if len(extraRows) == 1 {
|
||||
extraRows[0].Update(extraDict)
|
||||
extraDict = extraRows[0]
|
||||
return extraRows[0].CopyExcludes(excludes...), nil
|
||||
}
|
||||
|
||||
return extraDict, nil
|
||||
log.Errorf("FetchCustomizeColumns return incorrect number of objects %d", len(extraRows))
|
||||
return nil, httperrors.NewInternalServerError("FetchCustomizeColumns returns incorrect results")
|
||||
}
|
||||
|
||||
func (dispatcher *DBModelDispatcher) tryGetModelProperty(ctx context.Context, property string, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
|
||||
@@ -70,16 +70,19 @@ func allowOptional(manager IResource, userCred mcclient.TokenCredential, action
|
||||
* update: user | domain | admin
|
||||
*
|
||||
*/
|
||||
func listFields(manager IModelManager, userCred mcclient.TokenCredential) []string {
|
||||
ret := make([]string, 0)
|
||||
func listFields(manager IModelManager, userCred mcclient.TokenCredential) ([]string, []string) {
|
||||
includes := make([]string, 0)
|
||||
excludes := make([]string, 0)
|
||||
for _, col := range manager.TableSpec().Columns() {
|
||||
tags := col.Tags()
|
||||
list, _ := tags["list"]
|
||||
if allowAction(manager, userCred, list, IsAllowList) {
|
||||
ret = append(ret, col.Name())
|
||||
includes = append(includes, col.Name())
|
||||
} else {
|
||||
excludes = append(excludes, col.Name())
|
||||
}
|
||||
}
|
||||
return ret
|
||||
return includes, excludes
|
||||
}
|
||||
|
||||
func searchFields(manager IModelManager, userCred mcclient.TokenCredential) stringutils2.SSortedStrings {
|
||||
@@ -96,17 +99,20 @@ func searchFields(manager IModelManager, userCred mcclient.TokenCredential) stri
|
||||
return stringutils2.SSortedStrings(ret)
|
||||
}
|
||||
|
||||
func GetDetailFields(manager IModelManager, userCred mcclient.TokenCredential) []string {
|
||||
ret := make([]string, 0)
|
||||
func GetDetailFields(manager IModelManager, userCred mcclient.TokenCredential) ([]string, []string) {
|
||||
includes := make([]string, 0)
|
||||
excludes := make([]string, 0)
|
||||
for _, col := range manager.TableSpec().Columns() {
|
||||
tags := col.Tags()
|
||||
list := tags["list"]
|
||||
get := tags["get"]
|
||||
if allowAction(manager, userCred, list, IsAllowGet) || allowAction(manager, userCred, get, IsAllowGet) {
|
||||
ret = append(ret, col.Name())
|
||||
includes = append(includes, col.Name())
|
||||
} else {
|
||||
excludes = append(excludes, col.Name())
|
||||
}
|
||||
}
|
||||
return ret
|
||||
return includes, excludes
|
||||
}
|
||||
|
||||
func createRequireFields(manager IModelManager, userCred mcclient.TokenCredential) []string {
|
||||
|
||||
@@ -207,13 +207,6 @@ func (self *SJointResourceBase) AllowDetach(ctx context.Context, userCred mcclie
|
||||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
func (joint *SJointResourceBase) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
extra := joint.SResourceBase.GetCustomizeColumns(ctx, userCred, query)
|
||||
return JointModelExtra(joint, extra)
|
||||
}
|
||||
*/
|
||||
|
||||
func (manager *SJointResourceBaseManager) ResourceScope() rbacutils.TRbacScope {
|
||||
return manager.GetMasterManager().ResourceScope()
|
||||
}
|
||||
|
||||
@@ -293,9 +293,13 @@ func (manager *SModelBaseManager) FetchCustomizeColumns(
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []apis.ModelBaseDetails {
|
||||
showReason := false
|
||||
if query.Contains("show_fail_reason") {
|
||||
showReason = true
|
||||
}
|
||||
ret := make([]apis.ModelBaseDetails, len(objs))
|
||||
for i := range objs {
|
||||
ret[i] = getModelExtraDetails(objs[i].(IModel), ctx)
|
||||
ret[i] = getModelExtraDetails(objs[i].(IModel), ctx, showReason)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -81,18 +81,6 @@ func (model *SResourceBase) GetIResourceModel() IResourceModel {
|
||||
return model.GetVirtualObject().(IResourceModel)
|
||||
}
|
||||
|
||||
/*
|
||||
func (model *SResourceBase) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
extra := model.SModelBase.GetExtraDetails(ctx, userCred, query)
|
||||
canDelete := CanDelete(model, ctx)
|
||||
if canDelete {
|
||||
extra.Add(jsonutils.JSONTrue, "can_delete")
|
||||
} else {
|
||||
extra.Add(jsonutils.JSONFalse, "can_delete")
|
||||
}
|
||||
return extra
|
||||
}*/
|
||||
|
||||
func (model *SResourceBase) MarkDelete() error {
|
||||
model.Deleted = true
|
||||
model.DeletedAt = timeutils.UtcNow()
|
||||
@@ -186,11 +174,5 @@ func (manager *SResourceBaseManager) FetchCustomizeColumns(
|
||||
}
|
||||
|
||||
func (model *SResourceBase) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (apis.ResourceBaseDetails, error) {
|
||||
var err error
|
||||
out := apis.ResourceBaseDetails{}
|
||||
out.ModelBaseDetails, err = model.SModelBase.GetExtraDetails(ctx, userCred, query, isList)
|
||||
if err != nil {
|
||||
return out, errors.Wrap(err, "SModelBase.GetExtraDetails")
|
||||
}
|
||||
return out, nil
|
||||
return apis.ResourceBaseDetails{}, nil
|
||||
}
|
||||
|
||||
@@ -18,24 +18,26 @@ import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
type SScopedResourceBaseManager struct{}
|
||||
|
||||
type SScopedResourceBase struct {
|
||||
DomainId string `width:"64" charset:"ascii" nullable:"true" index:"true" list:"user"`
|
||||
ProjectId string `name:"tenant_id" width:"128" charset:"ascii" nullable:"true" index:"true" list:"user"`
|
||||
type SScopedResourceBaseManager struct {
|
||||
SProjectizedResourceBaseManager
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) ResourceScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeProject
|
||||
type SScopedResourceBase struct {
|
||||
SProjectizedResourceBase
|
||||
// DomainId string `width:"64" charset:"ascii" nullable:"true" index:"true" list:"user"`
|
||||
// ProjectId string `name:"tenant_id" width:"128" charset:"ascii" nullable:"true" index:"true" list:"user"`
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {
|
||||
@@ -57,10 +59,6 @@ func (m *SScopedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred
|
||||
return q
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) {
|
||||
return FetchProjectInfo(ctx, data)
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) ValidateCreateData(man IScopedResourceManager, ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input api.ScopedResourceCreateInput) (api.ScopedResourceCreateInput, error) {
|
||||
if input.Scope == "" {
|
||||
input.Scope = string(rbacutils.ScopeSystem)
|
||||
@@ -99,13 +97,6 @@ func getScopedResourceScope(domainId, projectId string) rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeNone
|
||||
}
|
||||
|
||||
func (s *SScopedResourceBase) GetOwnerId() mcclient.IIdentityProvider {
|
||||
return &SOwnerId{
|
||||
DomainId: s.DomainId,
|
||||
ProjectId: s.ProjectId,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SScopedResourceBase) GetResourceScope() rbacutils.TRbacScope {
|
||||
return getScopedResourceScope(s.DomainId, s.ProjectId)
|
||||
}
|
||||
@@ -235,3 +226,50 @@ func (m *SScopedResourceBaseManager) SetScopedResourceToProject(model IScopedRes
|
||||
}
|
||||
return setScopedResourceIds(model, userCred, project.GetDomainId(), projectId)
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query apis.ScopedResourceBaseListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := m.SProjectizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ProjectizedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SProjectizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (m *SScopedResourceBaseManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query apis.ScopedResourceBaseListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := m.SProjectizedResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.ProjectizedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SProjectizedResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SScopedResourceBaseManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []apis.ScopedResourceBaseInfo {
|
||||
rows := make([]apis.ScopedResourceBaseInfo, len(objs))
|
||||
|
||||
projRows := manager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
for i := range rows {
|
||||
rows[i] = apis.ScopedResourceBaseInfo{
|
||||
ProjectizedResourceInfo: projRows[i],
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ type SBaremetalagentManager struct {
|
||||
|
||||
type SBaremetalagent struct {
|
||||
db.SStandaloneResourceBase
|
||||
SZoneResourceBase
|
||||
SZoneResourceBase `width:"128" charset:"ascii" nullable:"false" list:"admin" update:"admin" create:"admin_required"`
|
||||
|
||||
Status string `width:"36" charset:"ascii" nullable:"false" default:"disable" list:"user" create:"optional"`
|
||||
AccessIp string `width:"16" charset:"ascii" nullable:"false" list:"admin" update:"admin" create:"admin_required"`
|
||||
@@ -279,13 +279,13 @@ func (manager *SBaremetalagentManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SZoneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
if len(query.Status) > 0 {
|
||||
q = q.Equals("status", query.Status)
|
||||
q = q.In("status", query.Status)
|
||||
}
|
||||
if len(query.AccessIp) > 0 {
|
||||
q = q.Equals("access_ip", query.AccessIp)
|
||||
q = q.In("access_ip", query.AccessIp)
|
||||
}
|
||||
if len(query.AgentType) > 0 {
|
||||
q = q.Equals("agent_type", query.AgentType)
|
||||
q = q.In("agent_type", query.AgentType)
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import (
|
||||
|
||||
type SBucketManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
}
|
||||
@@ -71,7 +72,7 @@ func init() {
|
||||
type SBucket struct {
|
||||
db.SVirtualResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
SCloudregionResourceBase
|
||||
SCloudregionResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
SManagedResourceBase
|
||||
|
||||
// CloudregionId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
@@ -601,6 +602,11 @@ func (manager *SBucketManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
@@ -612,13 +618,13 @@ func (manager *SBucketManager) ListItemFilter(
|
||||
}
|
||||
|
||||
if len(query.StorageClass) > 0 {
|
||||
q = q.Equals("storage_class", query.StorageClass)
|
||||
q = q.In("storage_class", query.StorageClass)
|
||||
}
|
||||
if len(query.Location) > 0 {
|
||||
q = q.Equals("location", query.Location)
|
||||
q = q.In("location", query.Location)
|
||||
}
|
||||
if len(query.Acl) > 0 {
|
||||
q = q.Equals("acl", query.Acl)
|
||||
q = q.In("acl", query.Acl)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
|
||||
type SCachedimageManager struct {
|
||||
db.SStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
}
|
||||
|
||||
var CachedimageManager *SCachedimageManager
|
||||
@@ -642,6 +643,11 @@ func (manager *SCachedimageManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = managedResourceFilterByRegion(q, query.RegionalFilterListInput, "id", func() *sqlchemy.SQuery {
|
||||
storagecachedImages := StoragecachedimageManager.Query().SubQuery()
|
||||
storageCaches := StoragecacheManager.Query().SubQuery()
|
||||
@@ -675,7 +681,7 @@ func (manager *SCachedimageManager) ListItemFilter(
|
||||
}
|
||||
|
||||
if len(query.ImageType) > 0 {
|
||||
q = q.Equals("image_type", query.ImageType)
|
||||
q = q.In("image_type", query.ImageType)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
|
||||
@@ -54,6 +54,7 @@ import (
|
||||
|
||||
type SCloudaccountManager struct {
|
||||
db.SEnabledStatusDomainLevelResourceBaseManager
|
||||
SSyncableBaseResourceManager
|
||||
}
|
||||
|
||||
var CloudaccountManager *SCloudaccountManager
|
||||
@@ -1251,6 +1252,11 @@ func (manager *SCloudaccountManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SEnabledStatusDomainLevelResourceBaseManager")
|
||||
}
|
||||
q, err = manager.SSyncableBaseResourceManager.ListItemFilter(ctx, q, userCred, query.SyncableBaseResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSyncableBaseResourceManager.ListItemFilter")
|
||||
}
|
||||
|
||||
managerStr := query.Cloudprovider
|
||||
if len(managerStr) > 0 {
|
||||
providerObj, err := CloudproviderManager.FetchByIdOrName(userCred, managerStr)
|
||||
@@ -1288,9 +1294,6 @@ func (manager *SCloudaccountManager) ListItemFilter(
|
||||
q = q.In("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
if len(query.SyncStatus) > 0 {
|
||||
q = q.In("sync_status", query.SyncStatus)
|
||||
}
|
||||
if len(query.HealthStatus) > 0 {
|
||||
q = q.In("health_status", query.HealthStatus)
|
||||
}
|
||||
|
||||
@@ -32,10 +32,14 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
type SCloudproviderregionManager struct {
|
||||
db.SJointResourceBaseManager
|
||||
SSyncableBaseResourceManager
|
||||
SCloudregionResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
}
|
||||
|
||||
var CloudproviderRegionManager *SCloudproviderregionManager
|
||||
@@ -51,6 +55,9 @@ func init() {
|
||||
CloudproviderManager,
|
||||
CloudregionManager,
|
||||
),
|
||||
SManagedResourceBaseManager: SManagedResourceBaseManager{
|
||||
managerIdFieldName: "cloudprovider_id",
|
||||
},
|
||||
}
|
||||
CloudproviderRegionManager.SetVirtualObject(CloudproviderRegionManager)
|
||||
})
|
||||
@@ -61,9 +68,12 @@ type SCloudproviderregion struct {
|
||||
|
||||
SSyncableBaseResource
|
||||
|
||||
SCloudregionResourceBase `width:"36" charset:"ascii" nullable:"false" list:"domain"`
|
||||
|
||||
// 云订阅ID
|
||||
CloudproviderId string `width:"36" charset:"ascii" nullable:"false" list:"domain"` // Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
CloudregionId string `width:"36" charset:"ascii" nullable:"false" list:"domain"`
|
||||
CloudproviderId string `width:"36" charset:"ascii" nullable:"false" list:"domain"`
|
||||
|
||||
//CloudregionId string `width:"36" charset:"ascii" nullable:"false" list:"domain"`
|
||||
|
||||
Enabled bool `nullable:"false" list:"domain" update:"domain"`
|
||||
|
||||
@@ -116,14 +126,55 @@ func (self *SCloudproviderregion) GetRegion() *SCloudregion {
|
||||
}
|
||||
|
||||
func (self *SCloudproviderregion) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (api.CloudproviderregionDetails, error) {
|
||||
var err error
|
||||
out := api.CloudproviderregionDetails{}
|
||||
out.JointResourceBaseDetails, err = self.SJointResourceBase.GetExtraDetails(ctx, userCred, query, isList)
|
||||
if err != nil {
|
||||
return out, err
|
||||
return api.CloudproviderregionDetails{}, nil
|
||||
}
|
||||
|
||||
func (manager *SCloudproviderregionManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []api.CloudproviderregionDetails {
|
||||
rows := make([]api.CloudproviderregionDetails, len(objs))
|
||||
|
||||
jointRows := manager.SJointResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
regionRows := manager.SCloudregionResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
managerIds := make([]string, len(rows))
|
||||
|
||||
for i := range rows {
|
||||
rows[i].JointResourceBaseDetails = jointRows[i]
|
||||
rows[i].CloudregionResourceInfo = regionRows[i]
|
||||
managerIds[i] = objs[i].(*SCloudproviderregion).CloudproviderId
|
||||
}
|
||||
out.Cloudprovider, out.Cloudregion = db.JointModelExtra(self)
|
||||
return self.getExtraDetails(out), nil
|
||||
|
||||
managers := make(map[string]SCloudprovider)
|
||||
err := db.FetchStandaloneObjectsByIds(CloudproviderManager, managerIds, &managers)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail %s", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
for i := range rows {
|
||||
if manager, ok := managers[managerIds[i]]; ok {
|
||||
rows[i].Cloudprovider = manager.Name
|
||||
account := manager.GetCloudaccount()
|
||||
rows[i].EnableAutoSync = false
|
||||
if account != nil {
|
||||
rows[i].CloudaccountId = account.Id
|
||||
rows[i].Cloudaccount = account.Name
|
||||
rows[i].CloudaccountDomainId = account.DomainId
|
||||
if account.GetEnabled() && account.EnableAutoSync {
|
||||
rows[i].EnableAutoSync = true
|
||||
}
|
||||
rows[i].SyncIntervalSeconds = account.getSyncIntervalSeconds()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
func (self *SCloudproviderregion) getSyncIntervalSeconds(account *SCloudaccount) int {
|
||||
@@ -133,21 +184,6 @@ func (self *SCloudproviderregion) getSyncIntervalSeconds(account *SCloudaccount)
|
||||
return account.getSyncIntervalSeconds()
|
||||
}
|
||||
|
||||
func (self *SCloudproviderregion) getExtraDetails(out api.CloudproviderregionDetails) api.CloudproviderregionDetails {
|
||||
account := self.GetAccount()
|
||||
if account != nil {
|
||||
out.CloudaccountId = account.Id
|
||||
out.Cloudaccount = account.Name
|
||||
out.CloudaccountDomainId = account.DomainId
|
||||
out.EnableAutoSync = false
|
||||
if account.GetEnabled() && account.EnableAutoSync {
|
||||
out.EnableAutoSync = true
|
||||
}
|
||||
out.SyncIntervalSeconds = self.getSyncIntervalSeconds(account)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (manager *SCloudproviderregion) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
return nil, httperrors.NewForbiddenError("not allow to create")
|
||||
}
|
||||
@@ -451,3 +487,82 @@ func (cprm *SCloudproviderregionManager) fetchRecordsByCloudproviderId(providerI
|
||||
}
|
||||
return recs, nil
|
||||
}
|
||||
|
||||
func (manager *SCloudproviderregionManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.CloudproviderregionListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SJointResourceBaseManager.ListItemFilter(ctx, q, userCred, query.JointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SJointResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SSyncableBaseResourceManager.ListItemFilter(ctx, q, userCred, query.SyncableBaseResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSyncableBaseResourceManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SCloudregionResourceBaseManager.ListItemFilter(ctx, q, userCred, query.RegionalFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if query.Enabled != nil {
|
||||
if *query.Enabled {
|
||||
q = q.IsTrue("enabled")
|
||||
} else {
|
||||
q = q.IsFalse("enabled")
|
||||
}
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SCloudproviderregionManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.CloudproviderregionListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SJointResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.JointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SJointResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SCloudregionResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.RegionalFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SManagedResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SCloudproviderregionManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SJointResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
q, err = manager.SCloudregionResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
q, err = manager.SManagedResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ import (
|
||||
type SCloudproviderManager struct {
|
||||
db.SEnabledStatusStandaloneResourceBaseManager
|
||||
db.SProjectizedResourceBaseManager
|
||||
|
||||
SSyncableBaseResourceManager
|
||||
}
|
||||
|
||||
var CloudproviderManager *SCloudproviderManager
|
||||
@@ -1019,7 +1021,11 @@ func (manager *SCloudproviderManager) ListItemFilter(
|
||||
|
||||
q, err := manager.SEnabledStatusStandaloneResourceBaseManager.ListItemFilter(ctx, q, userCred, query.EnabledStatusStandaloneResourceListInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "SEnabledStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SSyncableBaseResourceManager.ListItemFilter(ctx, q, userCred, query.SyncableBaseResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSyncableBaseResourceManager.ListItemFilter")
|
||||
}
|
||||
|
||||
managerStr := query.Cloudprovider
|
||||
@@ -1063,9 +1069,6 @@ func (manager *SCloudproviderManager) ListItemFilter(
|
||||
q = q.In("id", subq)
|
||||
}
|
||||
|
||||
if len(query.SyncStatus) > 0 {
|
||||
q = q.In("sync_status", query.SyncStatus)
|
||||
}
|
||||
if len(query.HealthStatus) > 0 {
|
||||
q = q.In("health_status", query.HealthStatus)
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
|
||||
type SCloudregionManager struct {
|
||||
db.SEnabledStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
}
|
||||
|
||||
var CloudregionManager *SCloudregionManager
|
||||
@@ -632,6 +633,8 @@ func (manager *SCloudregionManager) ListItemFilter(
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.CloudregionListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
providerStrs := query.Providers
|
||||
if len(providerStrs) > 0 {
|
||||
subq := queryCloudregionIdsByProviders("provider", providerStrs)
|
||||
@@ -644,11 +647,16 @@ func (manager *SCloudregionManager) ListItemFilter(
|
||||
q = q.In("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
q, err := manager.SEnabledStatusStandaloneResourceBaseManager.ListItemFilter(ctx, q, userCred, query.EnabledStatusStandaloneResourceListInput)
|
||||
q, err = manager.SEnabledStatusStandaloneResourceBaseManager.ListItemFilter(ctx, q, userCred, query.EnabledStatusStandaloneResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SEnabledStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "")
|
||||
}
|
||||
|
||||
cloudEnvStr := query.CloudEnv
|
||||
if cloudEnvStr == api.CLOUD_ENV_PUBLIC_CLOUD {
|
||||
q = q.In("provider", cloudprovider.GetPublicProviders())
|
||||
@@ -756,7 +764,7 @@ func (manager *SCloudregionManager) ListItemFilter(
|
||||
}
|
||||
|
||||
if len(query.Environment) > 0 {
|
||||
q = q.Equals("environment", query.Environment)
|
||||
q = q.In("environment", query.Environment)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
|
||||
@@ -41,6 +41,8 @@ type SSyncableBaseResource struct {
|
||||
LastSyncEndAt time.Time `list:"domain"`
|
||||
}
|
||||
|
||||
type SSyncableBaseResourceManager struct{}
|
||||
|
||||
func (self *SSyncableBaseResource) CanSync() bool {
|
||||
if self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_QUEUED || self.SyncStatus == api.CLOUD_PROVIDER_SYNC_STATUS_SYNCING {
|
||||
if self.LastSync.IsZero() || time.Now().Sub(self.LastSync) > 1800*time.Second {
|
||||
@@ -53,6 +55,18 @@ func (self *SSyncableBaseResource) CanSync() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *SSyncableBaseResourceManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.SyncableBaseResourceListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
if len(query.SyncStatus) > 0 {
|
||||
q = q.In("sync_status", query.SyncStatus)
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
type sStoragecacheSyncPair struct {
|
||||
local *SStoragecache
|
||||
remote cloudprovider.ICloudStoragecache
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
|
||||
type SDBInstanceAccountManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDBInstanceResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ type SDBInstanceAccount struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SDBInstanceResourceBase
|
||||
SDBInstanceResourceBase `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// 数据库密码
|
||||
Secret string `width:"256" charset:"ascii" nullable:"false" list:"domain" create:"optional"`
|
||||
@@ -199,6 +200,10 @@ func (manager *SDBInstanceAccountManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SDBInstanceResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DBInstanceFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDBInstanceResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
|
||||
type SDBInstanceBackupManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
SDBInstanceResourceBaseManager
|
||||
@@ -64,7 +65,7 @@ type SDBInstanceBackup struct {
|
||||
SManagedResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SDBInstanceResourceBase
|
||||
SDBInstanceResourceBase `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// RDS引擎
|
||||
// example: MySQL
|
||||
@@ -107,6 +108,11 @@ func (manager *SDBInstanceBackupManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
@@ -126,13 +132,13 @@ func (manager *SDBInstanceBackupManager) ListItemFilter(
|
||||
}
|
||||
|
||||
if len(query.Engine) > 0 {
|
||||
q = q.Equals("engine", query.Engine)
|
||||
q = q.In("engine", query.Engine)
|
||||
}
|
||||
if len(query.EngineVersion) > 0 {
|
||||
q = q.Equals("engine_version", query.EngineVersion)
|
||||
q = q.In("engine_version", query.EngineVersion)
|
||||
}
|
||||
if len(query.BackupMode) > 0 {
|
||||
q = q.Equals("backup_mode", query.BackupMode)
|
||||
q = q.In("backup_mode", query.BackupMode)
|
||||
}
|
||||
if len(query.DBNames) > 0 {
|
||||
q = q.Contains("db_names", query.DBNames)
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
|
||||
type SDBInstanceDatabaseManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDBInstanceResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ type SDBInstanceDatabase struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SDBInstanceResourceBase
|
||||
SDBInstanceResourceBase `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// 字符集
|
||||
// example: utf-8
|
||||
@@ -142,6 +143,10 @@ func (manager *SDBInstanceDatabaseManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SDBInstanceResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DBInstanceFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDBInstanceResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
|
||||
type SDBInstanceParameterManager struct {
|
||||
db.SStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDBInstanceResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -54,7 +55,7 @@ func init() {
|
||||
type SDBInstanceParameter struct {
|
||||
db.SStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
SDBInstanceResourceBase
|
||||
SDBInstanceResourceBase `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
// DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// 数据库参数名称
|
||||
@@ -81,6 +82,10 @@ func (manager *SDBInstanceParameterManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SDBInstanceResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DBInstanceFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDBInstanceResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
|
||||
type SDBInstancePrivilegeManager struct {
|
||||
db.SResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
}
|
||||
|
||||
var DBInstancePrivilegeManager *SDBInstancePrivilegeManager
|
||||
@@ -114,9 +115,13 @@ func (manager *SDBInstancePrivilegeManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.Privilege) > 0 {
|
||||
q = q.Equals("privilege", query.Privilege)
|
||||
q = q.In("privilege", query.Privilege)
|
||||
}
|
||||
|
||||
data := jsonutils.Marshal(query).(*jsonutils.JSONDict)
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
|
||||
type SDBInstanceSkuManager struct {
|
||||
db.SEnabledStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -121,6 +122,10 @@ func (manager *SDBInstanceSkuManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SEnabledStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if domainStr := query.ProjectDomain; len(domainStr) > 0 {
|
||||
domain, err := db.TenantCacheManager.FetchDomainByIdOrName(context.Background(), domainStr)
|
||||
@@ -142,22 +147,22 @@ func (manager *SDBInstanceSkuManager) ListItemFilter(
|
||||
|
||||
// StorageType
|
||||
if len(query.StorageType) > 0 {
|
||||
q = q.Equals("storage_type", query.StorageType)
|
||||
q = q.In("storage_type", query.StorageType)
|
||||
}
|
||||
if query.VcpuCount > 0 {
|
||||
q = q.Equals("vcpu_count", query.VcpuCount)
|
||||
if len(query.VcpuCount) > 0 {
|
||||
q = q.In("vcpu_count", query.VcpuCount)
|
||||
}
|
||||
if query.VmemSizeMb > 0 {
|
||||
q = q.Equals("vmem_size_mb", query.VmemSizeMb)
|
||||
if len(query.VmemSizeMb) > 0 {
|
||||
q = q.In("vmem_size_mb", query.VmemSizeMb)
|
||||
}
|
||||
if len(query.Category) > 0 {
|
||||
q = q.Equals("category", query.Category)
|
||||
q = q.In("category", query.Category)
|
||||
}
|
||||
if len(query.Engine) > 0 {
|
||||
q = q.Equals("engine", query.Engine)
|
||||
q = q.In("engine", query.Engine)
|
||||
}
|
||||
if len(query.EngineVersion) > 0 {
|
||||
q = q.Equals("engine_version", query.EngineVersion)
|
||||
q = q.In("engine_version", query.EngineVersion)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
type SDBInstanceJointsManager struct {
|
||||
db.SVirtualJointResourceBaseManager
|
||||
SDBInstanceResourceBaseManager
|
||||
}
|
||||
|
||||
func NewDBInstanceJointsManager(dt interface{}, tableName string, keyword string, keywordPlural string, slave db.IVirtualModelManager) SDBInstanceJointsManager {
|
||||
@@ -40,7 +41,8 @@ func NewDBInstanceJointsManager(dt interface{}, tableName string, keyword string
|
||||
type SDBInstanceJointsBase struct {
|
||||
db.SVirtualJointResourceBase
|
||||
|
||||
DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
SDBInstanceResourceBase `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
// DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
}
|
||||
|
||||
func (self *SDBInstanceJointsBase) getDBInstance() (*SDBInstance, error) {
|
||||
|
||||
@@ -48,6 +48,9 @@ import (
|
||||
|
||||
type SDBInstanceManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDeletePreventableResourceBaseManager
|
||||
|
||||
SCloudregionResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
SVpcResourceBaseManager
|
||||
@@ -152,17 +155,22 @@ func (man *SDBInstanceManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SDeletePreventableResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DeletePreventableResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDeletePreventableResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SCloudregionResourceBaseManager.ListItemFilter(ctx, q, userCred, query.RegionalFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SVpcResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VpcFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVpcResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"context"
|
||||
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
@@ -27,6 +31,8 @@ type SDeletePreventableResourceBase struct {
|
||||
DisableDelete tristate.TriState `nullable:"false" default:"true" list:"user" update:"user" create:"optional" json:"disable_delete"`
|
||||
}
|
||||
|
||||
type SDeletePreventableResourceBaseManager struct{}
|
||||
|
||||
func (lock *SDeletePreventableResourceBase) MarkDeletePreventionOff() {
|
||||
lock.DisableDelete = tristate.False
|
||||
}
|
||||
@@ -56,3 +62,19 @@ func (lock *SDeletePreventableResourceBase) DeletePreventionOff(model db.IModel,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SDeletePreventableResourceBaseManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query apis.DeletePreventableResourceBaseListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
if query.DisableDelete != nil {
|
||||
if *query.DisableDelete {
|
||||
q = q.IsTrue("disable_delete")
|
||||
} else {
|
||||
q = q.IsFalse("disable_delete")
|
||||
}
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import (
|
||||
|
||||
type SDiskManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SStorageResourceBaseManager
|
||||
SBillingResourceBaseManager
|
||||
}
|
||||
@@ -78,7 +79,7 @@ type SDisk struct {
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SBillingResourceBase
|
||||
SStorageResourceBase
|
||||
SStorageResourceBase `width:"128" charset:"ascii" nullable:"true" list:"admin" create:"optional"`
|
||||
|
||||
// 磁盘存储类型
|
||||
// example: qcow2
|
||||
@@ -147,6 +148,11 @@ func (manager *SDiskManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SStorageResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SBillingResourceBaseManager.ListItemFilter(ctx, q, userCred, query.BillingResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SBillingResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -56,7 +56,7 @@ const DNS_RECORDS_SEPARATOR = ","
|
||||
|
||||
type SDnsRecord struct {
|
||||
db.SAdminSharableVirtualResourceBase
|
||||
db.SEnabledResourceBase
|
||||
db.SEnabledResourceBase `nullable:"false" default:"true" create:"optional" list:"user"`
|
||||
|
||||
// DNS记录的过期时间,单位为秒
|
||||
// example: 60
|
||||
|
||||
@@ -101,7 +101,7 @@ func (man *SDynamicschedtagManager) InitializeData() error {
|
||||
//
|
||||
type SDynamicschedtag struct {
|
||||
db.SStandaloneResourceBase
|
||||
SSchedtagResourceBase
|
||||
SSchedtagResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" update:"admin"`
|
||||
|
||||
// 动态调度标间的匹配条件
|
||||
// example: host.sys_load > 1.5 || host.mem_used_percent > 0.7 => "high_load"
|
||||
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
// SElasticcache.Account
|
||||
type SElasticcacheAccountManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SElasticcacheResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ type SElasticcacheAccount struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SElasticcacheResourceBase
|
||||
SElasticcacheResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
@@ -463,6 +464,10 @@ func (manager *SElasticcacheAccountManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SElasticcacheResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ElasticcacheFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SElasticcacheResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
// SElasticcache.Acl
|
||||
type SElasticcacheAclManager struct {
|
||||
db.SStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SElasticcacheResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ func init() {
|
||||
type SElasticcacheAcl struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
SElasticcacheResourceBase
|
||||
SElasticcacheResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
@@ -343,6 +344,11 @@ func (manager *SElasticcacheAclManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SElasticcacheResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ElasticcacheFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SElasticcacheResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
// SElasticcache.Backup
|
||||
type SElasticcacheBackupManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SElasticcacheResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ func init() {
|
||||
type SElasticcacheBackup struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
SElasticcacheResourceBase
|
||||
SElasticcacheResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
@@ -355,6 +356,11 @@ func (manager *SElasticcacheBackupManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SElasticcacheResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ElasticcacheFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SElasticcacheResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -49,6 +49,8 @@ import (
|
||||
|
||||
type SElasticcacheManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDeletePreventableResourceBaseManager
|
||||
SVpcResourceBaseManager
|
||||
SZoneResourceBaseManager
|
||||
SNetworkResourceBaseManager
|
||||
@@ -73,7 +75,7 @@ type SElasticcache struct {
|
||||
db.SExternalizedResourceBase
|
||||
SBillingResourceBase
|
||||
SDeletePreventableResourceBase
|
||||
SVpcResourceBase
|
||||
SVpcResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
SZoneResourceBase
|
||||
|
||||
// 备可用区
|
||||
@@ -315,6 +317,14 @@ func (manager *SElasticcacheManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SDeletePreventableResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DeletePreventableResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDeletePreventableResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SVpcResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VpcFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVpcResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
// SElasticcache.Parameter
|
||||
type SElasticcacheParameterManager struct {
|
||||
db.SStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SElasticcacheResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ func init() {
|
||||
type SElasticcacheParameter struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
SElasticcacheResourceBase
|
||||
SElasticcacheResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
// ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
@@ -261,7 +262,10 @@ func (manager *SElasticcacheParameterManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SElasticcacheResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ElasticcacheFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SElasticcacheResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
|
||||
type SElasticcacheSkuManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
SZoneResourceBaseManager
|
||||
}
|
||||
@@ -225,6 +226,11 @@ func (manager *SElasticcacheSkuManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SStatusStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SCloudregionResourceBaseManager.ListItemFilter(ctx, q, userCred, query.RegionalFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -42,6 +42,7 @@ import (
|
||||
|
||||
type SElasticipManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
}
|
||||
@@ -63,11 +64,10 @@ func init() {
|
||||
|
||||
type SElasticip struct {
|
||||
db.SVirtualResourceBase
|
||||
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SManagedResourceBase
|
||||
SCloudregionResourceBase
|
||||
SCloudregionResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
|
||||
SBillingResourceBase
|
||||
|
||||
@@ -120,6 +120,11 @@ func (manager *SElasticipManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
type SExternalProjectManager struct {
|
||||
db.SStandaloneResourceBaseManager
|
||||
db.SProjectizedResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -297,6 +298,10 @@ func (manager *SExternalProjectManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -29,6 +30,7 @@ import (
|
||||
|
||||
type SGroupguestManager struct {
|
||||
SGroupJointsManager
|
||||
SGuestResourceBaseManager
|
||||
}
|
||||
|
||||
var GroupguestManager *SGroupguestManager
|
||||
@@ -152,3 +154,47 @@ func (self *SGroupguestManager) Attach(ctx context.Context, groupId, guestId str
|
||||
joint.SetModelManager(self, joint)
|
||||
return joint, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupguestManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupguestListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGroupJointsManager.ListItemFilter(ctx, q, userCred, query.GroupJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupJointsManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SGuestResourceBaseManager.ListItemFilter(ctx, q, userCred, query.GuestFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGuestResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.Tag) > 0 {
|
||||
q = q.In("tag", query.Tag)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupguestManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupguestListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGroupJointsManager.OrderByExtraFields(ctx, q, userCred, query.GroupJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupJointsManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SGuestResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.GuestFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGuestResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/reflectutils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -29,6 +31,7 @@ import (
|
||||
|
||||
type SGroupJointsManager struct {
|
||||
db.SVirtualJointResourceBaseManager
|
||||
SGroupResourceBaseManager
|
||||
}
|
||||
|
||||
func NewGroupJointsManager(dt interface{}, tableName string, keyword string, keywordPlural string, slave db.IVirtualModelManager) SGroupJointsManager {
|
||||
@@ -106,3 +109,43 @@ func (manager *SGroupJointsManager) FetchCustomizeColumns(
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
func (manager *SGroupJointsManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupJointsListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SVirtualJointResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VirtualJointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualJointResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SGroupResourceBaseManager.ListItemFilter(ctx, q, userCred, query.GroupFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupJointsManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupJointsListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SVirtualJointResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.VirtualJointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualJointResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SGroupResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.GroupFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -28,6 +30,7 @@ import (
|
||||
|
||||
type SGroupnetworkManager struct {
|
||||
SGroupJointsManager
|
||||
SNetworkResourceBaseManager
|
||||
}
|
||||
|
||||
var GroupnetworkManager *SGroupnetworkManager
|
||||
@@ -131,3 +134,47 @@ func (self *SGroupnetwork) Delete(ctx context.Context, userCred mcclient.TokenCr
|
||||
func (self *SGroupnetwork) Detach(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return db.DetachJoint(ctx, userCred, self)
|
||||
}
|
||||
|
||||
func (manager *SGroupnetworkManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupnetworkListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGroupJointsManager.ListItemFilter(ctx, q, userCred, query.GroupJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupJointsManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SNetworkResourceBaseManager.ListItemFilter(ctx, q, userCred, query.NetworkFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNetworkResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.IpAddr) > 0 {
|
||||
q = q.In("ip_addr", query.IpAddr)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupnetworkManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupnetworkListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGroupJointsManager.OrderByExtraFields(ctx, q, userCred, query.GroupJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGroupJointsManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SNetworkResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.NetworkFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNetworkResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/reflectutils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
type SGroupResourceBase struct {
|
||||
// 实例组ID
|
||||
GroupId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
}
|
||||
|
||||
type SGroupResourceBaseManager struct {
|
||||
}
|
||||
|
||||
func (self *SGroupResourceBase) GetGroup() *SGroup {
|
||||
obj, _ := GroupManager.FetchById(self.GroupId)
|
||||
if obj != nil {
|
||||
return obj.(*SGroup)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SGroupResourceBase) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) api.GroupResourceInfo {
|
||||
return api.GroupResourceInfo{}
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
objs []interface{},
|
||||
fields stringutils2.SSortedStrings,
|
||||
isList bool,
|
||||
) []api.GroupResourceInfo {
|
||||
rows := make([]api.GroupResourceInfo, len(objs))
|
||||
groupIds := make([]string, len(objs))
|
||||
for i := range objs {
|
||||
var base *SGroupResourceBase
|
||||
err := reflectutils.FindAnonymouStructPointer(objs[i], &base)
|
||||
if err != nil {
|
||||
log.Errorf("Cannot find SGuestResourceBase in object %s", objs[i])
|
||||
continue
|
||||
}
|
||||
groupIds[i] = base.GroupId
|
||||
}
|
||||
groupNames, err := db.FetchIdNameMap2(GroupManager, groupIds)
|
||||
if err != nil {
|
||||
log.Errorf("FetchIdNameMap2 fail %s", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
for i := range rows {
|
||||
if name, ok := groupNames[groupIds[i]]; ok {
|
||||
rows[i].Group = name
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupFilterListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
if len(query.Group) > 0 {
|
||||
groupObj, err := GroupManager.FetchByIdOrName(userCred, query.Group)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == sql.ErrNoRows {
|
||||
return nil, httperrors.NewResourceNotFoundError2(GroupManager.Keyword(), query.Group)
|
||||
} else {
|
||||
return nil, errors.Wrap(err, "GroupManager.FetchByIdOrName")
|
||||
}
|
||||
}
|
||||
q = q.Equals("group_id", groupObj.GetId())
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
switch field {
|
||||
case "group":
|
||||
groupQuery := GroupManager.Query("name", "id").SubQuery()
|
||||
q = q.AppendField(groupQuery.Field("name", field)).Distinct()
|
||||
q = q.Join(groupQuery, sqlchemy.Equals(q.Field("group_id"), groupQuery.Field("id")))
|
||||
return q, nil
|
||||
}
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupFilterListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, orders, fields := manager.GetOrderBySubQuery(q, userCred, query)
|
||||
if len(orders) > 0 {
|
||||
q = db.OrderByFields(q, orders, fields)
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) GetOrderBySubQuery(
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GroupFilterListInput,
|
||||
) (*sqlchemy.SQuery, []string, []sqlchemy.IQueryField) {
|
||||
groupQ := GroupManager.Query("id", "name")
|
||||
var orders []string
|
||||
var fields []sqlchemy.IQueryField
|
||||
|
||||
if db.NeedOrderQuery(manager.GetOrderByFields(query)) {
|
||||
subq := groupQ.SubQuery()
|
||||
q = q.LeftJoin(subq, sqlchemy.Equals(q.Field("group_id"), subq.Field("id")))
|
||||
if db.NeedOrderQuery([]string{query.OrderByGroup}) {
|
||||
orders = append(orders, query.OrderByGroup)
|
||||
fields = append(fields, subq.Field("name"))
|
||||
}
|
||||
}
|
||||
return q, orders, fields
|
||||
}
|
||||
|
||||
func (manager *SGroupResourceBaseManager) GetOrderByFields(query api.GroupFilterListInput) []string {
|
||||
return []string{query.OrderByGroup}
|
||||
}
|
||||
@@ -66,26 +66,26 @@ func init() {
|
||||
type SGroup struct {
|
||||
db.SVirtualResourceBase
|
||||
|
||||
SZoneResourceBase
|
||||
SZoneResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
|
||||
db.SEnabledResourceBase
|
||||
db.SEnabledResourceBase `nullable:"false" default:"true" create:"optional" list:"user" update:"user"`
|
||||
|
||||
// 服务类型
|
||||
ServiceType string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional" json:"service_type"`
|
||||
ParentId string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional" json:"parent_id"`
|
||||
ServiceType string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
ParentId string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
|
||||
// 可用区Id
|
||||
// example: zone1
|
||||
// ZoneId string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional" json:"zone_id"`
|
||||
// ZoneId string `width:"36" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"`
|
||||
|
||||
// 调度策略
|
||||
SchedStrategy string `width:"16" charset:"ascii" nullable:"true" default:"" list:"user" update:"user" create:"optional" json:"sched_strategy"`
|
||||
SchedStrategy string `width:"16" charset:"ascii" nullable:"true" default:"" list:"user" update:"user" create:"optional"`
|
||||
|
||||
// the upper limit number of guests with this group in a host
|
||||
Granularity int `nullable:"false" list:"user" get:"user" create:"optional" update:"user" default:"1" json:"granularity"`
|
||||
ForceDispersion tristate.TriState `list:"user" get:"user" create:"optional" update:"user" default:"true" json:"force_dispersion"`
|
||||
Granularity int `nullable:"false" list:"user" get:"user" create:"optional" update:"user" default:"1"`
|
||||
ForceDispersion tristate.TriState `list:"user" get:"user" create:"optional" update:"user" default:"true"`
|
||||
// 是否启用
|
||||
// Enabled tristate.TriState `nullable:"false" default:"true" create:"optional" list:"user" update:"user" json:"enabled"`
|
||||
// Enabled tristate.TriState `nullable:"false" default:"true" create:"optional" list:"user" update:"user"`
|
||||
}
|
||||
|
||||
// 主机组列表
|
||||
|
||||
@@ -57,8 +57,8 @@ func init() {
|
||||
type SGuestdisk struct {
|
||||
SGuestJointsBase
|
||||
|
||||
// SDiskResourceBase `list:"user" create:"required"`
|
||||
DiskId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
SDiskResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
// DiskId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
|
||||
ImagePath string `width:"256" charset:"ascii" nullable:"false" get:"user" create:"required"` // Column(VARCHAR(256, charset='ascii'), nullable=False)
|
||||
|
||||
@@ -151,6 +151,7 @@ func (manager *SGuestdiskManager) FetchCustomizeColumns(
|
||||
for i := range rows {
|
||||
if disk, ok := disks[diskIds[i]]; ok {
|
||||
rows[i].Disk = disk.Name
|
||||
rows[i].Status = disk.Status
|
||||
rows[i].DiskSize = disk.DiskSize
|
||||
rows[i].DiskType = disk.DiskType
|
||||
storage := disk.GetStorage()
|
||||
|
||||
@@ -66,6 +66,8 @@ import (
|
||||
|
||||
type SGuestManager struct {
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SDeletePreventableResourceBaseManager
|
||||
|
||||
SHostResourceBaseManager
|
||||
SBillingResourceBaseManager
|
||||
@@ -96,7 +98,7 @@ type SGuest struct {
|
||||
SBillingResourceBase
|
||||
SDeletePreventableResourceBase
|
||||
|
||||
SHostResourceBase
|
||||
SHostResourceBase `width:"36" charset:"ascii" nullable:"true" list:"admin" get:"admin" index:"true"`
|
||||
|
||||
// CPU大小
|
||||
VcpuCount int `nullable:"false" default:"1" list:"user" create:"optional"`
|
||||
@@ -168,6 +170,16 @@ func (manager *SGuestManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SHostResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SDeletePreventableResourceBaseManager.ListItemFilter(ctx, q, userCred, query.DeletePreventableResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SDeletePreventableResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SBillingResourceBaseManager.ListItemFilter(ctx, q, userCred, query.BillingResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SBillingResourceBaseManager.ListItemFilter")
|
||||
@@ -1512,7 +1524,8 @@ func (guest *SGuest) PostCreate(ctx context.Context, userCred mcclient.TokenCred
|
||||
}
|
||||
secgroups, _ := jsonutils.GetStringArray(data, "secgroups")
|
||||
for _, secgroup := range secgroups {
|
||||
gs := SGuestsecgroup{SecgroupId: secgroup}
|
||||
gs := SGuestsecgroup{}
|
||||
gs.SecgroupId = secgroup
|
||||
gs.GuestId = guest.Id
|
||||
GuestsecgroupManager.TableSpec().Insert(&gs)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -27,6 +30,7 @@ import (
|
||||
|
||||
type SGuestsecgroupManager struct {
|
||||
SGuestJointsManager
|
||||
SSecurityGroupResourceBaseManager
|
||||
}
|
||||
|
||||
var GuestsecgroupManager *SGuestsecgroupManager
|
||||
@@ -49,7 +53,8 @@ func init() {
|
||||
type SGuestsecgroup struct {
|
||||
SGuestJointsBase
|
||||
|
||||
SecgroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
SSecurityGroupResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
// SecgroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False)
|
||||
}
|
||||
|
||||
func (manager *SGuestsecgroupManager) GetSlaveFieldName() string {
|
||||
@@ -78,7 +83,8 @@ func (manager *SGuestsecgroupManager) newGuestSecgroup(ctx context.Context, user
|
||||
return nil, fmt.Errorf("security group %s has already been assigned to guest %s", secgroup.Name, guest.Name)
|
||||
}
|
||||
|
||||
gs := SGuestsecgroup{SecgroupId: secgroup.Id}
|
||||
gs := SGuestsecgroup{}
|
||||
gs.SecgroupId = secgroup.Id
|
||||
gs.SetModelManager(manager, &gs)
|
||||
gs.GuestId = guest.Id
|
||||
|
||||
@@ -126,3 +132,43 @@ func (manager *SGuestsecgroupManager) DeleteGuestSecgroup(ctx context.Context, u
|
||||
func (self *SGuestsecgroup) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return db.DeleteModel(ctx, userCred, self)
|
||||
}
|
||||
|
||||
func (manager *SGuestsecgroupManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GuestsecgroupListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGuestJointsManager.ListItemFilter(ctx, q, userCred, query.GuestJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGuestJointsManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SSecurityGroupResourceBaseManager.ListItemFilter(ctx, q, userCred, query.SecgroupFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSecurityGroupResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SGuestsecgroupManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.GuestsecgroupListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SGuestJointsManager.OrderByExtraFields(ctx, q, userCred, query.GuestJointsListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SGuestJointsManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SSecurityGroupResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.SecgroupFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSecurityGroupResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
)
|
||||
|
||||
type SHostResourceBase struct {
|
||||
HostId string `width:"36" charset:"ascii" nullable:"true" list:"user" index:"true" create:"optional"`
|
||||
HostId string `width:"36" charset:"ascii" nullable:"true" list:"user"`
|
||||
}
|
||||
|
||||
type SHostResourceBaseManager struct {
|
||||
|
||||
@@ -59,6 +59,7 @@ import (
|
||||
|
||||
type SHostManager struct {
|
||||
db.SEnabledStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SZoneResourceBaseManager
|
||||
SManagedResourceBaseManager
|
||||
}
|
||||
@@ -201,6 +202,11 @@ func (manager *SHostManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = manager.SZoneResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ZonalFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SZoneResourceBaseManager.ListItemFilter")
|
||||
|
||||
@@ -74,7 +74,7 @@ func init() {
|
||||
|
||||
type SIsolatedDevice struct {
|
||||
db.SStandaloneResourceBase
|
||||
SHostResourceBase
|
||||
SHostResourceBase `width:"36" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required"`
|
||||
|
||||
// 宿主机Id
|
||||
// HostId string `width:"36" charset:"ascii" nullable:"false" default:"" index:"true" list:"admin" create:"admin_required"`
|
||||
|
||||
@@ -93,6 +93,14 @@ func (manager *SKeypairManager) ListItemFilter(
|
||||
} else {
|
||||
q = q.Equals("owner_id", userCred.GetUserId())
|
||||
}
|
||||
|
||||
if len(query.Scheme) > 0 {
|
||||
q = q.In("scheme", query.Scheme)
|
||||
}
|
||||
if len(query.Fingerprint) > 0 {
|
||||
q = q.In("fingerprint", query.Fingerprint)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,10 @@ func (aclEntries *SLoadbalancerAclEntries) Fingerprint() string {
|
||||
|
||||
type SLoadbalancerAclManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
|
||||
db.SSharableVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
|
||||
SManagedResourceBaseManager
|
||||
SCloudregionResourceBaseManager
|
||||
}
|
||||
@@ -454,6 +457,10 @@ func (manager *SLoadbalancerAclManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SSharableVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SManagedResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ManagedResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SManagedResourceBaseManager.ListItemFilter")
|
||||
@@ -462,6 +469,11 @@ func (manager *SLoadbalancerAclManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SCloudregionResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(input.Fingerprint) > 0 {
|
||||
q = q.In("fingerprint", input.Fingerprint)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func init() {
|
||||
//
|
||||
type SLoadbalancerAgent struct {
|
||||
db.SStandaloneResourceBase
|
||||
SLoadbalancerClusterResourceBase
|
||||
SLoadbalancerClusterResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
|
||||
Version string `width:"64" nullable:"true" list:"admin" update:"admin"`
|
||||
IP string `width:"32" nullable:"true" list:"admin" update:"admin"`
|
||||
@@ -385,6 +385,17 @@ func (man *SLoadbalancerAgentManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerClusterResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.Version) > 0 {
|
||||
q = q.In("version", query.Version)
|
||||
}
|
||||
if len(query.IP) > 0 {
|
||||
q = q.In("ip", query.IP)
|
||||
}
|
||||
if len(query.HaState) > 0 {
|
||||
q = q.In("ha_state", query.HaState)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
type SLoadbalancerBackendGroupManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SLoadbalancerResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ type SLoadbalancerBackendGroup struct {
|
||||
db.SVirtualResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SLoadbalancerResourceBase
|
||||
SLoadbalancerResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
Type string `width:"36" charset:"ascii" nullable:"false" list:"user" default:"normal" create:"optional"`
|
||||
|
||||
@@ -89,6 +90,11 @@ func (man *SLoadbalancerBackendGroupManager) ListItemFilter(
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SLoadbalancerResourceBaseManager.ListItemFilter(ctx, q, userCred, query.LoadbalancerFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerResourceBaseManager.ListItemFilter")
|
||||
@@ -112,6 +118,11 @@ func (man *SLoadbalancerBackendGroupManager) ListItemFilter(
|
||||
return nil, httperrors.NewInternalServerError("query backend group releated resource failed.")
|
||||
}
|
||||
}
|
||||
|
||||
if len(query.Type) > 0 {
|
||||
q = q.In("type", query.Type)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
type SLoadbalancerBackendManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SLoadbalancerBackendgroupResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ type SLoadbalancerBackend struct {
|
||||
|
||||
//SManagedResourceBase
|
||||
//SCloudregionResourceBase
|
||||
SLoadbalancerBackendgroupResourceBase
|
||||
SLoadbalancerBackendgroupResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
// BackendGroupId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
BackendId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
@@ -97,6 +98,10 @@ func (man *SLoadbalancerBackendManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SLoadbalancerBackendgroupResourceBaseManager.ListItemFilter(ctx, q, userCred, query.LoadbalancerBackendGroupFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerBackendgroupResourceBaseManager.ListItemFilter")
|
||||
@@ -113,6 +118,23 @@ func (man *SLoadbalancerBackendManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(query.BackendType) > 0 {
|
||||
q = q.In("backend_type", query.BackendType)
|
||||
}
|
||||
if len(query.BackendRole) > 0 {
|
||||
q = q.In("backend_role", query.BackendRole)
|
||||
}
|
||||
if len(query.Address) > 0 {
|
||||
q = q.In("address", query.Address)
|
||||
}
|
||||
if len(query.SendProxy) > 0 {
|
||||
q = q.In("send_proxy", query.SendProxy)
|
||||
}
|
||||
if len(query.Ssl) > 0 {
|
||||
q = q.In("ssl", query.Ssl)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ type SCachedLoadbalancerCertificate struct {
|
||||
SManagedResourceBase // 云账号ID
|
||||
SCloudregionResourceBase // Region ID
|
||||
|
||||
SLoadbalancerCertificateResourceBase
|
||||
SLoadbalancerCertificateResourceBase `width:"128" charset:"ascii" nullable:"false" create:"required" index:"true" list:"user"`
|
||||
// CertificateId string `width:"128" charset:"ascii" nullable:"false" create:"required" index:"true" list:"user" json:"certificate_id"` // 本地证书ID
|
||||
}
|
||||
|
||||
|
||||
@@ -152,5 +152,5 @@ func (manager *SLoadbalancerCertificateResourceBaseManager) GetOrderBySubQuery(
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancerCertificateResourceBaseManager) GetOrderByFields(query api.LoadbalancerCertificateFilterListInput) []string {
|
||||
return []string{query.Certificate}
|
||||
return []string{query.OrderByCertificate}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import (
|
||||
type SLoadbalancerCertificateManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
}
|
||||
|
||||
var LoadbalancerCertificateManager *SLoadbalancerCertificateManager
|
||||
@@ -251,6 +252,10 @@ func (man *SLoadbalancerCertificateManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if query.Usable != nil && *query.Usable {
|
||||
region := query.Cloudregion
|
||||
@@ -284,6 +289,13 @@ func (man *SLoadbalancerCertificateManager) ListItemFilter(
|
||||
}
|
||||
}
|
||||
|
||||
if len(query.CommonName) > 0 {
|
||||
q = q.In("common_name", query.CommonName)
|
||||
}
|
||||
if len(query.SubjectAlternativeNames) > 0 {
|
||||
q = q.In("subject_alternative_names", query.SubjectAlternativeNames)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func init() {
|
||||
type SLoadbalancerCluster struct {
|
||||
db.SStandaloneResourceBase
|
||||
SZoneResourceBase
|
||||
SWireResourceBase
|
||||
SWireResourceBase `width:"36" charset:"ascii" nullable:"true" list:"admin" create:"optional" update:"admin"`
|
||||
//WireId string `width:"36" charset:"ascii" nullable:"true" list:"admin" create:"optional" update:"admin"`
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
type SLoadbalancerListenerRuleManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SLoadbalancerListenerResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ type SLoadbalancerListenerRule struct {
|
||||
db.SVirtualResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SLoadbalancerListenerResourceBase
|
||||
SLoadbalancerListenerResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
// 默认转发策略,目前只有aws用到其它云都是false
|
||||
IsDefault bool `default:"false" nullable:"true" list:"user" create:"optional"`
|
||||
@@ -395,6 +396,10 @@ func (man *SLoadbalancerListenerRuleManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SLoadbalancerListenerResourceBaseManager.ListItemFilter(ctx, q, userCred, query.LoadbalancerListenerFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerListenerResourceBaseManager.ListItemFilter")
|
||||
@@ -409,6 +414,21 @@ func (man *SLoadbalancerListenerRuleManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if query.IsDefault != nil {
|
||||
if *query.IsDefault {
|
||||
q = q.IsTrue("is_default")
|
||||
} else {
|
||||
q = q.IsFalse("is_default")
|
||||
}
|
||||
}
|
||||
if len(query.Domain) > 0 {
|
||||
q = q.In("domain", query.Domain)
|
||||
}
|
||||
if len(query.Path) > 0 {
|
||||
q = q.In("path", query.Path)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
type SLoadbalancerListenerManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SLoadbalancerResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ type SLoadbalancerListener struct {
|
||||
db.SVirtualResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SLoadbalancerResourceBase
|
||||
SLoadbalancerResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
//LoadbalancerId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
ListenerType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
@@ -216,6 +217,10 @@ func (man *SLoadbalancerListenerManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SLoadbalancerResourceBaseManager.ListItemFilter(ctx, q, userCred, query.LoadbalancerFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerResourceBaseManager.ListItemFilter")
|
||||
@@ -233,6 +238,26 @@ func (man *SLoadbalancerListenerManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(query.ListenerType) > 0 {
|
||||
q = q.In("listener_type", query.ListenerType)
|
||||
}
|
||||
if len(query.ListenerPort) > 0 {
|
||||
q = q.In("listener_port", query.ListenerPort)
|
||||
}
|
||||
if len(query.Scheduler) > 0 {
|
||||
q = q.In("scheduler", query.Scheduler)
|
||||
}
|
||||
if len(query.SendProxy) > 0 {
|
||||
q = q.In("send_proxy", query.SendProxy)
|
||||
}
|
||||
if len(query.AclStatus) > 0 {
|
||||
q = q.In("acl_status", query.AclStatus)
|
||||
}
|
||||
if len(query.AclType) > 0 {
|
||||
q = q.In("acl_type", query.AclType)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/util/regutils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
@@ -34,6 +36,8 @@ import (
|
||||
|
||||
type SLoadbalancernetworkManager struct {
|
||||
db.SVirtualJointResourceBaseManager
|
||||
SLoadbalancerResourceBaseManager
|
||||
SNetworkResourceBaseManager
|
||||
}
|
||||
|
||||
var LoadbalancernetworkManager *SLoadbalancernetworkManager
|
||||
@@ -293,3 +297,74 @@ func totalLBNicCount(
|
||||
q = CloudProviderFilter(q, lbs.Field("manager_id"), providers, brands, cloudEnv)
|
||||
return q.CountWithError()
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancernetworkManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.LoadbalancernetworkListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SVirtualJointResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VirtualJointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualJointResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SLoadbalancerResourceBaseManager.ListItemFilter(ctx, q, userCred, query.LoadbalancerFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = manager.SNetworkResourceBaseManager.ListItemFilter(ctx, q, userCred, query.NetworkFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNetworkResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.IpAddr) > 0 {
|
||||
q = q.In("ip_addr", query.IpAddr)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancernetworkManager) OrderByExtraFields(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.LoadbalancernetworkListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SVirtualJointResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.VirtualJointResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualJointResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SLoadbalancerResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.LoadbalancerFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SLoadbalancerResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
q, err = manager.SNetworkResourceBaseManager.OrderByExtraFields(ctx, q, userCred, query.NetworkFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNetworkResourceBaseManager.OrderByExtraFields")
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancernetworkManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
var err error
|
||||
|
||||
q, err = manager.SVirtualJointResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
q, err = manager.SLoadbalancerResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
q, err = manager.SNetworkResourceBaseManager.QueryDistinctExtraField(q, field)
|
||||
if err == nil {
|
||||
return q, nil
|
||||
}
|
||||
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
@@ -42,7 +42,10 @@ import (
|
||||
|
||||
type SLoadbalancerManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
|
||||
db.SVirtualResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
|
||||
SVpcResourceBaseManager
|
||||
SZoneResourceBaseManager
|
||||
SNetworkResourceBaseManager
|
||||
@@ -76,11 +79,11 @@ type SLoadbalancer struct {
|
||||
db.SVirtualResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
// LB must be in a VPC, vpc_id, manager_id, cloudregion_id
|
||||
SVpcResourceBase
|
||||
SVpcResourceBase `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
// zone_id
|
||||
SZoneResourceBase
|
||||
// optional network_id
|
||||
SNetworkResourceBase
|
||||
SNetworkResourceBase `width:"147" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
SLoadbalancerRateLimiter
|
||||
|
||||
@@ -126,6 +129,10 @@ func (man *SLoadbalancerManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVirtualResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SVpcResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VpcFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVpcResourceBaseManager.ListItemFilter")
|
||||
@@ -155,6 +162,22 @@ func (man *SLoadbalancerManager) ListItemFilter(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(query.Address) > 0 {
|
||||
q = q.In("address", query.Address)
|
||||
}
|
||||
if len(query.AddressType) > 0 {
|
||||
q = q.In("address_type", query.AddressType)
|
||||
}
|
||||
if len(query.NetworkType) > 0 {
|
||||
q = q.In("network_type", query.NetworkType)
|
||||
}
|
||||
if len(query.ChargeType) > 0 {
|
||||
q = q.In("charge_type", query.ChargeType)
|
||||
}
|
||||
if len(query.LoadbalancerSpec) > 0 {
|
||||
q = q.In("loadbalancer_spec", query.LoadbalancerSpec)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,19 @@ import (
|
||||
|
||||
type SManagedResourceBase struct {
|
||||
// 云订阅ID
|
||||
ManagerId string `width:"128" charset:"ascii" nullable:"true" list:"admin" create:"optional" json:"manager_id"`
|
||||
ManagerId string `width:"128" charset:"ascii" nullable:"true" list:"admin" create:"optional"`
|
||||
}
|
||||
|
||||
type SManagedResourceBaseManager struct{}
|
||||
type SManagedResourceBaseManager struct {
|
||||
managerIdFieldName string
|
||||
}
|
||||
|
||||
func (manager *SManagedResourceBaseManager) getManagerIdFileName() string {
|
||||
if len(manager.managerIdFieldName) > 0 {
|
||||
return manager.managerIdFieldName
|
||||
}
|
||||
return "manager_id"
|
||||
}
|
||||
|
||||
func (self *SManagedResourceBase) GetCloudprovider() *SCloudprovider {
|
||||
if len(self.ManagerId) > 0 {
|
||||
@@ -207,7 +216,7 @@ func (manager *SManagedResourceBaseManager) ListItemFilter(
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.ManagedResourceListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
return managedResourceFilterByAccount(q, query, "", nil)
|
||||
return _managedResourceFilterByAccount(manager.getManagerIdFileName(), q, query, "", nil)
|
||||
}
|
||||
|
||||
func (manager *SManagedResourceBaseManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) {
|
||||
@@ -215,20 +224,20 @@ func (manager *SManagedResourceBaseManager) QueryDistinctExtraField(q *sqlchemy.
|
||||
case "manager":
|
||||
managerQuery := CloudproviderManager.Query("name", "id").SubQuery()
|
||||
q.AppendField(managerQuery.Field("name", field)).Distinct()
|
||||
q = q.Join(managerQuery, sqlchemy.Equals(q.Field("manager_id"), managerQuery.Field("id")))
|
||||
q = q.Join(managerQuery, sqlchemy.Equals(q.Field(manager.getManagerIdFileName()), managerQuery.Field("id")))
|
||||
return q, nil
|
||||
case "account":
|
||||
accountQuery := CloudaccountManager.Query("name", "id").SubQuery()
|
||||
providers := CloudproviderManager.Query("id", "cloudaccount_id").SubQuery()
|
||||
q.AppendField(accountQuery.Field("name", field)).Distinct()
|
||||
q = q.Join(providers, sqlchemy.Equals(q.Field("manager_id"), providers.Field("id")))
|
||||
q = q.Join(providers, sqlchemy.Equals(q.Field(manager.getManagerIdFileName()), providers.Field("id")))
|
||||
q = q.Join(accountQuery, sqlchemy.Equals(providers.Field("cloudaccount_id"), accountQuery.Field("id")))
|
||||
return q, nil
|
||||
case "provider", "brand":
|
||||
accountQuery := CloudaccountManager.Query(field, "id").Distinct().SubQuery()
|
||||
providers := CloudproviderManager.Query("id", "cloudaccount_id").SubQuery()
|
||||
q.AppendField(accountQuery.Field(field)).Distinct()
|
||||
q = q.Join(providers, sqlchemy.Equals(q.Field("manager_id"), providers.Field("id")))
|
||||
q = q.Join(providers, sqlchemy.Equals(q.Field(manager.getManagerIdFileName()), providers.Field("id")))
|
||||
q = q.Join(accountQuery, sqlchemy.Equals(providers.Field("cloudaccount_id"), accountQuery.Field("id")))
|
||||
return q, nil
|
||||
}
|
||||
@@ -269,7 +278,7 @@ func (manager *SManagedResourceBaseManager) GetOrderBySubQuery(
|
||||
accounts,
|
||||
sqlchemy.Equals(providers.Field("cloudaccount_id"), accounts.Field("id")),
|
||||
).SubQuery()
|
||||
q = q.LeftJoin(subq, sqlchemy.Equals(q.Field("manager_id"), subq.Field("id")))
|
||||
q = q.LeftJoin(subq, sqlchemy.Equals(q.Field(manager.getManagerIdFileName()), subq.Field("id")))
|
||||
fields = []sqlchemy.IQueryField{
|
||||
subq.Field("name"),
|
||||
subq.Field("account"),
|
||||
@@ -284,7 +293,7 @@ func (manager *SManagedResourceBaseManager) GetOrderByFields(query api.ManagedRe
|
||||
return []string{query.OrderByManager, query.OrderByAccount, query.OrderByProvider, query.OrderByBrand}
|
||||
}
|
||||
|
||||
func _managedResourceFilterByDomain(q *sqlchemy.SQuery, query apis.DomainizedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) (*sqlchemy.SQuery, error) {
|
||||
func _managedResourceFilterByDomain(managerIdFieldName string, q *sqlchemy.SQuery, query apis.DomainizedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) (*sqlchemy.SQuery, error) {
|
||||
domainStr := query.ProjectDomain
|
||||
if len(domainStr) > 0 {
|
||||
domain, err := db.TenantCacheManager.FetchDomainByIdOrName(context.Background(), domainStr)
|
||||
@@ -311,12 +320,12 @@ func _managedResourceFilterByDomain(q *sqlchemy.SQuery, query apis.DomainizedRes
|
||||
))
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.IsNullOrEmpty(q.Field("manager_id")),
|
||||
sqlchemy.In(q.Field("manager_id"), subq.SubQuery()),
|
||||
sqlchemy.IsNullOrEmpty(q.Field(managerIdFieldName)),
|
||||
sqlchemy.In(q.Field(managerIdFieldName), subq.SubQuery()),
|
||||
))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.OR(sqlchemy.In(sq.Field("manager_id"), subq.SubQuery()), sqlchemy.IsNullOrEmpty(sq.Field("manager_id"))))
|
||||
sq = sq.Filter(sqlchemy.OR(sqlchemy.In(sq.Field(managerIdFieldName), subq.SubQuery()), sqlchemy.IsNullOrEmpty(sq.Field(managerIdFieldName))))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
}
|
||||
@@ -336,7 +345,7 @@ func splitProviders(providers []string) (bool, []string) {
|
||||
return oneCloud, others
|
||||
}
|
||||
|
||||
func filterByProviderStrs(q *sqlchemy.SQuery, filterField string, subqFunc func() *sqlchemy.SQuery, fieldName string, providerStrs []string) *sqlchemy.SQuery {
|
||||
func _filterByProviderStrs(managerIdFieldName string, q *sqlchemy.SQuery, filterField string, subqFunc func() *sqlchemy.SQuery, fieldName string, providerStrs []string) *sqlchemy.SQuery {
|
||||
oneCloud, providers := splitProviders(providerStrs)
|
||||
sq := q
|
||||
if len(filterField) > 0 {
|
||||
@@ -351,10 +360,10 @@ func filterByProviderStrs(q *sqlchemy.SQuery, filterField string, subqFunc func(
|
||||
account.Field("id"), providers.Field("cloudaccount_id"),
|
||||
))
|
||||
subq = subq.Filter(sqlchemy.In(account.Field(fieldName), providerStrs))
|
||||
filters = append(filters, sqlchemy.In(sq.Field("manager_id"), subq.SubQuery()))
|
||||
filters = append(filters, sqlchemy.In(sq.Field(managerIdFieldName), subq.SubQuery()))
|
||||
}
|
||||
if oneCloud {
|
||||
filters = append(filters, sqlchemy.IsNullOrEmpty(sq.Field("manager_id")))
|
||||
filters = append(filters, sqlchemy.IsNullOrEmpty(sq.Field(managerIdFieldName)))
|
||||
}
|
||||
if len(filters) == 1 {
|
||||
sq = sq.Filter(filters[0])
|
||||
@@ -370,6 +379,10 @@ func filterByProviderStrs(q *sqlchemy.SQuery, filterField string, subqFunc func(
|
||||
}
|
||||
|
||||
func managedResourceFilterByAccount(q *sqlchemy.SQuery, input api.ManagedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) (*sqlchemy.SQuery, error) {
|
||||
return _managedResourceFilterByAccount("manager_id", q, input, filterField, subqFunc)
|
||||
}
|
||||
|
||||
func _managedResourceFilterByAccount(managerIdFieldName string, q *sqlchemy.SQuery, input api.ManagedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) (*sqlchemy.SQuery, error) {
|
||||
cloudproviderStr := input.Cloudprovider
|
||||
if len(cloudproviderStr) > 0 {
|
||||
provider, err := CloudproviderManager.FetchByIdOrName(nil, cloudproviderStr)
|
||||
@@ -380,10 +393,10 @@ func managedResourceFilterByAccount(q *sqlchemy.SQuery, input api.ManagedResourc
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.Equals(q.Field("manager_id"), provider.GetId()))
|
||||
q = q.Filter(sqlchemy.Equals(q.Field(managerIdFieldName), provider.GetId()))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.Equals(sq.Field("manager_id"), provider.GetId()))
|
||||
sq = sq.Filter(sqlchemy.Equals(sq.Field(managerIdFieldName), provider.GetId()))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
}
|
||||
@@ -399,25 +412,25 @@ func managedResourceFilterByAccount(q *sqlchemy.SQuery, input api.ManagedResourc
|
||||
}
|
||||
subq := CloudproviderManager.Query("id").Equals("cloudaccount_id", account.GetId()).SubQuery()
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.In(q.Field("manager_id"), subq))
|
||||
q = q.Filter(sqlchemy.In(q.Field(managerIdFieldName), subq))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field("manager_id"), subq))
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field(managerIdFieldName), subq))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
}
|
||||
|
||||
if len(input.Providers) > 0 {
|
||||
q = filterByProviderStrs(q, filterField, subqFunc, "provider", input.Providers)
|
||||
q = _filterByProviderStrs(managerIdFieldName, q, filterField, subqFunc, "provider", input.Providers)
|
||||
}
|
||||
|
||||
if len(input.Brands) > 0 {
|
||||
q = filterByProviderStrs(q, filterField, subqFunc, "brand", input.Brands)
|
||||
q = _filterByProviderStrs(managerIdFieldName, q, filterField, subqFunc, "brand", input.Brands)
|
||||
}
|
||||
|
||||
q = filterByCloudType(q, input, filterField, subqFunc)
|
||||
q = _filterByCloudType(managerIdFieldName, q, input, filterField, subqFunc)
|
||||
|
||||
q, err := _managedResourceFilterByDomain(q, input.DomainizedResourceListInput, filterField, subqFunc)
|
||||
q, err := _managedResourceFilterByDomain(managerIdFieldName, q, input.DomainizedResourceListInput, filterField, subqFunc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "managedResourceFilterByDomain")
|
||||
}
|
||||
@@ -493,40 +506,40 @@ func managedResourceFilterByRegion(q *sqlchemy.SQuery, query api.RegionalFilterL
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func filterByCloudType(q *sqlchemy.SQuery, input api.ManagedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
func _filterByCloudType(managerIdFieldName string, q *sqlchemy.SQuery, input api.ManagedResourceListInput, filterField string, subqFunc func() *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
cloudEnvStr := input.CloudEnv
|
||||
|
||||
switch cloudEnvStr {
|
||||
case api.CLOUD_ENV_PUBLIC_CLOUD:
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.In(q.Field("manager_id"), CloudproviderManager.GetPublicProviderIdsQuery()))
|
||||
q = q.Filter(sqlchemy.In(q.Field(managerIdFieldName), CloudproviderManager.GetPublicProviderIdsQuery()))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field("manager_id"), CloudproviderManager.GetPublicProviderIdsQuery()))
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field(managerIdFieldName), CloudproviderManager.GetPublicProviderIdsQuery()))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
case api.CLOUD_ENV_PRIVATE_CLOUD:
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.In(q.Field("manager_id"), CloudproviderManager.GetPrivateProviderIdsQuery()))
|
||||
q = q.Filter(sqlchemy.In(q.Field(managerIdFieldName), CloudproviderManager.GetPrivateProviderIdsQuery()))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field("manager_id"), CloudproviderManager.GetPrivateProviderIdsQuery()))
|
||||
sq = sq.Filter(sqlchemy.In(sq.Field(managerIdFieldName), CloudproviderManager.GetPrivateProviderIdsQuery()))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
case api.CLOUD_ENV_ON_PREMISE:
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(
|
||||
sqlchemy.OR(
|
||||
sqlchemy.In(q.Field("manager_id"), CloudproviderManager.GetOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(q.Field("manager_id")),
|
||||
sqlchemy.In(q.Field(managerIdFieldName), CloudproviderManager.GetOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(q.Field(managerIdFieldName)),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(
|
||||
sqlchemy.OR(
|
||||
sqlchemy.In(sq.Field("manager_id"), CloudproviderManager.GetOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(sq.Field("manager_id")),
|
||||
sqlchemy.In(sq.Field(managerIdFieldName), CloudproviderManager.GetOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(sq.Field(managerIdFieldName)),
|
||||
),
|
||||
)
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
@@ -535,16 +548,16 @@ func filterByCloudType(q *sqlchemy.SQuery, input api.ManagedResourceListInput, f
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(
|
||||
sqlchemy.OR(
|
||||
sqlchemy.In(q.Field("manager_id"), CloudproviderManager.GetPrivateOrOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(q.Field("manager_id")),
|
||||
sqlchemy.In(q.Field(managerIdFieldName), CloudproviderManager.GetPrivateOrOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(q.Field(managerIdFieldName)),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(
|
||||
sqlchemy.OR(
|
||||
sqlchemy.In(sq.Field("manager_id"), CloudproviderManager.GetPrivateOrOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(sq.Field("manager_id")),
|
||||
sqlchemy.In(sq.Field(managerIdFieldName), CloudproviderManager.GetPrivateOrOnPremiseProviderIdsQuery()),
|
||||
sqlchemy.IsNullOrEmpty(sq.Field(managerIdFieldName)),
|
||||
),
|
||||
)
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
@@ -553,10 +566,10 @@ func filterByCloudType(q *sqlchemy.SQuery, input api.ManagedResourceListInput, f
|
||||
|
||||
if input.IsManaged {
|
||||
if len(filterField) == 0 {
|
||||
q = q.Filter(sqlchemy.IsNotEmpty(q.Field("manager_id")))
|
||||
q = q.Filter(sqlchemy.IsNotEmpty(q.Field(managerIdFieldName)))
|
||||
} else {
|
||||
sq := subqFunc()
|
||||
sq = sq.Filter(sqlchemy.IsNotEmpty(sq.Field("manager_id")))
|
||||
sq = sq.Filter(sqlchemy.IsNotEmpty(sq.Field(managerIdFieldName)))
|
||||
q = q.Filter(sqlchemy.In(q.Field(filterField), sq.SubQuery()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,23 @@ func (man *SNatDEntryManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNatEntryManager.ListItemFilter")
|
||||
}
|
||||
|
||||
if len(query.ExternalIP) > 0 {
|
||||
q = q.In("external_ip", query.ExternalIP)
|
||||
}
|
||||
if len(query.ExternalPort) > 0 {
|
||||
q = q.In("external_port", query.ExternalPort)
|
||||
}
|
||||
if len(query.InternalIP) > 0 {
|
||||
q = q.In("internal_ip", query.InternalIP)
|
||||
}
|
||||
if len(query.InternalPort) > 0 {
|
||||
q = q.In("internal_port", query.InternalPort)
|
||||
}
|
||||
if len(query.IpProtocol) > 0 {
|
||||
q = q.In("ip_protocol", query.IpProtocol)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
|
||||
type SNatGatewayManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SVpcResourceBaseManager
|
||||
// SManagedResourceBaseManager
|
||||
}
|
||||
@@ -72,11 +73,20 @@ func (manager *SNatGatewayManager) GetContextManagers() [][]db.IModelManager {
|
||||
}
|
||||
|
||||
// NAT网关列表
|
||||
func (man *SNatGatewayManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query api.NatGetewayListInput) (*sqlchemy.SQuery, error) {
|
||||
func (man *SNatGatewayManager) ListItemFilter(
|
||||
ctx context.Context,
|
||||
q *sqlchemy.SQuery,
|
||||
userCred mcclient.TokenCredential,
|
||||
query api.NatGetewayListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
q, err := man.SStatusStandaloneResourceBaseManager.ListItemFilter(ctx, q, userCred, query.StatusStandaloneResourceListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStatusDomainLevelResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SVpcResourceBaseManager.ListItemFilter(ctx, q, userCred, query.VpcFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SVpcResourceBaseManager.ListItemFilter")
|
||||
@@ -532,6 +542,7 @@ type INatHelper interface {
|
||||
|
||||
type SNatEntryManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
db.SExternalizedResourceBaseManager
|
||||
SNatgatewayResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -545,7 +556,7 @@ type SNatEntry struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SNatgatewayResourceBase
|
||||
SNatgatewayResourceBase `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
// NatgatewayId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"`
|
||||
}
|
||||
|
||||
@@ -566,7 +577,10 @@ func (man *SNatEntryManager) ListItemFilter(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
|
||||
q, err = man.SExternalizedResourceBaseManager.ListItemFilter(ctx, q, userCred, query.ExternalizedResourceBaseListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
|
||||
}
|
||||
q, err = man.SNatgatewayResourceBaseManager.ListItemFilter(ctx, q, userCred, query.NatGatewayFilterListInput)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SNatgatewayResourceBaseManager.ListItemFilter")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user