本文整理匯總了Golang中github.com/dorzheh/deployer/ui/dialog_ui.DialogUi類的典型用法代碼示例。如果您正苦於以下問題:Golang DialogUi類的具體用法?Golang DialogUi怎麽用?Golang DialogUi使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DialogUi類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: uiShowNumaTopologyHelpMsg
func uiShowNumaTopologyHelpMsg(ui *gui.DialogUi) {
msg := "CPU Pinning Help\n"
msg += "----------------\n\n"
msg += "Example 1 : one to one pinning\n\n"
msg += " _____________________________________\n"
msg += "| VA vNUMA ID : 0_____________________|\n"
msg += "| Host CPU(s) : 0_____________________|\n"
msg += "|_____________________________________|\n\n"
msg += " __________________ CPU/NUMA Topology ________________\n"
msg += "|____________ VA ___________|_________ Host __________|\n"
msg += "|____ vCPU ___|___ vNUMA ___|_________CPU(s) _________|\n"
msg += "|______ 0 ____|_____ 0 _____|__________ 0 ____________|\n\n"
msg += "VA CPU 0 will be pinned to the host CPU 0\n\n\n"
msg += "Example 2 : pinning to a range of the host CPUs\n\n"
msg += " _____________________________________\n"
msg += "| VA vNUMA ID : 0_____________________|\n"
msg += "| Host CPU(s) : 0-3___________________|\n"
msg += "|_____________________________________|\n\n"
msg += " __________________ CPU/NUMA Topology ________________\n"
msg += "|____________ VA ___________|_________ Host __________|\n"
msg += "|____ vCPU ___|___ vNUMA ___|_________CPU(s) _________|\n"
msg += "|______ 0 ____|_____ 0 _____|__________ 0,1,2,3_______|\n\n"
msg += "VA CPUs will be pinned to the host CPUs 0,1,2 and 3\n\n\n"
msg += "Example 3 : pinning to a list of the host CPUs\n\n"
msg += " _____________________________________\n"
msg += "| VA vNUMA ID : 0_____________________|\n"
msg += "| Host CPU(s) : 0,1,2,3,8_____________|\n"
msg += "|_____________________________________|\n\n"
msg += " __________________ CPU/NUMA Topology ________________\n"
msg += "|____________ VA ___________|_________ Host __________|\n"
msg += "|____ vCPU ___|___ vNUMA ___|_________CPU(s) _________|\n"
msg += "|______ 0 ____|_____ 0 _____|_______ 0,1,2,3,8 _______|\n\n"
msg += "VA CPUs will be pinned to the host CPUs 0,1,2,3 and 8\n\n"
ui.Msgbox(msg)
}
示例2: UiEulaMsg
// UiEulaMsg prints out appropriate EULA message
func UiEulaMsg(ui *gui.DialogUi, pathToEula string) {
ui.SetOkLabel("Agree")
ui.SetExtraLabel("Disagree")
ui.SetTitle("End User License Agreement")
ui.SetSize(30, 80)
if err := ui.Textbox(pathToEula); err != nil {
os.Exit(1)
}
}
示例3: uiDiskNotOK
func uiDiskNotOK(ui *gui.DialogUi, selectedDiskInMb, minDiskInMb, maxDiskInMb int) bool {
if selectedDiskInMb < minDiskInMb {
ui.Output(gui.Warning, fmt.Sprintf("Minimum disk size requirement is %dGB.", minDiskInMb/1024), "Press <OK> to return to menu.")
return true
}
if selectedDiskInMb > maxDiskInMb {
ui.Output(gui.Warning, fmt.Sprintf("Maximum disk size requirement is %dGB.", maxDiskInMb/1024), "Press <OK> to return to menu.")
return true
}
return false
}
示例4: uiHeaderSelectNics
func uiHeaderSelectNics(ui *gui.DialogUi) int {
str := " ___________________________________________________________________________________________________________________________"
width := len(str)
str += "\n|____________________________________________________HOST__________________________________________________________|___VM___|"
str += fmt.Sprintf("\n|________%s________|__%s__|_______________ %s _________________|__%s__|__%s__|", "Port Name", "PCI Address", "Network Interface Description", "NUMA", "Port")
ui.SetLabel(str)
ui.SetExtraLabel("Next")
ui.SetOkLabel("Select")
ui.HelpButton(true)
ui.SetHelpLabel("Back")
return width
}
示例5: uiNUMATopologyHeader
func uiNUMATopologyHeader(ui *gui.DialogUi, c *guest.Config) string {
ui.HelpButton(true)
ui.SetHelpLabel("Back")
ui.SetTitle("VA NUMA Configuration")
ui.SetExtraLabel("Edit")
var hdr string
for _, n := range c.NUMAs {
for _, nic := range n.NICs {
if nic.HostNIC.Type == host.NicTypePhys || nic.HostNIC.Type == host.NicTypePhysVF {
hdr += fmt.Sprintf("\nNUMA %d: %s", nic.HostNIC.NUMANode, nic.HostNIC.PCIAddr)
}
}
}
hdr += "\n"
if hdr != "\n" {
hdr = " \n---------------- PCI Devices Topology ---------------" + hdr
hdr += "-----------------------------------------------------\n\n"
}
hdr += " __________________ CPU/NUMA Topology ________________\n"
hdr += "|____________ VA ___________|_________ Host __________|\n"
hdr += "|____ vCPU ___|___ vNUMA ___|_________CPU(s) _________|"
return hdr
}
示例6: UiGatherHWInfo
func UiGatherHWInfo(ui *gui.DialogUi, hidriver deployer.HostinfoDriver, remote bool) error {
errCh := make(chan error)
defer close(errCh)
go func() {
errCh <- hidriver.Init()
}()
var msg string
if remote {
msg = "Gathering harwdare information from remote host.\nPlease wait..."
} else {
msg = "Gathering hardware information from local host.\nPlease wait..."
}
return ui.Wait(msg, time.Second*2, 0, errCh)
}
示例7: uiCpuNotOK
func uiCpuNotOK(ui *gui.DialogUi, selectedCpus, installedCpus, minCpus, maxCpus int) bool {
if selectedCpus < minCpus {
ui.Output(gui.Warning, fmt.Sprintf("Minimum vCPUs requirement is %d.", minCpus), "Press <OK> to return to menu.")
return true
}
if selectedCpus > maxCpus {
ui.Output(gui.Warning, fmt.Sprintf("Amount of vCPUs exceeds maximum supported vCPUs(%d).", maxCpus), "Press <OK> to return to menu.")
return true
}
if selectedCpus > installedCpus {
if !UiVCPUsOvercommit(ui, installedCpus) {
return true
}
}
return false
}
示例8: UiImagePath
func UiImagePath(ui *gui.DialogUi, defaultLocation string, remote bool) (string, error) {
if remote {
return ui.GetFromInput("Select directory on remote server to install the VA image on", defaultLocation, "Back", "")
}
var location string
var err error
for {
location, err = ui.GetPathToDirFromInput("Select directory to install the VA image on", defaultLocation, "Back", "")
if err != nil {
return "", err
}
if _, err := os.Stat(location); err == nil {
break
}
}
return location, nil
}
示例9: UiRemoteMode
func UiRemoteMode(ui *gui.DialogUi) (bool, error) {
ui.SetTitle("Deployment Mode")
ui.SetSize(9, 28)
answer, err := ui.Menu(2, "1", "Local", "2", "Remote")
if err != nil {
return false, err
}
if answer == "1" {
return false, nil
}
if _, err := exec.LookPath("sshfs"); err != nil {
ui.Output(gui.Error, "sshfs utility is not installed")
}
return true, nil
}
示例10: uiBundleConfig
func uiBundleConfig(ui *gui.DialogUi, configs []*Config, advancedConfig bool) (*Config, error) {
var temp []string
index := 0
for _, c := range configs {
index += 1
temp = append(temp, strconv.Itoa(index),
fmt.Sprintf("%-15s [ vCPU %-2d | RAM %-3dMB]", c.Name, c.CPUs, c.RAM))
}
advIndex := index + 1
temp = append(temp, strconv.Itoa(advIndex), "Custom configuration")
sliceLength := len(temp)
var configNumStr string
var err error
for {
ui.SetSize(sliceLength+6, 50)
ui.SetLabel("Select Virtual Machine configuration")
configNumStr, err = ui.Menu(sliceLength+6, temp[0:]...)
if err != nil {
return nil, err
}
if configNumStr != "" {
break
}
}
configNumInt, err := strconv.Atoi(configNumStr)
if err != nil {
return nil, utils.FormatError(err)
}
if configNumInt == advIndex {
return nil, nil
}
return configs[configNumInt-1], nil
}
示例11: uiRamNotOK
func uiRamNotOK(ui *gui.DialogUi, selectedRamInMb, installedRamMb, minRamInMb, maxRamInMb int) bool {
if selectedRamInMb > installedRamMb {
ui.Output(gui.Warning, "Required RAM exceeds host machine available memory.", "Press <OK> to return to menu.")
return true
}
if selectedRamInMb < minRamInMb {
ui.Output(gui.Warning, fmt.Sprintf("Minimum RAM requirement is %0.1fGB.", float64(minRamInMb)/1024), "Press <OK> to return to menu.")
return true
}
if selectedRamInMb > maxRamInMb {
ui.Output(gui.Warning, fmt.Sprintf("Maximum RAM requirement is %0.1fGB.", float64(maxRamInMb)/1024), "Press <OK> to return to menu.")
return true
}
return false
}
示例12: UiVCPUsOvercommit
func UiVCPUsOvercommit(ui *gui.DialogUi, installedCpus int) bool {
ui.SetSize(8, 75)
ui.SetTitle(gui.Warning)
ui.SetLabel(fmt.Sprintf("\nThe host only has %d CPUs.Overcommitting vCPUs can reduce performance!\nWould you like to proceed?", installedCpus))
return ui.Yesno()
}
示例13: UiApplianceName
func UiApplianceName(ui *gui.DialogUi, defaultName string, driver deployer.EnvDriver) (string, error) {
var name string
var err error
for {
ui.SetSize(8, len(defaultName)+10)
ui.SetTitle("Virtual machine name")
ui.HelpButton(true)
ui.SetHelpLabel("Back")
name, err = ui.Inputbox(defaultName)
if err != nil {
return "", err
}
if name != "" {
name = strings.Replace(name, ".", "-", -1)
if driver != nil {
if driver.DomainExists(name) {
ui.Output(gui.Warning, "domain "+name+" already exists.", "Press <OK> to return to menu.")
continue
}
}
break
}
}
return name, nil
}
示例14: UiNUMATopology
func UiNUMATopology(ui *gui.DialogUi, c *guest.Config, d deployer.EnvDriver, totalCpusOnHost int) (bool, error) {
var list []string
// file, err := os.Create("/tmp/UiNUMATopology.txt")
// if err != nil {
// return false, nil
// }
// defer file.Close()
isChanged := false
hCPUnotOnce := ""
CheckIfCPUdoubleUsed := true
MainLoop:
for {
// file.WriteString("[UiNUMATopology] MainLoop: \n")
list = make([]string, 0)
tempData := make(map[int]map[int]string)
// file.WriteString("[UiNUMATopology] totalCpusOnHost: " + strconv.Itoa(totalCpusOnHost) + " \n")
for _, n := range c.NUMAs {
// file.WriteString("[UiNUMATopology] c.NUMAs\n")
// file.WriteString("[UiNUMATopology] len(n.CPUPin): " + strconv.Itoa(len(n.CPUPin)) + "\n")
keys := make([]int, 0)
for vcpu, _ := range n.CPUPin {
keys = append(keys, vcpu)
// file.WriteString("[UiNUMATopology] vcpu: " + strconv.Itoa(vcpu) + "\n")
}
sort.Ints(keys)
var hostCpu string
for _, k := range keys {
if len(n.CPUPin[k]) > 1 {
if len(n.CPUPin[k]) == totalCpusOnHost {
CheckIfCPUdoubleUsed = false
hostCpu = "0-" + strconv.Itoa(totalCpusOnHost-1)
} else {
var tmpStrSlice []string
for _, c := range n.CPUPin[k] {
tmpStrSlice = append(tmpStrSlice, strconv.Itoa(c))
}
hostCpu = strings.Join(tmpStrSlice, ",")
}
} else {
hostCpu = strconv.Itoa(n.CPUPin[k][0])
}
// file.WriteString("[UiNUMATopology] hostCpu: " + hostCpu + "\n")
tempData[k] = make(map[int]string)
tempData[k][n.CellID] = hostCpu
// file.WriteString("tempData[" + strconv.Itoa(k) + "][" + strconv.Itoa(n.CellID) + "] = " + hostCpu + " \n")
}
}
// we need to represent sorted vCPU IDs and not vNUMA IDs
keys := make([]int, 0)
for k, _ := range tempData {
keys = append(keys, k)
}
duplicate_frequency := make(map[string]int)
sort.Ints(keys)
for _, key := range keys {
for k, v := range tempData[key] {
list = append(list, strconv.Itoa(key), fmt.Sprintf("%-10s%-18d%-7s", " ", k, v))
temphCPU := v
_, exist := duplicate_frequency[temphCPU]
if exist {
duplicate_frequency[temphCPU] += 1 // increase counter by 1 if already in the map
} else {
duplicate_frequency[temphCPU] = 1 // else start counting from 1
}
// file.WriteString("k: " + strconv.Itoa(k) + " v: " + v + " \n")
}
}
hCPUnotOnce = ""
for k_dup, v_dup := range duplicate_frequency {
if v_dup > 1 {
hCPUnotOnce = k_dup
break
}
}
ui.SetLabel(uiNUMATopologyHeader(ui, c))
result, err := ui.Menu(len(list), list[0:]...)
// file.WriteString("[UiNUMATopology] result: " + result + " err: " + err.Error() + " len(list): " + strconv.Itoa(len(list)) + " \n")
if err == nil {
if hCPUnotOnce != "" && isChanged && CheckIfCPUdoubleUsed {
ui.Output(gui.Warning, "CPU "+hCPUnotOnce+" is assigned to more than one vCPU")
continue
}
break
}
if err.Error() != gui.DialogNext {
// file.WriteString("[UiNUMATopology] err.Error() != gui.DialogNext " + err.Error() + " \n")
return isChanged, err
}
InternalLoop:
//.........這裏部分代碼省略.........
示例15: UiWarningOnOptimizationFailure
func UiWarningOnOptimizationFailure(ui *gui.DialogUi, warningStr string) bool {
ui.SetTitle(gui.Warning)
ui.SetSize(10, 80)
ui.SetLabel("Virtual machine configuration can not be optimized.\n" + warningStr + "\n\nDo you want to continue?")
return ui.Yesno()
}