MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / runGuestsShell

Function runGuestsShell

internal/cli/guests.go:646–684  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

644}
645
646func runGuestsShell(cmd *cobra.Command, args []string) error {
647 vmid, err := parseVMID(args[0])
648 if err != nil {
649 return printError(err)
650 }
651
652 session, initErr := initCLISession(cmd)
653 if initErr != nil {
654 return printError(initErr)
655 }
656
657 if session == nil {
658 return nil
659 }
660
661 ctx := context.Background()
662
663 vm, err := session.findVM(ctx, vmid)
664 if err != nil {
665 return printError(err)
666 }
667
668 if vm.Status != api.VMStatusRunning {
669 return printError(fmt.Errorf("guest %d is not running (status: %s)", vmid, vm.Status))
670 }
671
672 if vm.Template {
673 return printError(fmt.Errorf("guest %d is a template; shell is not supported", vmid))
674 }
675
676 switch vm.Type {
677 case api.VMTypeLXC:
678 return runLXCShell(cmd, session, vm)
679 case api.VMTypeQemu:
680 return runQEMUShell(cmd, session, vm)
681 default:
682 return printError(fmt.Errorf("unsupported guest type %q for guest %d", vm.Type, vmid))
683 }
684}
685
686func runLXCShell(_ *cobra.Command, session *cliSession, vm *api.VM) error {
687 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

parseVMIDFunction · 0.85
printErrorFunction · 0.85
initCLISessionFunction · 0.85
runLXCShellFunction · 0.85
runQEMUShellFunction · 0.85
findVMMethod · 0.80

Tested by

no test coverage detected