mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #18074 from wanyaoqi/automated-cherry-pick-of-#18073-upstream-release-3.11
Automated cherry pick of #18073: feat(region): host list filter by host storage type
This commit is contained in:
@@ -101,8 +101,10 @@ type HostListInput struct {
|
||||
CpuCount []int `json:"cpu_count"`
|
||||
// 内存大小,单位Mb
|
||||
MemSize []int `json:"mem_size"`
|
||||
// 存储类型
|
||||
// 存储类型(磁盘类型,sdd, rotate, hybrid)
|
||||
StorageType []string `json:"storage_type"`
|
||||
// 宿主机绑定存储类型
|
||||
HostStorageType []string `json:"host_storage_type"`
|
||||
// IPMI地址
|
||||
IpmiIp []string `json:"ipmi_ip"`
|
||||
// 宿主机状态
|
||||
|
||||
@@ -332,6 +332,15 @@ func (manager *SHostManager) ListItemFilter(
|
||||
}
|
||||
}
|
||||
|
||||
hostStorageType := query.HostStorageType
|
||||
if len(hostStorageType) > 0 {
|
||||
hoststorages := HoststorageManager.Query()
|
||||
storages := StorageManager.Query().In("storage_type", hostStorageType).SubQuery()
|
||||
hq := hoststorages.Join(storages, sqlchemy.Equals(hoststorages.Field("storage_id"), storages.Field("id"))).SubQuery()
|
||||
scopeQuery := hq.Query(hq.Field("host_id")).SubQuery()
|
||||
q = q.In("id", scopeQuery)
|
||||
}
|
||||
|
||||
hypervisorStr := query.Hypervisor
|
||||
if len(hypervisorStr) > 0 {
|
||||
hostType, ok := api.HYPERVISOR_HOSTTYPE[hypervisorStr]
|
||||
|
||||
@@ -21,20 +21,21 @@ import (
|
||||
)
|
||||
|
||||
type HostListOptions struct {
|
||||
Schedtag string `help:"List hosts in schedtag"`
|
||||
Zone string `help:"List hosts in zone"`
|
||||
Region string `help:"List hosts in region"`
|
||||
Wire string `help:"List hosts in wire"`
|
||||
Image string `help:"List hosts cached images" json:"cachedimage"`
|
||||
Storage string `help:"List hosts attached to storages"`
|
||||
Baremetal string `help:"List hosts that is managed by baremetal system" choices:"true|false"`
|
||||
Empty bool `help:"show empty host" json:"-"`
|
||||
Occupied bool `help:"show occupid host" json:"-"`
|
||||
Enabled bool `help:"Show enabled host only" json:"-"`
|
||||
Disabled bool `help:"Show disabled host only" json:"-"`
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv|aliyun|azure|qcloud|aws|huawei|ucloud|google|ctyun"`
|
||||
AnyMac string `help:"Mac matches one of the host's interface"`
|
||||
AnyIp []string `help:"IP matches one of the host's interface"`
|
||||
Schedtag string `help:"List hosts in schedtag"`
|
||||
Zone string `help:"List hosts in zone"`
|
||||
Region string `help:"List hosts in region"`
|
||||
Wire string `help:"List hosts in wire"`
|
||||
Image string `help:"List hosts cached images" json:"cachedimage"`
|
||||
Storage string `help:"List hosts attached to storages"`
|
||||
Baremetal string `help:"List hosts that is managed by baremetal system" choices:"true|false"`
|
||||
Empty bool `help:"show empty host" json:"-"`
|
||||
Occupied bool `help:"show occupid host" json:"-"`
|
||||
Enabled bool `help:"Show enabled host only" json:"-"`
|
||||
Disabled bool `help:"Show disabled host only" json:"-"`
|
||||
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv|aliyun|azure|qcloud|aws|huawei|ucloud|google|ctyun"`
|
||||
AnyMac string `help:"Mac matches one of the host's interface"`
|
||||
AnyIp []string `help:"IP matches one of the host's interface"`
|
||||
HostStorageType []string `help:"List host in host_storage_type"`
|
||||
|
||||
IsBaremetal *bool `help:"filter host list by is_baremetal=true|false"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user