本文整理汇总了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()
}