From 2b481a45e959967771ab97f72dd3012d455b91d9 Mon Sep 17 00:00:00 2001 From: muhammadalihussnain Date: Wed, 18 Sep 2024 17:13:45 +0500 Subject: [PATCH 1/4] kdump-remote feature in hostcfgd --- scripts/hostcfgd | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/hostcfgd b/scripts/hostcfgd index 7f296f70..a63b754c 100644 --- a/scripts/hostcfgd +++ b/scripts/hostcfgd @@ -1134,9 +1134,14 @@ class SshServer(object): class KdumpCfg(object): def __init__(self, CfgDb): self.config_db = CfgDb - self.kdump_defaults = { "enabled" : "false", - "memory": "0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M", - "num_dumps": "3" } + self.kdump_defaults = { + "enabled": "false", + "memory": "0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M", + "num_dumps": "3", + "remote": "false", # New feature: remote, default is "false" + "SSH_KEY": "", # New feature: SSH key, default value + "SSH_PATH": "" # New feature: SSH path, default value + } def load(self, kdump_table): """ @@ -1147,7 +1152,7 @@ class KdumpCfg(object): for row in self.kdump_defaults: value = self.kdump_defaults.get(row) if not kdump_conf.get(row): - self.config_db.mod_entry("KDUMP", "config", {row : value}) + self.config_db.mod_entry("KDUMP", "config", {row: value}) def kdump_update(self, key, data): syslog.syslog(syslog.LOG_INFO, "Kdump global configuration update") @@ -1177,6 +1182,25 @@ class KdumpCfg(object): num_dumps = data.get("num_dumps") run_cmd(["sonic-kdump-config", "--num_dumps", num_dumps]) + # Remote option + remote = self.kdump_defaults["remote"] + if data.get("remote") is not None: + remote = data.get("remote") + run_cmd(["sonic-kdump-config", "--remote", remote]) + + # SSH key + ssh_key = self.kdump_defaults["SSH_KEY"] + if data.get("SSH_KEY") is not None: + ssh_key = data.get("SSH_KEY") + run_cmd(["sonic-kdump-config", "--ssh_key", ssh_key]) + + # SSH path + ssh_path = self.kdump_defaults["SSH_PATH"] + if data.get("SSH_PATH") is not None: + ssh_path = data.get("SSH_PATH") + run_cmd(["sonic-kdump-config", "--ssh_path", ssh_path]) + + class NtpCfg(object): """ NtpCfg Config Daemon From 3f60bda3894d2137112bbce4693585e0cfc36893 Mon Sep 17 00:00:00 2001 From: Muhammad Ali Hussnain <91005947+muhammadalihussnain@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:24:16 +0000 Subject: [PATCH 2/4] set values if remote enable --- scripts/hostcfgd | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/hostcfgd b/scripts/hostcfgd index a63b754c..dde15069 100644 --- a/scripts/hostcfgd +++ b/scripts/hostcfgd @@ -1189,16 +1189,16 @@ class KdumpCfg(object): run_cmd(["sonic-kdump-config", "--remote", remote]) # SSH key - ssh_key = self.kdump_defaults["SSH_KEY"] - if data.get("SSH_KEY") is not None: - ssh_key = data.get("SSH_KEY") - run_cmd(["sonic-kdump-config", "--ssh_key", ssh_key]) - - # SSH path - ssh_path = self.kdump_defaults["SSH_PATH"] - if data.get("SSH_PATH") is not None: - ssh_path = data.get("SSH_PATH") - run_cmd(["sonic-kdump-config", "--ssh_path", ssh_path]) + if remote.lower() == "true": + ssh_key = self.kdump_defaults["SSH_KEY"] + if data.get("SSH_KEY") is not None: + ssh_key = data.get("SSH_KEY") + run_cmd(["sonic-kdump-config", "--ssh_key", ssh_key]) + + ssh_path = self.kdump_defaults["SSH_PATH"] + if data.get("SSH_PATH") is not None: + ssh_path = data.get("SSH_PATH") + run_cmd(["sonic-kdump-config", "--ssh_path", ssh_path]) class NtpCfg(object): From be93fd2089eff33d27abdb2fcf1ed7ab80307a1b Mon Sep 17 00:00:00 2001 From: Muhammad Ali Hussnain <91005947+muhammadalihussnain@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:29:22 +0000 Subject: [PATCH 3/4] set values if remote enable --- scripts/hostcfgd | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/hostcfgd b/scripts/hostcfgd index dde15069..e4d0a196 100644 --- a/scripts/hostcfgd +++ b/scripts/hostcfgd @@ -1200,7 +1200,6 @@ class KdumpCfg(object): ssh_path = data.get("SSH_PATH") run_cmd(["sonic-kdump-config", "--ssh_path", ssh_path]) - class NtpCfg(object): """ NtpCfg Config Daemon From 3417b5f8a010901131a4646685efb3e61822ef2a Mon Sep 17 00:00:00 2001 From: Muhammad Ali Hussnain <91005947+muhammadalihussnain@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:10:39 +0000 Subject: [PATCH 4/4] set values if remote enable --- scripts/hostcfgd | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/hostcfgd b/scripts/hostcfgd index e4d0a196..b203b4ec 100644 --- a/scripts/hostcfgd +++ b/scripts/hostcfgd @@ -1189,16 +1189,11 @@ class KdumpCfg(object): run_cmd(["sonic-kdump-config", "--remote", remote]) # SSH key - if remote.lower() == "true": - ssh_key = self.kdump_defaults["SSH_KEY"] - if data.get("SSH_KEY") is not None: - ssh_key = data.get("SSH_KEY") - run_cmd(["sonic-kdump-config", "--ssh_key", ssh_key]) - - ssh_path = self.kdump_defaults["SSH_PATH"] - if data.get("SSH_PATH") is not None: - ssh_path = data.get("SSH_PATH") - run_cmd(["sonic-kdump-config", "--ssh_path", ssh_path]) + if data.get("SSH_KEY") is not None and (data.get("SSH_KEY") != self.kdump_defaults["SSH_KEY"]): + run_cmd(["sonic-kdump-config", "--ssh_key", data.get("SSH_KEY")]) + # SSH_PATH + if data.get("SSH_PATH") is not None and (data.get("SSH_PATH") != self.kdump_defaults["SSH_PATH"]): + run_cmd(["sonic-kdump-config", "--ssh_path", data.get("SSH_PATH")]) class NtpCfg(object): """