Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sonic-net/sonic-utilities into fe…
Browse files Browse the repository at this point in the history
…at_poe
  • Loading branch information
SerhiyBoikoPLV committed Oct 31, 2024
2 parents 3a37fb8 + 329fc22 commit b866427
Show file tree
Hide file tree
Showing 103 changed files with 8,095 additions and 1,687 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ stages:
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-add-repository https://packages.microsoft.com/debian/11/prod
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
sudo apt-get install -y dotnet-sdk-8.0
displayName: "Install .NET CORE"
- script: |
Expand Down
158 changes: 146 additions & 12 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,38 @@ def watermark():
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
@watermark.command('headroom')
def clear_wm_pg_headroom():
def clear_wm_pg_headroom(namespace):
"""Clear user headroom WM for pg"""
command = ['watermarkstat', '-c', '-t', 'pg_headroom']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('shared')
def clear_wm_pg_shared():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_pg_shared(namespace):
"""Clear user shared WM for pg"""
command = ['watermarkstat', '-c', '-t', 'pg_shared']
if namespace:
command += ['-n', str(namespace)]
run_command(command)

@priority_group.group()
Expand All @@ -261,16 +283,38 @@ def persistent_watermark():
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@persistent_watermark.command('headroom')
def clear_pwm_pg_headroom():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_pg_headroom(namespace):
"""Clear persistent headroom WM for pg"""
command = ['watermarkstat', '-c', '-p', '-t', 'pg_headroom']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('shared')
def clear_pwm_pg_shared():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_pg_shared(namespace):
"""Clear persistent shared WM for pg"""
command = ['watermarkstat', '-c', '-p', '-t', 'pg_shared']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


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


@watermark.command('unicast')
def clear_wm_q_uni():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_uni(namespace):
"""Clear user WM for unicast queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_uni']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('multicast')
def clear_wm_q_multi():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_multi(namespace):
"""Clear user WM for multicast queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_multi']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('all')
def clear_wm_q_all():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_all(namespace):
"""Clear user WM for all queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_all']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


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


@persistent_watermark.command('unicast')
def clear_pwm_q_uni():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_uni(namespace):
"""Clear persistent WM for persistent queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_uni']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('multicast')
def clear_pwm_q_multi():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_multi(namespace):
"""Clear persistent WM for multicast queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_multi']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('all')
def clear_pwm_q_all():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_all(namespace):
"""Clear persistent WM for all queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_all']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@cli.group(name='headroom-pool')
def headroom_pool():
"""Clear headroom pool WM"""
pass


@headroom_pool.command('watermark')
def watermark():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def watermark(namespace):
"""Clear headroom pool user WM. One does not simply clear WM, root is required"""
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")

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


@headroom_pool.command('persistent-watermark')
def persistent_watermark():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def persistent_watermark(namespace):
"""Clear headroom pool persistent WM. One does not simply clear WM, root is required"""
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")

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

#
Expand Down
8 changes: 4 additions & 4 deletions config/chassis_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def fabric_module_set_admin_status(db, chassis_module_name, state):
if state == "down":
for asic in asic_list:
click.echo("Stop swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl stop swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'stop', 'swss@{}.service'.format(asic)])

is_active = subprocess.call(["systemctl", "is-active", "--quiet", "swss@{}.service".format(asic)])

Expand All @@ -89,13 +89,13 @@ def fabric_module_set_admin_status(db, chassis_module_name, state):
# without bring down the hardware
for asic in asic_list:
# To address systemd service restart limit by resetting the count
clicommon.run_command('sudo systemctl reset-failed swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'reset-failed', 'swss@{}.service'.format(asic)])
click.echo("Start swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl start swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'start', 'swss@{}.service'.format(asic)])
elif state == "up":
for asic in asic_list:
click.echo("Start swss@{} and peer services".format(asic))
clicommon.run_command('sudo systemctl start swss@{}.service'.format(asic))
clicommon.run_command(['sudo', 'systemctl', 'start', 'swss@{}.service'.format(asic)])

#
# 'shutdown' subcommand ('config chassis_modules shutdown ...')
Expand Down
Loading

0 comments on commit b866427

Please sign in to comment.