Skip to content

Commit

Permalink
[CLI][show][platform] Added ASIC count in the output. (sonic-net#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
smaheshm committed Nov 10, 2020
1 parent 1a949ca commit 9fc5c75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 12 additions & 4 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from swsssdk import SonicV2Connector
from tabulate import tabulate
import mlnx
import utilities_common.cli as clicommon
import utilities_common.multi_asic as multi_asic_util

SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen'
Expand Down Expand Up @@ -1509,6 +1510,7 @@ def get_hw_info_dict():
hw_info_dict['platform'] = device_info.get_platform()
hw_info_dict['hwsku'] = device_info.get_hwsku()
hw_info_dict['asic_type'] = version_info['asic_type']
hw_info_dict['asic_count'] = device_info.get_num_npus()

return hw_info_dict

Expand All @@ -1523,12 +1525,18 @@ def platform():

# 'summary' subcommand ("show platform summary")
@platform.command()
def summary():
@click.option('--json', is_flag=True, help="JSON output")
def summary(json):
"""Show hardware platform information"""

hw_info_dict = get_hw_info_dict()
click.echo("Platform: {}".format(hw_info_dict['platform']))
click.echo("HwSKU: {}".format(hw_info_dict['hwsku']))
click.echo("ASIC: {}".format(hw_info_dict['asic_type']))
if json:
click.echo(clicommon.json_dump(hw_info_dict))
else:
click.echo("Platform: {}".format(hw_info_dict['platform']))
click.echo("HwSKU: {}".format(hw_info_dict['hwsku']))
click.echo("ASIC: {}".format(hw_info_dict['asic_type']))
click.echo("ASIC Count: {}".format(hw_info_dict['asic_count']))

# 'syseeprom' subcommand ("show platform syseeprom")
@platform.command()
Expand Down
9 changes: 9 additions & 0 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import json

def json_dump(data):
"""
Dump data in JSON format
"""
return json.dumps(
data, sort_keys=True, indent=2, ensure_ascii=False
)

0 comments on commit 9fc5c75

Please sign in to comment.