feat(region,host): server-monitor support qmp

server-montior add qmp option, default is hmp.

usage:
    climc server-monitor --qmp <ID> <COMMAND>

Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
wanyaoqi
2022-07-14 16:17:15 +08:00
parent 0ec0a182c0
commit e26ea2ebb3
9 changed files with 57 additions and 30 deletions

View File

@@ -104,6 +104,7 @@ func init() {
cmd.Perform("cpuset-remove", &options.ServerIdOptions{})
cmd.Perform("calculate-record-checksum", &options.ServerIdOptions{})
cmd.Perform("set-class-metadata", &baseoptions.ResourceMetadataOptions{})
cmd.Perform("monitor", &options.ServerMonitorOptions{})
cmd.Get("vnc", new(options.ServerIdOptions))
cmd.Get("desc", new(options.ServerIdOptions))
@@ -305,23 +306,6 @@ func init() {
return nil
})
R(&options.ServerMonitorOptions{}, "server-monitor", "Send commands to qemu monitor", func(s *mcclient.ClientSession, opts *options.ServerMonitorOptions) error {
params, err := baseoptions.StructToParams(opts)
if err != nil {
return err
}
ret, err := modules.Servers.PerformAction(s, opts.ID, "monitor", params)
if err != nil {
return err
}
result, err := ret.GetString("results")
if err != nil {
return err
}
fmt.Println(result)
return nil
})
type ServerDiskSnapshotOptions struct {
SERVER string `help:"server ID or Name"`
DISK string `help:"create snapshot disk id"`