kdump-anaconda-addon/set-addon-default-on-and-close-service-when-ks-set-disable.patch

68 lines
2.2 KiB
Diff
Raw Permalink Normal View History

From f610873cd3590a0cb77287c01b7a025dc83a547a Mon Sep 17 00:00:00 2001
From: sun_hai_10 <sunhai10@huawei.com>
Date: Thu, 6 Apr 2023 18:26:19 +0800
Subject: [PATCH] set addon defalut on and close service when ks set disable
Signed-off-by: yangzhuangzhuang <yangzhuangzhuang1@huawei.com>
Signed-off-by: zhangruifang <zhangruifang1@huawei.com>
---
com_redhat_kdump/service/initialization.py | 18 +++++++++++++++++-
com_redhat_kdump/service/installation.py | 8 +++++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/com_redhat_kdump/service/initialization.py b/com_redhat_kdump/service/initialization.py
index 2bdbe6e..310a504 100644
--- a/com_redhat_kdump/service/initialization.py
+++ b/com_redhat_kdump/service/initialization.py
@@ -25,8 +25,24 @@ log = logging.getLogger(__name__)
__all__ = ["check_initial_conditions"]
+def kdump_is_enabled():
+ """Return boolean value for the given argument.
+
+ Rules:
+ - 0, off -> False
+ - the rest, not present -> True
+ """
+ # None is stored when arg is present but had no value when parsing.
+ # So the "miss" value must be something else.
+ val = kernel_arguments.get("kdump_addon", True)
+ if val in ["0", "off"]:
+ return False
+ else:
+ return True
+
+
def check_initial_conditions():
"""Can the Kdump service run?"""
- if not kernel_arguments.is_enabled("kdump_addon"):
+ if not kdump_is_enabled():
log.debug("The kdump add-on is disabled. Quit.")
sys.exit(1)
diff --git a/com_redhat_kdump/service/installation.py b/com_redhat_kdump/service/installation.py
index 64638a9..d93b51a 100644
--- a/com_redhat_kdump/service/installation.py
+++ b/com_redhat_kdump/service/installation.py
@@ -85,12 +85,14 @@ class KdumpInstallationTask(Task):
def run(self):
"""Run the task."""
+ action = "enable"
if not self._kdump_enabled:
- log.debug("Kdump is disabled. Skipping.")
- return
+ log.debug("Kdump is disabled.")
+ # unknow kdump.service default set
+ action = "disable"
util.execWithRedirect(
"systemctl",
- ["enable", "kdump.service"],
+ [action, "kdump.service"],
root=self._sysroot
)
--
2.19.1