Skip to content

Commit

Permalink
[Mellanox] Improve the prompt of the Mellanox sdk sniffer command. (s…
Browse files Browse the repository at this point in the history
…onic-net#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)
  • Loading branch information
stephenxs authored and liat-grozovik committed Jul 15, 2019
1 parent 5a5b74d commit 2764c6c
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions config/mlnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 2764c6c

Please sign in to comment.