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..0a187450bc 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -713,6 +713,32 @@ This command displays the cause of the previous reboot User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] ``` +``` +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: + ``` + root@MtFuji:~$ show reboot-cause all + Device Name Cause Time User + -------- ------------------- ---------- ------ ------ + NPU 2024_07_24_20_43_22 Power Loss N/A N/A + DPU2 2024_07_24_20_43_22 Software causes (Reboot) N/A N/A + DPU1 2024_07_24_20_43_22 Software causes (Reboot) N/A N/A + ``` **show reboot-cause history** This command displays the history of the previous reboots up to 10 entry @@ -733,6 +759,42 @@ This command displays the history of the previous reboots up to 10 entry 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin ``` +**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: + ``` + 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 + ``` + +**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: + ``` + 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 + ``` + + **show uptime** This command displays the current system uptime @@ -11165,6 +11227,36 @@ In addition, displays a list of all current 'Services' and 'Hardware' being moni psu.voltage Ignored Device ``` +**show system-health dpu