mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(region): instance snapshot with_memory filter
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
@@ -24,13 +26,21 @@ func init() {
|
||||
type InstanceSnapshotsListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
GuestId string `help:"guest id" json:"guest_id"`
|
||||
GuestId string `help:"guest id" json:"guest_id"`
|
||||
HasMemory bool `help:"contains memory snapshot" json:"-"`
|
||||
NotHasMemory bool `help:"not contains memory snapshot" json:"-"`
|
||||
}
|
||||
R(&InstanceSnapshotsListOptions{}, "instance-snapshot-list", "Show instance snapshots", func(s *mcclient.ClientSession, args *InstanceSnapshotsListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if args.HasMemory {
|
||||
params.Set("with_memory", jsonutils.NewBool(true))
|
||||
}
|
||||
if args.NotHasMemory {
|
||||
params.Set("with_memory", jsonutils.NewBool(false))
|
||||
}
|
||||
result, err := modules.InstanceSnapshots.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -67,4 +67,7 @@ type InstanceSnapshotListInput struct {
|
||||
|
||||
// 操作系统类型
|
||||
OsType []string `json:"os_type"`
|
||||
|
||||
// 包含内存快照
|
||||
WithMemory *bool `json:"with_memory"`
|
||||
}
|
||||
|
||||
@@ -143,6 +143,14 @@ func (manager *SInstanceSnapshotManager) ListItemFilter(
|
||||
q = q.In("os_type", query.OsType)
|
||||
}
|
||||
|
||||
if query.WithMemory != nil {
|
||||
if *query.WithMemory {
|
||||
q = q.IsTrue("with_memory")
|
||||
} else {
|
||||
q = q.IsFalse("with_memory")
|
||||
}
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user