-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into dev-banner-feature
- Loading branch information
Showing
14 changed files
with
344 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
data/debian/sonic-host-services-data.process-reboot-cause.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
[Unit] | ||
Description=Retrieve the reboot cause from the history files and save them to StateDB | ||
Requires=database.service determine-reboot-cause.service | ||
PartOf=database.service | ||
After=database.service determine-reboot-cause.service | ||
|
||
[Service] | ||
Type=simple | ||
ExecStartPre=/usr/bin/systemctl is-active database | ||
ExecStartPre=/usr/bin/systemctl is-active determine-reboot-cause | ||
Restart=on-failure | ||
RestartSec=30 | ||
RemainAfterExit=yes | ||
ExecStart=/usr/local/bin/process-reboot-cause | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
9 changes: 0 additions & 9 deletions
9
data/debian/sonic-host-services-data.process-reboot-cause.timer
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Systemd service handler""" | ||
|
||
from host_modules import host_service | ||
import subprocess | ||
|
||
MOD_NAME = 'systemd' | ||
ALLOWED_SERVICES = ['snmp', 'swss', 'dhcp_relay', 'radv', 'restapi', 'lldp', 'sshd', 'pmon', 'rsyslog', 'telemetry'] | ||
EXIT_FAILURE = 1 | ||
|
||
|
||
class SystemdService(host_service.HostModule): | ||
""" | ||
DBus endpoint that executes the service command | ||
""" | ||
@host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is') | ||
def restart_service(self, service): | ||
if not service: | ||
return EXIT_FAILURE, "Dbus restart_service called with no service specified" | ||
if service not in ALLOWED_SERVICES: | ||
return EXIT_FAILURE, "Dbus does not support {} service restart".format(service) | ||
|
||
cmd = ['/usr/bin/systemctl', 'reset-failed', service] | ||
result = subprocess.run(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
if result.returncode: | ||
possible_expected_error = "Failed to reset failed state" | ||
msg = result.stderr.decode() | ||
if possible_expected_error not in msg: | ||
return result.returncode, msg # Throw error only if unexpected error | ||
|
||
msg = '' | ||
cmd = ['/usr/bin/systemctl', 'restart', service] | ||
result = subprocess.run(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
if result.returncode: | ||
msg = result.stderr.decode() | ||
|
||
return result.returncode, msg | ||
|
||
@host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is') | ||
def stop_service(self, service): | ||
if not service: | ||
return EXIT_FAILURE, "Dbus stop_service called with no service specified" | ||
if service not in ALLOWED_SERVICES: | ||
return EXIT_FAILURE, "Dbus does not support {} service management".format(service) | ||
|
||
cmd = ['/usr/bin/systemctl', 'stop', service] | ||
result = subprocess.run(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
msg = '' | ||
if result.returncode: | ||
msg = result.stderr.decode() | ||
return result.returncode, msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.