Skip to content
Snippets Groups Projects
Commit c32b4f04 authored by Florent Gluck's avatar Florent Gluck
Browse files

WIP

parent fe755bfa
Branches
No related tags found
No related merge requests found
Showing
with 46 additions and 48 deletions
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/exec"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -46,7 +46,7 @@ func (cmd *AttachAsyncSingle) Run(args []string) int {
vmID := args[0]
creds, err := libclient.VMAttach(vmID)
creds, err := nc.VMAttach(vmID)
if err != nil {
u.PrintlnErr("Failed retrieving VM credentials for VM \"" + vmID + "\": " + err.Error())
return 1
......
......@@ -3,8 +3,7 @@ package cmdVM
import (
"net/url"
g "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/globals"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/exec"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -61,7 +60,7 @@ func (cmd *AttachFromPwd) Run(args []string) int {
pwd := args[0]
p := params.VMAttachCreds{Pwd: pwd}
creds, err := libclient.VMGetAnySpiceCreds(p)
creds, err := nc.VMGetAnySpiceCreds(p)
if err != nil {
u.PrintlnErr(err)
return 1
......
......@@ -4,8 +4,8 @@ import (
"fmt"
"strconv"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -126,7 +126,7 @@ func (cmd *Create) Run(args []string) int {
vmArgs.Name = name + " " + csvEntries[i-1]
}
vm, err := libclient.VMCreate(vmArgs)
vm, err := nc.VMCreate(vmArgs)
if err != nil {
u.PrintlnErr("Error: failed creating VM: " + err.Error())
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -32,7 +32,7 @@ func (cmd *Del) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetDelVMs, args)
vms, err := getFilteredVMs(nc.GetDelVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -46,7 +46,7 @@ func (cmd *Del) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMDel(vm.ID.String())
err := nc.VMDel(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
......@@ -8,8 +8,8 @@ import (
"os"
g "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/globals"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -94,7 +94,7 @@ func (cmd *DelAccess) Run(args []string) int {
continue
}
if err := libclient.VMDelAccess(vmID, vmID, email); err != nil {
if err := nc.VMDelAccess(vmID, vmID, email); err != nil {
u.PrintlnErr(err)
statusCode = 1
} else {
......@@ -110,7 +110,7 @@ func (cmd *DelAccess) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetEditAccessVMs, patterns)
vms, err := getFilteredVMs(nc.GetEditAccessVMs, patterns)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -122,7 +122,7 @@ func (cmd *DelAccess) Run(args []string) int {
}
for _, vm := range vms {
if err := libclient.VMDelAccess(vm.ID.String(), vm.Name, email); err != nil {
if err := nc.VMDelAccess(vm.ID.String(), vm.Name, email); err != nil {
u.PrintlnErr(err)
statusCode = 1
} else {
......
......@@ -5,8 +5,8 @@ import (
"strconv"
"strings"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -66,7 +66,7 @@ func (cmd *Edit) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetEditVMs, patterns)
vms, err := getFilteredVMs(nc.GetEditVMs, patterns)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -81,7 +81,7 @@ func (cmd *Edit) Run(args []string) int {
for _, vm := range vms {
vmID := vm.ID.String()
vmEdited, err := libclient.VMEdit(vmID, *vmParams)
vmEdited, err := nc.VMEdit(vmID, *vmParams)
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -43,7 +43,7 @@ func (cmd *ExportDir) Run(args []string) int {
dir := args[argc-1]
vms, err := getFilteredVMs(libclient.GetExportDirVMs, args[:argc-1])
vms, err := getFilteredVMs(nc.GetExportDirVMs, args[:argc-1])
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -57,7 +57,7 @@ func (cmd *ExportDir) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
outputFile, err := libclient.VMExportDir(vm.Name, vm.ID.String(), dir)
outputFile, err := nc.VMExportDir(vm.Name, vm.ID.String(), dir)
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
......@@ -3,7 +3,7 @@ package cmdVM
import (
"os"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -49,7 +49,7 @@ func (cmd *ImportDir) Run(args []string) int {
vmDir := args[argc-1]
localDir := args[argc-2]
vms, err := getFilteredVMs(libclient.GetImportFileVMs, args[:argc-2])
vms, err := getFilteredVMs(nc.GetImportFileVMs, args[:argc-2])
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -75,7 +75,7 @@ func (cmd *ImportDir) Run(args []string) int {
}
for _, vm := range vms {
err := libclient.VMImportArchive(vm.ID.String(), vmDir, tmpTarGzFile)
err := nc.VMImportArchive(vm.ID.String(), vmDir, tmpTarGzFile)
if err != nil {
u.PrintlnErr("Failed copying \"" + localDir + "\" into \"" + vmDir + "\" in VM \"" + vm.Name + "\": " + err.Error())
statusCode = 1
......
......@@ -3,8 +3,8 @@ package cmdVM
import (
"fmt"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -58,7 +58,7 @@ func (cmd *List) printFilteredVMs(args []string) int {
args = utils.RemoveArgAtIndex(args, foundLongOutputFlag)
}
vms, err := getFilteredVMs(libclient.GetListVMs, args)
vms, err := getFilteredVMs(nc.GetListVMs, args)
if err != nil {
u.PrintlnErr("Error: " + err.Error())
return 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -37,7 +37,7 @@ func (cmd *ListSingle) Run(args []string) int {
}
vmID := args[0]
vm, err := libclient.GetListVM(vmID)
vm, err := nc.GetListVM(vmID)
if err != nil {
u.PrintlnErr(err)
return 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -32,7 +32,7 @@ func (cmd *Reboot) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetRebootVMs, args)
vms, err := getFilteredVMs(nc.GetRebootVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -46,7 +46,7 @@ func (cmd *Reboot) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMReboot(vm.ID.String())
err := nc.VMReboot(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -32,7 +32,7 @@ func (cmd *Shutdown) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetStopVMs, args)
vms, err := getFilteredVMs(nc.GetStopVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -46,7 +46,7 @@ func (cmd *Shutdown) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMShutdown(vm.ID.String())
err := nc.VMShutdown(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -32,7 +32,7 @@ func (cmd *Start) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetStartVMs, args)
vms, err := getFilteredVMs(nc.GetStartVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -46,7 +46,7 @@ func (cmd *Start) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMStart(vm.ID.String())
err := nc.VMStart(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/exec"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -39,7 +39,7 @@ func (cmd *StartAttach) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetStartVMs, args)
vms, err := getFilteredVMs(nc.GetStartVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -53,7 +53,7 @@ func (cmd *StartAttach) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMStart(vm.ID.String())
err := nc.VMStart(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
......@@ -3,8 +3,8 @@ package cmdVM
import (
"errors"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils"
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
......@@ -74,7 +74,7 @@ func (cmd *StartWithCreds) Run(args []string) int {
for i, vmID := range vmIDs {
vmArgs.Pwd = pwds[i]
err := libclient.VMStartWithCreds(vmID, vmArgs)
err := nc.VMStartWithCreds(vmID, vmArgs)
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
package cmdVM
import (
libclient "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/vm"
nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
)
......@@ -32,7 +32,7 @@ func (cmd *Stop) Run(args []string) int {
return 1
}
vms, err := getFilteredVMs(libclient.GetStopVMs, args)
vms, err := getFilteredVMs(nc.GetStopVMs, args)
if err != nil {
u.PrintlnErr(err)
return 1
......@@ -46,7 +46,7 @@ func (cmd *Stop) Run(args []string) int {
statusCode := 0
for _, vm := range vms {
err := libclient.VMStop(vm.ID.String())
err := nc.VMStop(vm.ID.String())
if err != nil {
u.PrintlnErr(err)
statusCode = 1
......
......@@ -3,9 +3,8 @@ package nexusclient
import (
"encoding/json"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/params"
"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response"
)
// Authenticate a user given.
......@@ -24,7 +23,7 @@ func (nc *NexusClient) Authenticate(user, pwd string) error {
if err != nil {
return err
}
client.SetAuthToken(token.Token)
nc.client.SetAuthToken(token.Token)
return nil
} else {
return response.ErrorToMsg(resp)
......@@ -43,7 +42,7 @@ func (nc *NexusClient) RefreshToken() error {
if err != nil {
return err
}
client.SetAuthToken(token.Token)
nc.client.SetAuthToken(token.Token)
return nil
} else {
return response.ErrorToMsg(resp)
......
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment