Skip to content

Commit

Permalink
Add qemu specific guest commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyblargon committed Sep 13, 2022
1 parent a12c5c5 commit ee8e24d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/command/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
_ "github.com/Telmate/proxmox-api-go/cli/command/get"
_ "github.com/Telmate/proxmox-api-go/cli/command/get/id"
_ "github.com/Telmate/proxmox-api-go/cli/command/guest"
_ "github.com/Telmate/proxmox-api-go/cli/command/guest/qemu"
_ "github.com/Telmate/proxmox-api-go/cli/command/list"
_ "github.com/Telmate/proxmox-api-go/cli/command/set"
_ "github.com/Telmate/proxmox-api-go/cli/command/update"
Expand Down
25 changes: 25 additions & 0 deletions cli/command/guest/qemu/guest-qemu-reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package qemu

import (
"github.com/Telmate/proxmox-api-go/cli"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/spf13/cobra"
)

var qemu_resetCmd = &cobra.Command{
Use: "reset GUESTID",
Short: "Resets the speciefid guest",
RunE: func(cmd *cobra.Command, args []string) (err error) {
vmr := proxmox.NewVmRef(cli.ValidateIntIDset(args, "GuestID"))
c := cli.NewClient()
_, err = c.StartVm(vmr)
if err == nil {
cli.PrintGuestStatus(qemuCmd.OutOrStdout(), vmr.VmId(), "reset")
}
return
},
}

func init() {
qemuCmd.AddCommand(qemu_resetCmd)
}
25 changes: 25 additions & 0 deletions cli/command/guest/qemu/guest-qemu-resume.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package qemu

import (
"github.com/Telmate/proxmox-api-go/cli"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/spf13/cobra"
)

var qemu_resumeCmd = &cobra.Command{
Use: "resume GUESTID",
Short: "Resumes the speciefid guest",
RunE: func(cmd *cobra.Command, args []string) (err error) {
vmr := proxmox.NewVmRef(cli.ValidateIntIDset(args, "GuestID"))
c := cli.NewClient()
_, err = c.ResumeVm(vmr)
if err == nil {
cli.PrintGuestStatus(qemuCmd.OutOrStdout(), vmr.VmId(), "resumed")
}
return
},
}

func init() {
qemuCmd.AddCommand(qemu_resumeCmd)
}
15 changes: 15 additions & 0 deletions cli/command/guest/qemu/guest-qemu.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package qemu

import (
"github.com/Telmate/proxmox-api-go/cli/command/guest"
"github.com/spf13/cobra"
)

var qemuCmd = &cobra.Command{
Use: "qemu",
Short: "Commands to interact with the qemu guests on Proxmox",
}

func init() {
guest.GuestCmd.AddCommand(qemuCmd)
}

0 comments on commit ee8e24d

Please sign in to comment.