Skip to content
Merged
2 changes: 1 addition & 1 deletion rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ INCLUDE_MGMT_FRAMEWORK = y

# ENABLE_HOST_SERVICE_ON_START - enable sonic-host-server for mgmt-framework and/or
# telemetry containers to access host functionality by default
ENABLE_HOST_SERVICE_ON_START = n
ENABLE_HOST_SERVICE_ON_START = y
Comment thread
kerry-meyer marked this conversation as resolved.
Outdated

# INCLUDE_RESTAPI - build docker-sonic-restapi for configuring the switch using REST APIs
INCLUDE_RESTAPI = n
Expand Down
55 changes: 55 additions & 0 deletions src/sonic-host-services/host_modules/showtech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Show techsupport command handler"""

import host_service
import subprocess
import re

MOD_NAME = 'showtech'

class Showtech(host_service.HostModule):
"""DBus endpoint that executes the "show techsupport" command
"""
@host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is')
def info(self, date):

ERROR_TAR_FAILED = 5
ERROR_PROCFS_SAVE_FAILED = 6
ERROR_INVALID_ARGUMENT = 10

err_dict = {ERROR_INVALID_ARGUMENT: 'Invalid input: Incorrect DateTime format',
ERROR_TAR_FAILED: 'Failure saving information into compressed output file',
ERROR_PROCFS_SAVE_FAILED: 'Saving of process information failed'}

cmd = ['/usr/local/bin/generate_dump']
if date:
cmd.append("-s")
cmd.append(date)

try:
rc = 0
output = subprocess.check_output(cmd)
Comment thread
kerry-meyer marked this conversation as resolved.
Outdated
Comment thread
kerry-meyer marked this conversation as resolved.
Outdated

except subprocess.CalledProcessError as err:
rc = err.returncode
errmsg = err_dict.get(rc)

if errmsg is None:
output = 'Error: Failure code {:-5}'.format(rc)
else:
output = errmsg

print("%Error: Host side: Failed: " + str(rc))
return rc, output

output_string = output.decode("utf-8")
Comment thread
kerry-meyer marked this conversation as resolved.
Outdated
output_file_match = re.search('\/var\/.*dump.*\.gz', output_string)
if output_file_match is not None:
Comment thread
kerry-meyer marked this conversation as resolved.
Outdated
output_filename = output_file_match.group()
else:
output_filename = ""
return rc, output_filename

def register():
"""Return the class name"""
return Showtech, MOD_NAME

2 changes: 1 addition & 1 deletion src/sonic-mgmt-common
2 changes: 1 addition & 1 deletion src/sonic-mgmt-framework