本文整理匯總了Golang中github.com/dorzheh/deployer/ui/dialog_ui.DialogUi.Yesno方法的典型用法代碼示例。如果您正苦於以下問題:Golang DialogUi.Yesno方法的具體用法?Golang DialogUi.Yesno怎麽用?Golang DialogUi.Yesno使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dorzheh/deployer/ui/dialog_ui.DialogUi
的用法示例。
在下文中一共展示了DialogUi.Yesno方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UiNumaRamNotOK
func UiNumaRamNotOK(ui *gui.DialogUi, driver deployer.HostinfoDriver, c *guest.Config, selectedRamInMb int) (bool, error) {
// file, err := os.Create("/tmp/_setNUMATuneData.txt")
// defer file.Close()
numas, err := driver.NUMAInfo()
if err != nil {
return true, utils.FormatError(err)
}
NumaForCheck := make([]int, 0)
// file.WriteString("uiNumaRamNotOK\n")
for _, n := range c.NUMAs {
// file.WriteString("c.NUMAs\n")
for _, nic := range n.NICs {
if nic.HostNIC.Type == host.NicTypePhys || nic.HostNIC.Type == host.NicTypePhysVF {
isAdd := true
for _, v := range NumaForCheck {
if v == nic.HostNIC.NUMANode {
isAdd = false
}
}
if isAdd {
NumaForCheck = append(NumaForCheck, nic.HostNIC.NUMANode)
// file.WriteString("NumaForCheck: [" + strconv.Itoa(nic.HostNIC.NUMANode) + "]\n")
}
}
}
}
// selectedRamInMb = 1
var requiredMemory float64
var freeRam float64
numberOfNumas := len(NumaForCheck)
if numberOfNumas < 1 {
numberOfNumas = 1
}
requiredMemoryMB := selectedRamInMb / numberOfNumas
requiredMemory = float64(selectedRamInMb / numberOfNumas)
requiredMemoryStr := strconv.FormatFloat((requiredMemory / 1024), 'f', 1, 64)
// file.WriteString("requiredMemoryStr: " + requiredMemoryStr + " selectedRamInMb:" + strconv.Itoa(selectedRamInMb) + " \n")
for _, node := range numas {
for _, CellID := range NumaForCheck {
// file.WriteString("CellID: " + strconv.Itoa(CellID) + " node.CellID: " + strconv.Itoa(node.CellID) + "\n")
if node.CellID != CellID {
continue
}
numafreeRamMb := node.FreeRAM / 1024
// file.WriteString("requiredMemoryMB: " + strconv.Itoa(requiredMemoryMB) + " node.FreeRAM:" + strconv.Itoa(numafreeRamMb) + " \n")
// numafreeRamMb = 0
if numafreeRamMb < requiredMemoryMB {
freeRam = float64(node.FreeRAM / (1024 * 1024))
freeRamStr := strconv.FormatFloat(freeRam, 'f', 1, 64)
ui.SetTitle(gui.Warning)
ui.SetSize(10, 80)
ui.SetLabel("Virtual machine configuration can not be optimized.\n" + requiredMemoryStr + " GB RAM are required on NUMA " + strconv.Itoa(node.CellID) + " but just " + freeRamStr + "Gb are available\n\nDo you want to continue?")
return ui.Yesno(), nil
}
}
}
return true, nil
}
示例2: 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()
}
示例3: 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()
}