Skip to content

Commit ca9d329

Browse files
kdump-remote feature in hostcfgd (#166)
* kdump-remote feature in hostcfgd * set values if remote enable * set values if remote enable * set values if remote enable
1 parent 0430ada commit ca9d329

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

scripts/hostcfgd

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,14 @@ class SshServer(object):
11361136
class KdumpCfg(object):
11371137
def __init__(self, CfgDb):
11381138
self.config_db = CfgDb
1139-
self.kdump_defaults = { "enabled" : "false",
1140-
"memory": "0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M",
1141-
"num_dumps": "3" }
1139+
self.kdump_defaults = {
1140+
"enabled": "false",
1141+
"memory": "0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M",
1142+
"num_dumps": "3",
1143+
"remote": "false", # New feature: remote, default is "false"
1144+
"SSH_KEY": "<user@server>", # New feature: SSH key, default value
1145+
"SSH_PATH": "<path>" # New feature: SSH path, default value
1146+
}
11421147

11431148
def load(self, kdump_table):
11441149
"""
@@ -1149,7 +1154,7 @@ class KdumpCfg(object):
11491154
for row in self.kdump_defaults:
11501155
value = self.kdump_defaults.get(row)
11511156
if not kdump_conf.get(row):
1152-
self.config_db.mod_entry("KDUMP", "config", {row : value})
1157+
self.config_db.mod_entry("KDUMP", "config", {row: value})
11531158

11541159
def kdump_update(self, key, data):
11551160
syslog.syslog(syslog.LOG_INFO, "Kdump global configuration update")
@@ -1179,6 +1184,19 @@ class KdumpCfg(object):
11791184
num_dumps = data.get("num_dumps")
11801185
run_cmd(["sonic-kdump-config", "--num_dumps", num_dumps])
11811186

1187+
# Remote option
1188+
remote = self.kdump_defaults["remote"]
1189+
if data.get("remote") is not None:
1190+
remote = data.get("remote")
1191+
run_cmd(["sonic-kdump-config", "--remote", remote])
1192+
1193+
# SSH key
1194+
if data.get("SSH_KEY") is not None and (data.get("SSH_KEY") != self.kdump_defaults["SSH_KEY"]):
1195+
run_cmd(["sonic-kdump-config", "--ssh_key", data.get("SSH_KEY")])
1196+
# SSH_PATH
1197+
if data.get("SSH_PATH") is not None and (data.get("SSH_PATH") != self.kdump_defaults["SSH_PATH"]):
1198+
run_cmd(["sonic-kdump-config", "--ssh_path", data.get("SSH_PATH")])
1199+
11821200
class NtpCfg(object):
11831201
"""
11841202
NtpCfg Config Daemon

0 commit comments

Comments
 (0)