Skip to content

Commit 284de91

Browse files
committed
Merge branch 'master' into dev-reset-local-users-password
2 parents bfc284a + 5086a43 commit 284de91

File tree

216 files changed

+21946
-3671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+21946
-3671
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ A convenient alternative is to let the SONiC build system configure a build envi
5151
5252
2. Build the sonic-utilities Python wheel package inside the Bullseye slave container, and tell the build system to keep the container alive when finished
5353
```
54-
make NOSTRETCH=1 NOBUSTER=1 KEEP_SLAVE_ON=yes target/python-wheels/bullseye/sonic_utilities-1.2-py3-none-any.whl
54+
make -f Makefile.work BLDENV=bookworm KEEP_SLAVE_ON=yes target/python-wheels/bookworm/sonic_utilities-1.2-py3-none-any.whl
5555
```
5656
5757
3. When the build finishes, your prompt will change to indicate you are inside the slave container. Change into the `src/sonic-utilities/` directory
@@ -66,13 +66,20 @@ A convenient alternative is to let the SONiC build system configure a build envi
6666
```
6767
python3 setup.py bdist_wheel
6868
```
69+
Note: This command by default will not update the wheel package in target/. To specify the destination location of wheel package, use "-d" option.
6970
7071
#### To run unit tests
7172
7273
```
7374
python3 setup.py test
7475
```
7576
77+
#### To install the package on a SONiC machine
78+
```
79+
sudo pip uninstall sonic-utilities
80+
sudo pip install YOUR_WHEEL_PACKAGE
81+
```
82+
Note: Don't use "--force-reinstall".
7683
7784
### sonic-utilities-data
7885

azure-pipelines.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ stages:
2727
displayName: "Static Analysis"
2828
timeoutInMinutes: 10
2929
continueOnError: true
30-
pool: ubuntu-20.04
30+
pool: sonic-ubuntu-1c
3131
steps:
3232
- template: .azure-pipelines/pre-commit-check.yml
3333

@@ -46,6 +46,13 @@ stages:
4646
image: sonicdev-microsoft.azurecr.io:443/sonic-slave-bullseye:$(BUILD_BRANCH)
4747

4848
steps:
49+
- script: |
50+
set -ex
51+
sudo apt-get update
52+
sudo apt-get install -y python3-pip
53+
sudo pip3 install requests==2.31.0
54+
displayName: "Install dependencies"
55+
4956
- script: |
5057
sourceBranch=$(Build.SourceBranchName)
5158
if [[ "$(Build.Reason)" == "PullRequest" ]];then
@@ -114,7 +121,7 @@ stages:
114121
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
115122
sudo apt-add-repository https://packages.microsoft.com/debian/11/prod
116123
sudo apt-get update
117-
sudo apt-get install -y dotnet-sdk-5.0
124+
sudo apt-get install -y dotnet-sdk-8.0
118125
displayName: "Install .NET CORE"
119126
120127
- script: |

clear/main.py

Lines changed: 151 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from show.plugins.pbh import read_pbh_counters
1313
from config.plugins.pbh import serialize_pbh_counters
1414
from . import plugins
15-
15+
from . import stp
1616
# This is from the aliases example:
1717
# https://github.com/pallets/click/blob/57c6f09611fc47ca80db0bd010f05998b3c0aa95/examples/aliases/aliases.py
1818
class Config(object):
@@ -145,6 +145,10 @@ def ipv6():
145145
pass
146146

147147

148+
# 'STP'
149+
#
150+
cli.add_command(stp.spanning_tree)
151+
148152
#
149153
# Inserting BGP functionality into cli's clear parse-chain.
150154
# BGP commands are determined by the routing-stack being elected.
@@ -229,16 +233,38 @@ def watermark():
229233
if os.geteuid() != 0:
230234
sys.exit("Root privileges are required for this operation")
231235

236+
237+
@click.option('--namespace',
238+
'-n',
239+
'namespace',
240+
default=None,
241+
type=str,
242+
show_default=True,
243+
help='Namespace name or all',
244+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
232245
@watermark.command('headroom')
233-
def clear_wm_pg_headroom():
246+
def clear_wm_pg_headroom(namespace):
234247
"""Clear user headroom WM for pg"""
235248
command = ['watermarkstat', '-c', '-t', 'pg_headroom']
249+
if namespace:
250+
command += ['-n', str(namespace)]
236251
run_command(command)
237252

253+
238254
@watermark.command('shared')
239-
def clear_wm_pg_shared():
255+
@click.option('--namespace',
256+
'-n',
257+
'namespace',
258+
default=None,
259+
type=str,
260+
show_default=True,
261+
help='Namespace name or all',
262+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
263+
def clear_wm_pg_shared(namespace):
240264
"""Clear user shared WM for pg"""
241265
command = ['watermarkstat', '-c', '-t', 'pg_shared']
266+
if namespace:
267+
command += ['-n', str(namespace)]
242268
run_command(command)
243269

244270
@priority_group.group()
@@ -261,16 +287,38 @@ def persistent_watermark():
261287
if os.geteuid() != 0:
262288
sys.exit("Root privileges are required for this operation")
263289

290+
264291
@persistent_watermark.command('headroom')
265-
def clear_pwm_pg_headroom():
292+
@click.option('--namespace',
293+
'-n',
294+
'namespace',
295+
default=None,
296+
type=str,
297+
show_default=True,
298+
help='Namespace name or all',
299+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
300+
def clear_pwm_pg_headroom(namespace):
266301
"""Clear persistent headroom WM for pg"""
267302
command = ['watermarkstat', '-c', '-p', '-t', 'pg_headroom']
303+
if namespace:
304+
command += ['-n', str(namespace)]
268305
run_command(command)
269306

307+
270308
@persistent_watermark.command('shared')
271-
def clear_pwm_pg_shared():
309+
@click.option('--namespace',
310+
'-n',
311+
'namespace',
312+
default=None,
313+
type=str,
314+
show_default=True,
315+
help='Namespace name or all',
316+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
317+
def clear_pwm_pg_shared(namespace):
272318
"""Clear persistent shared WM for pg"""
273319
command = ['watermarkstat', '-c', '-p', '-t', 'pg_shared']
320+
if namespace:
321+
command += ['-n', str(namespace)]
274322
run_command(command)
275323

276324

@@ -285,69 +333,159 @@ def watermark():
285333
if os.geteuid() != 0:
286334
sys.exit("Root privileges are required for this operation")
287335

336+
288337
@watermark.command('unicast')
289-
def clear_wm_q_uni():
338+
@click.option('--namespace',
339+
'-n',
340+
'namespace',
341+
default=None,
342+
type=str,
343+
show_default=True,
344+
help='Namespace name or all',
345+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
346+
def clear_wm_q_uni(namespace):
290347
"""Clear user WM for unicast queues"""
291348
command = ['watermarkstat', '-c', '-t', 'q_shared_uni']
349+
if namespace:
350+
command += ['-n', str(namespace)]
292351
run_command(command)
293352

353+
294354
@watermark.command('multicast')
295-
def clear_wm_q_multi():
355+
@click.option('--namespace',
356+
'-n',
357+
'namespace',
358+
default=None,
359+
type=str,
360+
show_default=True,
361+
help='Namespace name or all',
362+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
363+
def clear_wm_q_multi(namespace):
296364
"""Clear user WM for multicast queues"""
297365
command = ['watermarkstat', '-c', '-t', 'q_shared_multi']
366+
if namespace:
367+
command += ['-n', str(namespace)]
298368
run_command(command)
299369

370+
300371
@watermark.command('all')
301-
def clear_wm_q_all():
372+
@click.option('--namespace',
373+
'-n',
374+
'namespace',
375+
default=None,
376+
type=str,
377+
show_default=True,
378+
help='Namespace name or all',
379+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
380+
def clear_wm_q_all(namespace):
302381
"""Clear user WM for all queues"""
303382
command = ['watermarkstat', '-c', '-t', 'q_shared_all']
383+
if namespace:
384+
command += ['-n', str(namespace)]
304385
run_command(command)
305386

387+
306388
@queue.group(name='persistent-watermark')
307389
def persistent_watermark():
308390
"""Clear queue persistent WM. One does not simply clear WM, root is required"""
309391
if os.geteuid() != 0:
310392
sys.exit("Root privileges are required for this operation")
311393

394+
312395
@persistent_watermark.command('unicast')
313-
def clear_pwm_q_uni():
396+
@click.option('--namespace',
397+
'-n',
398+
'namespace',
399+
default=None,
400+
type=str,
401+
show_default=True,
402+
help='Namespace name or all',
403+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
404+
def clear_pwm_q_uni(namespace):
314405
"""Clear persistent WM for persistent queues"""
315406
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_uni']
407+
if namespace:
408+
command += ['-n', str(namespace)]
316409
run_command(command)
317410

411+
318412
@persistent_watermark.command('multicast')
319-
def clear_pwm_q_multi():
413+
@click.option('--namespace',
414+
'-n',
415+
'namespace',
416+
default=None,
417+
type=str,
418+
show_default=True,
419+
help='Namespace name or all',
420+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
421+
def clear_pwm_q_multi(namespace):
320422
"""Clear persistent WM for multicast queues"""
321423
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_multi']
424+
if namespace:
425+
command += ['-n', str(namespace)]
322426
run_command(command)
323427

428+
324429
@persistent_watermark.command('all')
325-
def clear_pwm_q_all():
430+
@click.option('--namespace',
431+
'-n',
432+
'namespace',
433+
default=None,
434+
type=str,
435+
show_default=True,
436+
help='Namespace name or all',
437+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
438+
def clear_pwm_q_all(namespace):
326439
"""Clear persistent WM for all queues"""
327440
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_all']
441+
if namespace:
442+
command += ['-n', str(namespace)]
328443
run_command(command)
329444

445+
330446
@cli.group(name='headroom-pool')
331447
def headroom_pool():
332448
"""Clear headroom pool WM"""
333449
pass
334450

451+
335452
@headroom_pool.command('watermark')
336-
def watermark():
453+
@click.option('--namespace',
454+
'-n',
455+
'namespace',
456+
default=None,
457+
type=str,
458+
show_default=True,
459+
help='Namespace name or all',
460+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
461+
def watermark(namespace):
337462
"""Clear headroom pool user WM. One does not simply clear WM, root is required"""
338463
if os.geteuid() != 0:
339464
sys.exit("Root privileges are required for this operation")
340465

341466
command = ['watermarkstat', '-c', '-t', 'headroom_pool']
467+
if namespace:
468+
command += ['-n', str(namespace)]
342469
run_command(command)
343470

471+
344472
@headroom_pool.command('persistent-watermark')
345-
def persistent_watermark():
473+
@click.option('--namespace',
474+
'-n',
475+
'namespace',
476+
default=None,
477+
type=str,
478+
show_default=True,
479+
help='Namespace name or all',
480+
callback=multi_asic_util.multi_asic_namespace_validation_callback)
481+
def persistent_watermark(namespace):
346482
"""Clear headroom pool persistent WM. One does not simply clear WM, root is required"""
347483
if os.geteuid() != 0:
348484
sys.exit("Root privileges are required for this operation")
349485

350486
command = ['watermarkstat', '-c', '-p', '-t', 'headroom_pool']
487+
if namespace:
488+
command += ['-n', str(namespace)]
351489
run_command(command)
352490

353491
#

clear/stp.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import click
2+
import utilities_common.cli as clicommon
3+
4+
#
5+
# This group houses Spanning_tree commands and subgroups
6+
#
7+
8+
9+
@click.group(cls=clicommon.AliasedGroup)
10+
@click.pass_context
11+
def spanning_tree(ctx):
12+
'''Clear Spanning-tree counters'''
13+
pass
14+
15+
16+
@spanning_tree.group('statistics', cls=clicommon.AliasedGroup, invoke_without_command=True)
17+
@click.pass_context
18+
def stp_clr_stats(ctx):
19+
if ctx.invoked_subcommand is None:
20+
command = 'sudo stpctl clrstsall'
21+
clicommon.run_command(command)
22+
23+
24+
@stp_clr_stats.command('interface')
25+
@click.argument('interface_name', metavar='<interface_name>', required=True)
26+
@click.pass_context
27+
def stp_clr_stats_intf(ctx, interface_name):
28+
command = 'sudo stpctl clrstsintf ' + interface_name
29+
clicommon.run_command(command)
30+
31+
32+
@stp_clr_stats.command('vlan')
33+
@click.argument('vlan_id', metavar='<vlan_id>', required=True)
34+
@click.pass_context
35+
def stp_clr_stats_vlan(ctx, vlan_id):
36+
command = 'sudo stpctl clrstsvlan ' + vlan_id
37+
clicommon.run_command(command)
38+
39+
40+
@stp_clr_stats.command('vlan-interface')
41+
@click.argument('vlan_id', metavar='<vlan_id>', required=True)
42+
@click.argument('interface_name', metavar='<interface_name>', required=True)
43+
@click.pass_context
44+
def stp_clr_stats_vlan_intf(ctx, vlan_id, interface_name):
45+
command = 'sudo stpctl clrstsvlanintf ' + vlan_id + ' ' + interface_name
46+
clicommon.run_command(command)

0 commit comments

Comments
 (0)