mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): vm filter by os dist (#18777)
This commit is contained in:
@@ -73,6 +73,8 @@ type ServerListInput struct {
|
||||
// 列出操作系统为指定值的主机
|
||||
// enum: linux,windows,vmware
|
||||
OsType []string `json:"os_type"`
|
||||
// 操作系统发行版
|
||||
OsDist []string `json:"os_dist"`
|
||||
|
||||
// 对列表结果按照磁盘大小进行排序
|
||||
// enum: asc,desc
|
||||
|
||||
@@ -655,6 +655,10 @@ func (manager *SGuestManager) ListItemFilter(
|
||||
if len(query.OsType) > 0 {
|
||||
q = q.In("os_type", query.OsType)
|
||||
}
|
||||
if len(query.OsDist) > 0 {
|
||||
metaSQ := db.Metadata.Query().Equals("key", "os_distribution").In("value", query.OsDist).SubQuery()
|
||||
q = q.Join(metaSQ, sqlchemy.Equals(q.Field("id"), metaSQ.Field("obj_id")))
|
||||
}
|
||||
if len(query.VcpuCount) > 0 {
|
||||
q = q.In("vcpu_count", query.VcpuCount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user