Skip to content

Commit

Permalink
kdump-remote feature in hostcfgd (#166)
Browse files Browse the repository at this point in the history
* kdump-remote feature in hostcfgd

* set values if remote enable

* set values if remote enable

* set values if remote enable
  • Loading branch information
muhammadalihussnain authored Jan 21, 2025
1 parent 0430ada commit ca9d329
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,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": "<user@server>", # New feature: SSH key, default value
"SSH_PATH": "<path>" # New feature: SSH path, default value
}

def load(self, kdump_table):
"""
Expand All @@ -1149,7 +1154,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")
Expand Down Expand Up @@ -1179,6 +1184,19 @@ 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
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):
"""
NtpCfg Config Daemon
Expand Down

1 comment on commit ca9d329

@hdwhdw
Copy link
Contributor

@hdwhdw hdwhdw commented on ca9d329 Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://elastictest.org/scheduler/testplan/67a4e6f5f5a74203a8e1b8e8?testcase=show_techsupport%2Ftest_auto_techsupport.py&type=console

Match Messages:
E               2025 Feb  6 17:30:13.904639 vlab-03 ERR sonic_yang: All Keys are not parsed in KDUMP#012dict_keys(['SSH_KEY', 'SSH_PATH', 'remote'])
E               
E               2025 Feb  6 17:30:13.904667 vlab-03 ERR sonic_yang: exceptionList:[]
E               
E               2025 Feb  6 17:30:13.904691 vlab-03 ERR sonic_yang: Data Loading Failed:All Keys are not parsed in KDUMP#012dict_keys(['SSH_KEY', 'SSH_PATH', 'remote'])#012exceptionList:[]
E               
E               2025 Feb  6 17:30:13.904715 vlab-03 ERR ConfigMgmt: Data Loading Failed#012All Keys are not parsed in KDUMP#012dict_keys(['SSH_KEY', 'SSH_PATH', 'remote'])#012exceptionList:[]

This commit is preventing sonic-net/sonic-buildimage#21565 from merge. I think the test fails on KVM.

Please sign in to comment.