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) { func runPingClick(b *ButtonMap) {
log.Println("runPingClick START") log.Println("runPingClick START")
log.Println("runTestExecClick b.VM", b.VM)
hostname := "localhost"
if (b.VM != nil) {
hostname = b.VM.Hostname
}
spew.Dump(b) spew.Dump(b)
var tmp []string var tmp []string
tmp = append(tmp, "xterm", "-e", "ping localhost") tmp = append(tmp, "xterm", "-e", "ping " + hostname + ";bash")
runCommand(tmp) runCommand(tmp)
log.Println("runPingClick END") log.Println("runPingClick END")
} }
@ -91,7 +96,7 @@ func runTestExecClick(b *ButtonMap) {
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
go runSimpleCommand("xterm -report-fonts") go runSimpleCommand("xterm -report-fonts")
} else if runtime.GOOS == "windows" { } else if runtime.GOOS == "windows" {
go runSimpleCommand("cmd.exe") go runSimpleCommand("mintty.exe")
} else { } else {
go runSimpleCommand("xterm") go runSimpleCommand("xterm")
} }
@ -115,6 +120,8 @@ func runCommand(cmdArgs []string) {
process.Start() process.Start()
log.Println("runXterm process.Wait()") log.Println("runXterm process.Wait()")
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") 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 var newmap ButtonMap
newmap.B = newB newmap.B = newB
newmap.Account = a newmap.Account = a
newmap.VM = vm
newmap.Action = note newmap.Action = note
newmap.custom = custom newmap.custom = custom
newmap.aTab = Data.CurrentTab newmap.aTab = Data.CurrentTab

View File

@ -3,6 +3,7 @@ package gui
import "log" import "log"
import "time" import "time"
import "fmt" import "fmt"
// import "os"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" 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) hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false) vbox.Append(hboxButtons, false)
log.Println("pbVM =", pbVM)
hboxButtons.Append(CreateButton(nil, pbVM, "Power On", "POWERON", custom), false) 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, "Power Off", "POWEROFF", custom), false)
hboxButtons.Append(CreateButton(nil, pbVM, "Destroy", "DESTROY", custom), false) hboxButtons.Append(CreateButton(nil, pbVM, "Destroy", "DESTROY", custom), false)