2019-05-29 09:24:40 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
import "github.com/davecgh/go-spew/spew"
|
|
|
|
|
2019-05-30 10:52:28 -05:00
|
|
|
func AddVmConfigureTab(wm *GuiWindow, name string, pbVM *pb.Event_VM) {
|
2019-05-30 00:24:41 -05:00
|
|
|
CreateVmBox(wm, wm.T, pbVM)
|
2019-05-29 09:24:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:52:28 -05:00
|
|
|
func CreateVmBox(wm *GuiWindow, tab *ui.Tab, vm *pb.Event_VM) {
|
2019-05-29 09:24:40 -05:00
|
|
|
log.Println("CreateVmBox() START")
|
|
|
|
log.Println("CreateVmBox() vm.Name", vm.Name)
|
|
|
|
spew.Dump(vm)
|
|
|
|
if (Data.Debug) {
|
|
|
|
spew.Dump(vm)
|
|
|
|
}
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
|
|
|
|
hboxAccount := ui.NewHorizontalBox()
|
|
|
|
hboxAccount.SetPadded(true)
|
|
|
|
vbox.Append(hboxAccount, false)
|
|
|
|
|
|
|
|
// Add hostname entry box
|
|
|
|
makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true, "Hostname")
|
|
|
|
makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true, "IPv6")
|
|
|
|
makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory")
|
|
|
|
makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus")
|
|
|
|
makeEntryVbox(hboxAccount, "Disk (GB):",fmt.Sprintf("%d",vm.Disk), true, "Disk")
|
|
|
|
makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true, "BaseImage")
|
|
|
|
|
|
|
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
|
|
|
|
|
|
|
hboxButtons := ui.NewHorizontalBox()
|
|
|
|
hboxButtons.SetPadded(true)
|
|
|
|
vbox.Append(hboxButtons, false)
|
|
|
|
|
2019-05-29 21:57:15 -05:00
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Power On", "POWERON", nil), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Power Off", "POWEROFF", nil), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Destroy", "DESTROY", nil), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "ping", "PING", runPingClick), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Console", "XTERM", runTestExecClick), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Save", "SAVE", nil), false)
|
|
|
|
hboxButtons.Append(CreateButton(wm, nil, vm, "Done", "DONE", nil), false)
|
2019-05-29 09:24:40 -05:00
|
|
|
|
2019-05-30 00:24:41 -05:00
|
|
|
AddBoxToTab(vm.Name, tab, vbox)
|
2019-05-29 09:24:40 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:55:54 -05:00
|
|
|
func createAddVmBox(wm *GuiWindow, tab *ui.Tab, name string, b *GuiButton) {
|
2019-05-29 09:24:40 -05:00
|
|
|
log.Println("createAddVmBox() START")
|
|
|
|
vbox := ui.NewVerticalBox()
|
|
|
|
vbox.SetPadded(true)
|
|
|
|
|
|
|
|
hbox := ui.NewHorizontalBox()
|
|
|
|
hbox.SetPadded(true)
|
|
|
|
vbox.Append(hbox, false)
|
|
|
|
|
|
|
|
// Add hostname entry box
|
|
|
|
hostname := makeEntryHbox(vbox, "Hostname:", "testhost", true, "Hostname")
|
|
|
|
memory := makeEntryHbox(vbox, "Memory:", "512", true, "Memory")
|
|
|
|
disk := makeEntryHbox(vbox, "Disk:", "20", true, "Disk")
|
|
|
|
|
|
|
|
log.Println("createAddVmBox() hostname, memory, disk =", hostname, memory, disk)
|
|
|
|
|
|
|
|
vbox.Append(ui.NewHorizontalSeparator(), false)
|
|
|
|
|
|
|
|
hboxButtons := ui.NewHorizontalBox()
|
|
|
|
hboxButtons.SetPadded(true)
|
|
|
|
vbox.Append(hboxButtons, false)
|
|
|
|
|
2019-05-30 10:55:54 -05:00
|
|
|
var newb GuiButton
|
2019-05-29 09:24:40 -05:00
|
|
|
newb.Action = "CREATE"
|
|
|
|
newb.VM = b.VM
|
|
|
|
newb.Account = b.Account
|
|
|
|
newb.T = tab
|
|
|
|
hostname.B = &newb
|
|
|
|
memory.B = &newb
|
|
|
|
disk.B = &newb
|
|
|
|
hboxButtons.Append(AddButton(&newb, "Add Virtual Machine"), false)
|
|
|
|
|
|
|
|
// hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine","CREATE",nil), false)
|
2019-05-29 21:57:15 -05:00
|
|
|
hboxButtons.Append(CreateButton(wm, nil, nil, "Cancel", "CLOSE", nil), false)
|
2019-05-29 09:24:40 -05:00
|
|
|
|
|
|
|
name += " (" + b.Account.Nick + ")"
|
|
|
|
AddBoxToTab(name, tab, vbox)
|
|
|
|
}
|