diff --git a/config/chassis_modules.py b/config/chassis_modules.py index 4e7fd8096b..0699a6f766 100755 --- a/config/chassis_modules.py +++ b/config/chassis_modules.py @@ -5,6 +5,7 @@ import re import subprocess import utilities_common.cli as clicommon +from utilities_common.chassis import is_smartswitch, get_all_dpus TIMEOUT_SECS = 10 @@ -27,7 +28,10 @@ def get_config_module_state(db, chassis_module_name): config_db = db.cfgdb fvs = config_db.get_entry('CHASSIS_MODULE', chassis_module_name) if not fvs: - return 'up' + if is_smartswitch(): + return 'down' + else: + return 'up' else: return fvs['admin_status'] @@ -102,7 +106,11 @@ def fabric_module_set_admin_status(db, chassis_module_name, state): # @modules.command('shutdown') @clicommon.pass_db -@click.argument('chassis_module_name', metavar='', required=True) +@click.argument('chassis_module_name', + metavar='', + required=True, + type=click.Choice(get_all_dpus(), case_sensitive=False) if is_smartswitch() else str + ) def shutdown_chassis_module(db, chassis_module_name): """Chassis-module shutdown of module""" config_db = db.cfgdb @@ -110,8 +118,9 @@ def shutdown_chassis_module(db, chassis_module_name): if not chassis_module_name.startswith("SUPERVISOR") and \ not chassis_module_name.startswith("LINE-CARD") and \ - not chassis_module_name.startswith("FABRIC-CARD"): - ctx.fail("'module_name' has to begin with 'SUPERVISOR', 'LINE-CARD' or 'FABRIC-CARD'") + not chassis_module_name.startswith("FABRIC-CARD") and \ + not chassis_module_name.startswith("DPU"): + ctx.fail("'module_name' has to begin with 'SUPERVISOR', 'LINE-CARD', 'FABRIC-CARD', 'DPU'") # To avoid duplicate operation if get_config_module_state(db, chassis_module_name) == 'down': @@ -130,7 +139,11 @@ def shutdown_chassis_module(db, chassis_module_name): # @modules.command('startup') @clicommon.pass_db -@click.argument('chassis_module_name', metavar='', required=True) +@click.argument('chassis_module_name', + metavar='', + required=True, + type=click.Choice(get_all_dpus(), case_sensitive=False) if is_smartswitch() else str + ) def startup_chassis_module(db, chassis_module_name): """Chassis-module startup of module""" config_db = db.cfgdb @@ -142,7 +155,12 @@ def startup_chassis_module(db, chassis_module_name): return click.echo("Starting up chassis module {}".format(chassis_module_name)) - config_db.set_entry('CHASSIS_MODULE', chassis_module_name, None) + if is_smartswitch(): + fvs = {'admin_status': 'up'} + config_db.set_entry('CHASSIS_MODULE', chassis_module_name, fvs) + else: + config_db.set_entry('CHASSIS_MODULE', chassis_module_name, None) + if chassis_module_name.startswith("FABRIC-CARD"): if not check_config_module_state_with_timeout(ctx, db, chassis_module_name, 'up'): fabric_module_set_admin_status(db, chassis_module_name, 'up') diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 689ca23b73..f5bc34b7ca 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -708,11 +708,52 @@ This command displays the cause of the previous reboot ``` - Example: + ### Shown below is the output of the CLI when executed on the NPU ``` admin@sonic:~$ show reboot-cause User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] ``` + ### Shown below is the output of the CLI when executed on the DPU + ``` + admin@sonic:~$ show reboot-cause + reboot + ``` +``` +Note: The CLI extensions shown in this block are applicable only to smartswitch platforms. When these extensions are used on a regular switch the extension will be ignored and the output will be the same irrespective of the options. + +CLI Extensions Applicable to Smartswtich + - show reboot-cause all + - show reboot-cause history all + - show reboot-cause history DPUx +``` +**show reboot-cause all** + +This command displays the cause of the previous reboot for the Switch and the DPUs for which the midplane interfaces are up. + +- Usage: + ``` + show reboot-cause all + ``` + +- Example: + ### Shown below is the output of the CLI when executed on the NPU + ``` + root@MtFuji:/home/cisco# show reboot-cause all + Device Name Cause Time User + -------- ------------------- ------------ ------------------------------- ------ + NPU 2025_01_21_09_01_11 Power Loss N/A N/A + DPU1 2025_01_21_09_03_43 Non-Hardware Tue Jan 21 09:03:43 AM UTC 2025 + DPU0 2025_01_21_09_03_37 Non-Hardware Tue Jan 21 09:03:37 AM UTC 2025 + ``` + ### Shown below is the output of the CLI when executed on the DPU + ``` + root@sonic:/home/admin# show reboot-cause all + Usage: show reboot-cause [OPTIONS] COMMAND [ARGS]... + Try "show reboot-cause -h" for help. + + Error: No such command "all". + ``` **show reboot-cause history** This command displays the history of the previous reboots up to 10 entry @@ -723,15 +764,74 @@ This command displays the history of the previous reboots up to 10 entry ``` - Example: + ### Shown below is the output of the CLI when executed on the NPU ``` - admin@sonic:~$ show reboot-cause history - Name Cause Time User Comment - ------------------- ----------- ---------------------------- ------ --------- - 2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin + root@MtFuji:/home/cisco# show reboot-cause history + Name Cause Time User Comment + ------------------- ---------- ------ ------ ---------------------------------------------------------------------------------- + 2020_10_09_02_40_11 Power Loss Fri Oct 9 02:40:11 UTC 2020 N/A Unknown (First boot of SONiC version azure_cisco_master.308-dirty-20250120.220704) 2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin - 2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin - 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin ``` + ### Shown below is the output of the CLI when executed on the DPU + ``` + root@sonic:/home/admin# show reboot-cause history + Name Cause Time User Comment + ------------------- ------- ------------------------------- ------ --------- + 2025_01_21_16_49_20 Unknown N/A N/A N/A + 2025_01_17_11_25_58 reboot Fri Jan 17 11:23:24 AM UTC 2025 admin N/A + ``` +**show reboot-cause history all** + +This command displays the history of the previous reboots up to 10 entry of the Switch and the DPUs for which the midplane interfaces are up. + +- Usage: + ``` + show reboot-cause history all + ``` + +- Example: + ### Shown below is the output of the CLI when executed on the NPU + ``` + root@MtFuji:~# show reboot-cause history all + Device Name Cause Time User Comment + -------- ------------------- ----------------------------------------- ------------------------------- ------ ------- + NPU 2024_07_23_23_06_57 Kernel Panic Tue Jul 23 11:02:27 PM UTC 2024 N/A N/A + NPU 2024_07_23_11_21_32 Power Loss N/A N/A Unknown + ``` + ### Shown below is the output of the CLI when executed on the DPU + ``` + root@sonic:/home/admin# show reboot-cause history all + Usage: show reboot-cause history [OPTIONS] + Try "show reboot-cause history -h" for help. + + Error: Got unexpected extra argument (all) + ``` +**show reboot-cause history DPU1** + +This command displays the history of the previous reboots up to 10 entry of DPU1. If DPU1 is powered down then there won't be any data in the DB and the "show reboot-cause history DPU1" output will be blank. + +- Usage: + ``` + show reboot-cause history DPU1 + ``` + +- Example: + ### Shown below is the output of the CLI when executed on the NPU + ``` + root@MtFuji:~# show reboot-cause history DPU1 + Device Name Cause Time User Comment + -------- ------ ----------------------------------------- ------ ------ --------- + DPU1 DPU1 Software causes (Hardware watchdog reset) N/A N/A N/A + ``` + ### Shown below is the output of the CLI when executed on the DPU + ``` + root@sonic:/home/admin# show reboot-cause history DPU1 + Usage: show reboot-cause history [OPTIONS] + Try "show reboot-cause history -h" for help. + + Error: Got unexpected extra argument (DPU1) + ``` + **show uptime** @@ -11165,6 +11265,36 @@ In addition, displays a list of all current 'Services' and 'Hardware' being moni psu.voltage Ignored Device ``` +**show system-health dpu