fix(region): vm filter by os dist (#18777)

This commit is contained in:
屈轩
2023-11-24 20:06:01 +08:00
committed by GitHub
parent e343ae3b5e
commit 4d7cbb93b2
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -73,6 +73,8 @@ type ServerListInput struct {
// 列出操作系统为指定值的主机
// enum: linux,windows,vmware
OsType []string `json:"os_type"`
// 操作系统发行版
OsDist []string `json:"os_dist"`
// 对列表结果按照磁盘大小进行排序
// enum: asc,desc
+4
View File
@@ -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)
}