コード例 #1
0
ファイル: ui.go プロジェクト: weldpua2008/deployer
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
0
ファイル: ui.go プロジェクト: weldpua2008/deployer
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
0
ファイル: ui.go プロジェクト: weldpua2008/deployer
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()
}