From 2764c6c82cbc88eb778ed87e33652bf4207b20d8 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Tue, 16 Jul 2019 06:35:05 +0800 Subject: [PATCH] [Mellanox] Improve the prompt of the Mellanox sdk sniffer command. (#546) * [config/mlnx.py] Prompt the risk of excessive consumption of disk space when user intends to turn on the sdk sniffer. The SDK sniffer is a diagnosis feature, introduced with a view to recording the all the operations to SDK into the sniffer file which the low level team can replay and investigate. Only the sniffer file contains all the operations from SWSS restart does it help. To handle it in a way like log-rotate can hurt its integrity since the operations can be lost during rotating and to address this requires big effort. So we just add a promot of that risk for now. * [config/mlnx.py] adjust prompt. adjust prompt in order to make it more clear. * [config/mlnx.py] adjust prompt. adjust prompt in order to make it more clear. (recommit this in order to trigger vstest of the sonic-utilities and check whether it can pass) --- config/mlnx.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/config/mlnx.py b/config/mlnx.py index caa8cd0de43f..330dd41ac359 100644 --- a/config/mlnx.py +++ b/config/mlnx.py @@ -198,21 +198,33 @@ def sniffer(): # 'sdk' subgroup -@sniffer.command() -@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False, - prompt='To change SDK sniffer status, swss service will be restarted, continue?') -@click.argument('option', type=click.Choice(["enable", "disable"])) -def sdk(option): +@sniffer.group() +def sdk(): """SDK Sniffer - Command Line to enable/disable SDK sniffer""" - if option == 'enable': - sdk_sniffer_enable() - elif option == 'disable': - sdk_sniffer_disable() + pass -def sdk_sniffer_enable(): +@sdk.command() +@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False, + prompt='Swss service will be restarted, continue?') +def enable(): """Enable SDK Sniffer""" print "Enabling SDK sniffer" + sdk_sniffer_enable() + print "Note: the sniffer file may exhaust the space on /var/log, please disable it when you are done with this sniffering." + + +@sdk.command() +@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False, + prompt='Swss service will be restarted, continue?') +def disable(): + """Disable SDK Sniffer""" + print "Disabling SDK sniffer" + sdk_sniffer_disable() + + +def sdk_sniffer_enable(): + """Enable SDK Sniffer""" sdk_sniffer_filename = sniffer_filename_generate(SDK_SNIFFER_TARGET_PATH, SDK_SNIFFER_FILENAME_PREFIX, SDK_SNIFFER_FILENAME_EXT) @@ -231,21 +243,20 @@ def sdk_sniffer_enable(): err = restart_swss() if err is not 0: return - print 'Enabled SDK sniffer, recording file is %s' % sdk_sniffer_filename + print 'SDK sniffer is Enabled, recording file is %s.' % sdk_sniffer_filename else: pass def sdk_sniffer_disable(): """Disable SDK Sniffer""" - print "Disabling SDK sniffer" ignore = sniffer_env_variable_set(enable=False, env_variable_name=ENV_VARIABLE_SX_SNIFFER) if not ignore: err = restart_swss() if err is not 0: return - print "Disabled SDK sniffer" + print "SDK sniffer is Disabled." else: pass