def getTotalMemory(): """Return the total amount of system memory in MB This is the amount reported by /proc/meminfo plus the aount currently reserved for kdump. """ # total_memory return memory in KB, convert to MB availMem = total_memory() / 1024 return availMem + getReservedMemory()
def getTotalMemory(): """Return the total amount of system memory in MB This is the amount reported by /proc/meminfo plus the aount currently reserved for kdump. """ # total_memory return memory in KB, convert to MB availMem = total_memory() / 1024 return availMem + getReservedMemory()
def check_memory(anaconda, options, display_mode=None): """Check is the system has enough RAM for installation. :param anaconda: instance of the Anaconda class :param options: command line/boot options :param display_mode: a display mode to use for the check (graphical mode usually needs more RAM, etc.) """ from pyanaconda import isys reason_strict = _( "%(product_name)s requires %(needed_ram)s MB of memory to " "install, but you only have %(total_ram)s MB on this machine.\n") reason_graphical = _( "The %(product_name)s graphical installer requires %(needed_ram)s " "MB of memory, but you only have %(total_ram)s MB.\n") reboot_extra = _('\n' 'Press [Enter] to reboot your system.\n') livecd_title = _("Not enough RAM") livecd_extra = _(" Try the text mode installer by running:\n\n" "'/usr/bin/liveinst -T'\n\n from a root terminal.") nolivecd_extra = _(" Starting text mode.") # skip the memory check in rescue mode if options.rescue: return if not display_mode: display_mode = anaconda.display_mode reason = reason_strict total_ram = int(isys.total_memory() / 1024) needed_ram = int(isys.MIN_RAM) graphical_ram = int(isys.MIN_GUI_RAM) # count the squashfs.img in if it is kept in RAM if not util.persistent_root_image(): needed_ram += isys.SQUASHFS_EXTRA_RAM graphical_ram += isys.SQUASHFS_EXTRA_RAM log.info("check_memory(): total:%s, needed:%s, graphical:%s", total_ram, needed_ram, graphical_ram) if not options.memcheck: log.warning("CHECK_MEMORY DISABLED") return reason_args = { "product_name": product.productName, "needed_ram": needed_ram, "total_ram": total_ram } if needed_ram > total_ram: if options.liveinst: # pylint: disable=logging-not-lazy stdout_log.warning(reason % reason_args) gtk_warning(livecd_title, reason % reason_args) else: reason += reboot_extra print(reason % reason_args) print( _("The installation cannot continue and the system will be rebooted" )) print(_("Press ENTER to continue")) input() util.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) # override display mode if machine cannot nicely run X if display_mode != constants.DisplayModes.TUI and not flags.usevnc: needed_ram = graphical_ram reason_args["needed_ram"] = graphical_ram reason = reason_graphical if needed_ram > total_ram: if options.liveinst: reason += livecd_extra # pylint: disable=logging-not-lazy stdout_log.warning(reason % reason_args) title = livecd_title gtk_warning(title, reason % reason_args) util.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) else: reason += nolivecd_extra # pylint: disable=logging-not-lazy stdout_log.warning(reason % reason_args) anaconda.display_mode = constants.DisplayModes.TUI time.sleep(2)
def check_memory(anaconda, options, display_mode=None): from pyanaconda import isys reason_strict = _("%(product_name)s requires %(needed_ram)s MB of memory to " "install, but you only have %(total_ram)s MB on this machine.\n") reason_graphical = _("The %(product_name)s graphical installer requires %(needed_ram)s " "MB of memory, but you only have %(total_ram)s MB\n.") reboot_extra = _('\n' 'Press [Enter] to reboot your system.\n') livecd_title = _("Not enough RAM") livecd_extra = _(" Try the text mode installer by running:\n\n" "'/usr/bin/liveinst -T'\n\n from a root " "terminal.") nolivecd_extra = _(" Starting text mode.") if options.rescue: return if not display_mode: display_mode = anaconda.displayMode reason = reason_strict total_ram = int(isys.total_memory() / 1024) needed_ram = int(isys.MIN_RAM) graphical_ram = int(isys.MIN_GUI_RAM) # count the squashfs.img in if it is kept in RAM if not iutil.persistent_root_image(): needed_ram += isys.SQUASHFS_EXTRA_RAM graphical_ram += isys.SQUASHFS_EXTRA_RAM log.info("check_memory(): total:%s, needed:%s, graphical:%s", total_ram, needed_ram, graphical_ram) if not options.memcheck: log.warning("CHECK_MEMORY DISABLED") return reason_args = {"product_name": product.productName, "needed_ram": needed_ram, "total_ram": total_ram} if needed_ram > total_ram: if options.liveinst: # pylint: disable=logging-not-lazy stdoutLog.warning(reason % reason_args) gtk_warning(livecd_title, reason % reason_args) else: reason += reboot_extra print(reason % reason_args) print(_("The installation cannot continue and the system will be rebooted")) print(_("Press ENTER to continue")) input() iutil.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) # override display mode if machine cannot nicely run X if display_mode not in ('t', 'c', 's') and not flags.usevnc: needed_ram = graphical_ram reason_args["needed_ram"] = graphical_ram reason = reason_graphical if needed_ram > total_ram: if options.liveinst: reason += livecd_extra # pylint: disable=logging-not-lazy stdoutLog.warning(reason % reason_args) title = livecd_title gtk_warning(title, reason % reason_args) iutil.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) else: reason += nolivecd_extra # pylint: disable=logging-not-lazy stdoutLog.warning(reason % reason_args) anaconda.displayMode = 't' time.sleep(2)