mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): filter unused snapshot (#21563)
This commit is contained in:
@@ -32,6 +32,7 @@ func init() {
|
||||
Share *bool `help:"Show shared snapshots"`
|
||||
DiskType string `help:"Filter by disk type" choices:"sys|data"`
|
||||
Server string `help:"Filter by server" json:"server_id"`
|
||||
Unused bool
|
||||
|
||||
OrderByGuest string
|
||||
OrderByDiskName string
|
||||
|
||||
@@ -74,6 +74,9 @@ type SnapshotListInput struct {
|
||||
// list server snapshots
|
||||
ServerId string `json:"server_id"`
|
||||
|
||||
// 未关联任何磁盘
|
||||
Unused bool `json:"unused"`
|
||||
|
||||
// 按虚拟机名称排序
|
||||
// pattern:asc|desc
|
||||
OrderByGuest string `json:"order_by_guest"`
|
||||
|
||||
@@ -205,6 +205,11 @@ func (manager *SSnapshotManager) ListItemFilter(
|
||||
q = q.In("disk_id", gdq)
|
||||
}
|
||||
|
||||
if query.Unused {
|
||||
sq := DiskManager.Query("id").Distinct().SubQuery()
|
||||
q = q.NotIn("disk_id", sq)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user