pass the VM to the buttons in the VM tab

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-25 16:00:33 -07:00
parent 7b601a8e68
commit 8fe85f0af2
3 changed files with 12 additions and 2 deletions

View File

@ -79,9 +79,14 @@ func addDebuggingButtons(vbox *ui.Box, custom func(*ButtonMap)) {
func runPingClick(b *ButtonMap) {
log.Println("runPingClick START")
log.Println("runTestExecClick b.VM", b.VM)
hostname := "localhost"
if (b.VM != nil) {
hostname = b.VM.Hostname
}
spew.Dump(b)
var tmp []string
tmp = append(tmp, "xterm", "-e", "ping localhost")
tmp = append(tmp, "xterm", "-e", "ping " + hostname + ";bash")
runCommand(tmp)
log.Println("runPingClick END")
}
@ -91,7 +96,7 @@ func runTestExecClick(b *ButtonMap) {
if runtime.GOOS == "linux" {
go runSimpleCommand("xterm -report-fonts")
} else if runtime.GOOS == "windows" {
go runSimpleCommand("cmd.exe")
go runSimpleCommand("mintty.exe")
} else {
go runSimpleCommand("xterm")
}
@ -115,6 +120,8 @@ func runCommand(cmdArgs []string) {
process.Start()
log.Println("runXterm process.Wait()")
process.Wait()
log.Println("runXterm NEED TO CHECK THE TIME HERE TO SEE IF THIS WORKED")
log.Println("runXterm OTHERWISE INFORM THE USER")
log.Println("runXterm END")
log.Println("runXterm END")
log.Println("runXterm END")

1
gui.go
View File

@ -201,6 +201,7 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM,
var newmap ButtonMap
newmap.B = newB
newmap.Account = a
newmap.VM = vm
newmap.Action = note
newmap.custom = custom
newmap.aTab = Data.CurrentTab

View File

@ -3,6 +3,7 @@ package gui
import "log"
import "time"
import "fmt"
// import "os"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
@ -335,6 +336,7 @@ func createVmBox(tab *ui.Tab, custom func(*ButtonMap), pbVM *pb.Event_VM) {
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
log.Println("pbVM =", pbVM)
hboxButtons.Append(CreateButton(nil, pbVM, "Power On", "POWERON", custom), false)
hboxButtons.Append(CreateButton(nil, pbVM, "Power Off", "POWEROFF", custom), false)
hboxButtons.Append(CreateButton(nil, pbVM, "Destroy", "DESTROY", custom), false)