Files
cloudpods/pkg/util/openstack/shell/snapshot.go
2019-01-02 17:38:59 +08:00

35 lines
844 B
Go

package shell
import (
"yunion.io/x/onecloud/pkg/util/openstack"
"yunion.io/x/onecloud/pkg/util/shellutils"
)
func init() {
type SnapshotListOptions struct {
DiskId string `help:"Disk ID for filter snapshot"`
}
shellutils.R(&SnapshotListOptions{}, "snapshot-list", "List snapshots", func(cli *openstack.SRegion, args *SnapshotListOptions) error {
snapshots, err := cli.GetSnapshots(args.DiskId)
if err != nil {
return err
}
printList(snapshots, 0, 0, 0, []string{})
return nil
})
type SnapshotShowOptions struct {
ID string `help:"ID of snapshot"`
}
shellutils.R(&SnapshotShowOptions{}, "snapshot-show", "Show snapshot", func(cli *openstack.SRegion, args *SnapshotShowOptions) error {
snapshot, err := cli.GetISnapshotById(args.ID)
if err != nil {
return err
}
printObject(snapshot)
return nil
})
}