From 06381645722b76189ea8eff679c0e157fc210c58 Mon Sep 17 00:00:00 2001 From: Florent <florent.gluck@hesge.ch> Date: Fri, 27 Dec 2024 00:00:38 +0100 Subject: [PATCH] liblcient: completed vmStartAttach --- src/client/cmdVM/vmStartAttach.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/client/cmdVM/vmStartAttach.go b/src/client/cmdVM/vmStartAttach.go index d3ae95b..5649b90 100644 --- a/src/client/cmdVM/vmStartAttach.go +++ b/src/client/cmdVM/vmStartAttach.go @@ -3,7 +3,6 @@ package cmdVM import ( "nexus-client/exec" u "nexus-client/utils" - g "nexus-libclient/globals" libclient "nexus-libclient/vm" ) @@ -28,9 +27,6 @@ func (cmd *StartAttach) PrintUsage() { } func (cmd *StartAttach) Run(args []string) int { - client := g.GetInstance().Client - host := g.GetInstance().Host - argc := len(args) if argc < 1 { cmd.PrintUsage() @@ -56,20 +52,13 @@ func (cmd *StartAttach) Run(args []string) int { statusCode := 0 for _, vm := range vms { - uuid := vm.ID.String() - resp, err := client.R().Put(host + "/vms/" + uuid + "/start") + err := libclient.VMStart(vm.ID.String()) if err != nil { - u.PrintlnErr("Failed starting VM \"" + vm.Name + "\": " + err.Error()) + u.PrintlnErr(err) statusCode = 1 } else { - if resp.IsSuccess() { - u.Println("Started VM \"" + vm.Name + "\"") - } else { - u.PrintlnErr("Failed starting VM \"" + vm.Name + "\": " + resp.Status() + ": " + resp.String()) - statusCode = 1 - } + u.Println("Started VM \"" + vm.Name + "\"") } - } // at this point, the returned filtered credentials only works for VMs that started successfully -- GitLab