-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sonic-net:master' into jhli-exb
- Loading branch information
Showing
69 changed files
with
2,486 additions
and
149 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
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
5 changes: 3 additions & 2 deletions
5
data/debian/sonic-host-services-data.determine-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
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
4 changes: 2 additions & 2 deletions
4
data/debian/sonic-host-services-data.procdockerstatsd.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
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
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,17 @@ | ||
{{ ldap_cfg.cfg_servers(servers) }} | ||
|
||
base {{ ldap_cfg.cfg_base(servers) }} | ||
|
||
ldap_version {{ ldap_cfg.cfg_version(servers) }} | ||
|
||
binddn {{ ldap_cfg.cfg_bind(servers) }} | ||
|
||
bindpw {{ ldap_cfg.cfg_bindpw(servers) }} | ||
|
||
port {{ ldap_cfg.cfg_port(servers) }} | ||
|
||
scope {{ ldap_cfg.cfg_scope(servers) }} | ||
|
||
timelimit {{ ldap_cfg.cfg_timeout(servers) }} | ||
|
||
bind_timelimit {{ ldap_cfg.cfg_bind_timeout(servers) }} |
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,41 @@ | ||
# /etc/nslcd.conf | ||
# nslcd configuration file. See nslcd.conf(5) | ||
# for details. | ||
|
||
# The user and group nslcd should run as. | ||
uid nslcd | ||
gid nslcd | ||
|
||
# The location at which the LDAP server(s) should be reachable. | ||
{{ ldap_cfg.cfg_servers(servers) }} | ||
|
||
# The search base that will be used for all queries. | ||
base {{ ldap_cfg.cfg_base(servers) }} | ||
|
||
|
||
# The LDAP protocol version to use. | ||
ldap_version {{ ldap_cfg.cfg_version(servers) }} | ||
|
||
# The DN to bind with for normal lookups. | ||
binddn {{ ldap_cfg.cfg_bind(servers) }} | ||
bindpw {{ ldap_cfg.cfg_bindpw(servers) }} | ||
|
||
# The DN used for password modifications by root. | ||
#rootpwmoddn cn=admin,dc=example,dc=com | ||
|
||
# SSL options | ||
#ssl off | ||
#tls_reqcert never | ||
tls_cacertfile /etc/ssl/certs/ca-certificates.crt | ||
|
||
# The search scope. | ||
scope {{ ldap_cfg.cfg_scope(servers) }} | ||
|
||
timelimit {{ ldap_cfg.cfg_timeout(servers) }} | ||
|
||
bind_timelimit {{ ldap_cfg.cfg_bind_timeout(servers) }} | ||
|
||
nss_initgroups_ignoreusers ALLLOCAL | ||
|
||
nss_min_uid 1000 | ||
|
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,45 @@ | ||
"""File stat handler""" | ||
|
||
from host_modules import host_service | ||
import subprocess | ||
|
||
MOD_NAME = 'file' | ||
EXIT_FAILURE = 1 | ||
|
||
import os | ||
|
||
class FileService(host_service.HostModule): | ||
""" | ||
Dbus endpoint that executes the file command | ||
""" | ||
@host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='ia{ss}') | ||
def get_file_stat(self, path): | ||
if not path: | ||
return EXIT_FAILURE, {'error': 'Dbus get_file_stat called with no path specified'} | ||
|
||
try: | ||
file_stat = os.stat(path) | ||
|
||
# Get last modified time in nanoseconds since epoch | ||
last_modified = int(file_stat.st_mtime * 1e9) # Convert seconds to nanoseconds | ||
|
||
# Get permissions in octal format | ||
permissions = oct(file_stat.st_mode)[-3:] | ||
|
||
# Get file size in bytes | ||
size = file_stat.st_size | ||
|
||
# Get current umask | ||
current_umask = os.umask(0) | ||
os.umask(current_umask) # Reset umask to previous value | ||
|
||
return 0, { | ||
'path': path, | ||
'last_modified': str(last_modified), # Converting to string to maintain consistency | ||
'permissions': permissions, | ||
'size': str(size), # Converting to string to maintain consistency | ||
'umask': oct(current_umask)[-3:] | ||
} | ||
|
||
except Exception as e: | ||
return EXIT_FAILURE, {'error': str(e)} |
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 |
Oops, something went wrong.