Skip to content

Commit 2764c6c

Browse files
stephenxsliat-grozovik
authored andcommitted
[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)
1 parent 5a5b74d commit 2764c6c

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

config/mlnx.py

+24-13
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,33 @@ def sniffer():
198198

199199

200200
# 'sdk' subgroup
201-
@sniffer.command()
202-
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False,
203-
prompt='To change SDK sniffer status, swss service will be restarted, continue?')
204-
@click.argument('option', type=click.Choice(["enable", "disable"]))
205-
def sdk(option):
201+
@sniffer.group()
202+
def sdk():
206203
"""SDK Sniffer - Command Line to enable/disable SDK sniffer"""
207-
if option == 'enable':
208-
sdk_sniffer_enable()
209-
elif option == 'disable':
210-
sdk_sniffer_disable()
204+
pass
211205

212206

213-
def sdk_sniffer_enable():
207+
@sdk.command()
208+
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False,
209+
prompt='Swss service will be restarted, continue?')
210+
def enable():
214211
"""Enable SDK Sniffer"""
215212
print "Enabling SDK sniffer"
213+
sdk_sniffer_enable()
214+
print "Note: the sniffer file may exhaust the space on /var/log, please disable it when you are done with this sniffering."
215+
216+
217+
@sdk.command()
218+
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False,
219+
prompt='Swss service will be restarted, continue?')
220+
def disable():
221+
"""Disable SDK Sniffer"""
222+
print "Disabling SDK sniffer"
223+
sdk_sniffer_disable()
224+
225+
226+
def sdk_sniffer_enable():
227+
"""Enable SDK Sniffer"""
216228
sdk_sniffer_filename = sniffer_filename_generate(SDK_SNIFFER_TARGET_PATH,
217229
SDK_SNIFFER_FILENAME_PREFIX,
218230
SDK_SNIFFER_FILENAME_EXT)
@@ -231,21 +243,20 @@ def sdk_sniffer_enable():
231243
err = restart_swss()
232244
if err is not 0:
233245
return
234-
print 'Enabled SDK sniffer, recording file is %s' % sdk_sniffer_filename
246+
print 'SDK sniffer is Enabled, recording file is %s.' % sdk_sniffer_filename
235247
else:
236248
pass
237249

238250

239251
def sdk_sniffer_disable():
240252
"""Disable SDK Sniffer"""
241-
print "Disabling SDK sniffer"
242253

243254
ignore = sniffer_env_variable_set(enable=False, env_variable_name=ENV_VARIABLE_SX_SNIFFER)
244255
if not ignore:
245256
err = restart_swss()
246257
if err is not 0:
247258
return
248-
print "Disabled SDK sniffer"
259+
print "SDK sniffer is Disabled."
249260
else:
250261
pass
251262

0 commit comments

Comments
 (0)