221 lines
8.0 KiB
Diff
221 lines
8.0 KiB
Diff
From 78830ebefc25f616145da2b1534f879f4cabca29 Mon Sep 17 00:00:00 2001
|
|
From: Jiri Konecny <jkonecny@redhat.com>
|
|
Date: Fri, 19 Jan 2018 11:41:39 +0100
|
|
Subject: [PATCH 1/3] Fix import after Anaconda refactoring
|
|
|
|
iutil -> core.util
|
|
|
|
Introduced in anaconda-28.18.1.
|
|
---
|
|
com_redhat_kdump/ks/kdump.py | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/com_redhat_kdump/ks/kdump.py b/com_redhat_kdump/ks/kdump.py
|
|
index ec4ab35..4f734e4 100644
|
|
--- a/com_redhat_kdump/ks/kdump.py
|
|
+++ b/com_redhat_kdump/ks/kdump.py
|
|
@@ -21,7 +21,7 @@
|
|
|
|
import os.path
|
|
from pyanaconda.addons import AddonData
|
|
-from pyanaconda import iutil
|
|
+from pyanaconda.core import util
|
|
from pyanaconda.flags import flags
|
|
|
|
from pykickstart.options import KSOptionParser
|
|
@@ -138,4 +138,4 @@ def execute(self, storage, ksdata, instClass, users, payload):
|
|
else:
|
|
action = "disable"
|
|
|
|
- iutil.execWithRedirect("systemctl", [action, "kdump.service"], root=iutil.getSysroot())
|
|
+ util.execWithRedirect("systemctl", [action, "kdump.service"], root=util.getSysroot())
|
|
|
|
From d0a30e26ca7176db949038402effa0523cae3fc2 Mon Sep 17 00:00:00 2001
|
|
From: Jiri Konecny <jkonecny@redhat.com>
|
|
Date: Fri, 19 Jan 2018 11:45:32 +0100
|
|
Subject: [PATCH 2/3] Fix unused dependency and code style
|
|
|
|
Minor issues I found in the code.
|
|
---
|
|
com_redhat_kdump/common.py | 1 -
|
|
com_redhat_kdump/ks/kdump.py | 2 +-
|
|
2 files changed, 1 insertion(+), 2 deletions(-)
|
|
|
|
diff --git a/com_redhat_kdump/common.py b/com_redhat_kdump/common.py
|
|
index d45304e..1b79186 100644
|
|
--- a/com_redhat_kdump/common.py
|
|
+++ b/com_redhat_kdump/common.py
|
|
@@ -18,7 +18,6 @@
|
|
#
|
|
# Red Hat Author(s): David Shea <dshea@redhat.com>
|
|
#
|
|
-import os
|
|
import re
|
|
__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds"]
|
|
|
|
diff --git a/com_redhat_kdump/ks/kdump.py b/com_redhat_kdump/ks/kdump.py
|
|
index 4f734e4..84ec5f9 100644
|
|
--- a/com_redhat_kdump/ks/kdump.py
|
|
+++ b/com_redhat_kdump/ks/kdump.py
|
|
@@ -125,7 +125,7 @@ def handle_header(self, lineno, args):
|
|
|
|
# Store the parsed arguments
|
|
self.enabled = opts.enabled
|
|
- self.reserveMB =opts.reserveMB
|
|
+ self.reserveMB = opts.reserveMB
|
|
self.enablefadump = opts.enablefadump
|
|
|
|
def execute(self, storage, ksdata, instClass, users, payload):
|
|
|
|
From 8d18fd069b8b63b2ff031f47103ec879ab85f22d Mon Sep 17 00:00:00 2001
|
|
From: Jiri Konecny <jkonecny@redhat.com>
|
|
Date: Fri, 19 Jan 2018 16:50:04 +0100
|
|
Subject: [PATCH 3/3] Migrate TUI spoke to new Simpleline solution
|
|
|
|
Anaconda migrated to Simpleline which is old Anaconda TUI promoted to
|
|
separate library.
|
|
---
|
|
com_redhat_kdump/tui/spokes/kdump.py | 106 +++++++++++++++++++--------
|
|
1 file changed, 76 insertions(+), 30 deletions(-)
|
|
|
|
diff --git a/com_redhat_kdump/tui/spokes/kdump.py b/com_redhat_kdump/tui/spokes/kdump.py
|
|
index e220f07..dea0b14 100644
|
|
--- a/com_redhat_kdump/tui/spokes/kdump.py
|
|
+++ b/com_redhat_kdump/tui/spokes/kdump.py
|
|
@@ -26,50 +26,36 @@
|
|
|
|
from pyanaconda.flags import flags
|
|
from pyanaconda.ui.categories.system import SystemCategory
|
|
-from pyanaconda.ui.tui.spokes import EditTUISpoke
|
|
-from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
|
|
+from pyanaconda.ui.tui.spokes import NormalTUISpoke
|
|
+from pyanaconda.ui.tui.tuiobject import Dialog
|
|
+from simpleline.render.widgets import CheckboxWidget, EntryWidget
|
|
+from simpleline.render.containers import ListColumnContainer
|
|
+from simpleline.render.screen import InputState
|
|
from com_redhat_kdump.common import getMemoryBounds
|
|
from com_redhat_kdump.i18n import N_, _
|
|
from com_redhat_kdump.constants import FADUMP_CAPABLE_FILE
|
|
|
|
__all__ = ["KdumpSpoke"]
|
|
|
|
-class _re:
|
|
- def __init__(self, patten):
|
|
- self.re = re.compile(patten)
|
|
+class KdumpSpoke(NormalTUISpoke):
|
|
+ category = SystemCategory
|
|
|
|
- def match(self, key):
|
|
- if self.re.match(key):
|
|
- self.low, self.up, self.step = getMemoryBounds()
|
|
- if key[-1] == 'M':
|
|
- key = key[:-1]
|
|
- key = int(key)
|
|
- if key <= self.up and key >= self.low :
|
|
- return True
|
|
- return False
|
|
+ def __init__(self, data, storage, payload, instclass):
|
|
+ super().__init__(data, storage, payload, instclass)
|
|
+ self.title = N_("Kdump")
|
|
+ self._addon_data = self.data.addons.com_redhat_kdump
|
|
|
|
-# Allow a string of digits optionally followed by 'M'
|
|
-RESERVE_VALID = _re(r'^(\d+M?)$')
|
|
+ self._lower, self._upper, self._step = getMemoryBounds()
|
|
+ # Allow a string of digits optionally followed by 'M'
|
|
+ self._reserve_check_re = re.compile(r'^(\d+M?)$')
|
|
|
|
-class KdumpSpoke(EditTUISpoke):
|
|
- title = N_("Kdump")
|
|
- category = SystemCategory
|
|
- lower, upper ,_step = getMemoryBounds()
|
|
- edit_fields = [
|
|
- Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
|
|
- Entry("Enable dump mode fadump", "enablefadump", EditTUISpoke.CHECK, os.path.exists(FADUMP_CAPABLE_FILE) and (lambda self,args: args.enabled)),
|
|
- Entry("Reserve amount (%d - %d MB)" % (lower, upper), "reserveMB", RESERVE_VALID, lambda self,args: args.enabled)
|
|
- ]
|
|
+ self._container = None
|
|
|
|
@classmethod
|
|
def should_run(cls, environment, data):
|
|
# the KdumpSpoke should run only if requested
|
|
return flags.cmdline.getbool("kdump_addon", default=False)
|
|
|
|
- def __init__(self, app, data, storage, payload, instclass):
|
|
- EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
|
|
- self.args = self.data.addons.com_redhat_kdump
|
|
-
|
|
def apply(self):
|
|
pass
|
|
|
|
@@ -79,8 +65,68 @@ def completed(self):
|
|
|
|
@property
|
|
def status(self):
|
|
- if self.args.enabled:
|
|
+ if self._addon_data.enabled:
|
|
state = _("Kdump is enabled")
|
|
else:
|
|
state = _("Kdump is disabled")
|
|
return state
|
|
+
|
|
+ def refresh(self, args=None):
|
|
+ super().refresh(args)
|
|
+
|
|
+ self._container = ListColumnContainer(1)
|
|
+ self.window.add(self._container)
|
|
+
|
|
+ self._create_enable_checkbox()
|
|
+
|
|
+ if self._addon_data.enabled:
|
|
+ self._create_fadump_checkbox()
|
|
+ self._create_reserve_amount_text_widget()
|
|
+
|
|
+ self.window.add_separator()
|
|
+
|
|
+ def _create_enable_checkbox(self):
|
|
+ enable_kdump_checkbox = CheckboxWidget(title=_("Enable kdump"),
|
|
+ completed=self._addon_data.enabled)
|
|
+ self._container.add(enable_kdump_checkbox, self._set_enabled)
|
|
+
|
|
+ def _create_fadump_checkbox(self):
|
|
+ if not os.path.exists(FADUMP_CAPABLE_FILE):
|
|
+ return
|
|
+
|
|
+ enable_fadump_checkbox = CheckboxWidget(title=_("Enable dump mode fadump"),
|
|
+ completed=self._addon_data.enablefadump)
|
|
+ self._container.add(enable_fadump_checkbox, self._set_fadump_enable)
|
|
+
|
|
+ def _create_reserve_amount_text_widget(self):
|
|
+ title = _("Reserve amount (%d - %d MB)" % (self._lower, self._upper))
|
|
+ reserve_amount_entry = EntryWidget(title=title, value=self._addon_data.reserveMB)
|
|
+ self._container.add(reserve_amount_entry, self._get_reserve_amount)
|
|
+
|
|
+ def _set_enabled(self, data):
|
|
+ self._addon_data.enabled = not self._addon_data.enabled
|
|
+
|
|
+ def _set_fadump_enable(self, data):
|
|
+ self._addon_data.enablefadump = not self._addon_data.enablefadump
|
|
+
|
|
+ def _get_reserve_amount(self, data):
|
|
+ text = "Reserve amount (%d - %d MB)" % (self._lower, self._upper)
|
|
+ dialog = Dialog(title=text, conditions=[self._check_reserve_valid])
|
|
+
|
|
+ self._addon_data.reserveMB = dialog.run()
|
|
+
|
|
+ def _check_reserve_valid(self, key, report_func):
|
|
+ if self._reserve_check_re.match(key):
|
|
+ if key[-1] == 'M':
|
|
+ key = key[:-1]
|
|
+ key = int(key)
|
|
+ if self._upper >= key >= self._lower:
|
|
+ return True
|
|
+ return False
|
|
+
|
|
+ def input(self, args, key):
|
|
+ if self._container.process_user_input(key):
|
|
+ self.redraw()
|
|
+ return InputState.PROCESSED
|
|
+ else:
|
|
+ return super().input(args, key)
|