Skip to content

Commit 2088a9a

Browse files
authored
Provide support to install platform extensions (#1578)
cisco-8000 : show commands support as plugins show platform idprom show platform inventory
1 parent c97fe54 commit 2088a9a

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

show/main.py

-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from . import warm_restart
5858
from . import plugins
5959

60-
6160
# Global Variables
6261
PLATFORM_JSON = 'platform.json'
6362
HWSKU_JSON = 'hwsku.json'
@@ -1676,12 +1675,10 @@ def ztp(status, verbose):
16761675
cmd = cmd + " --verbose"
16771676
run_command(cmd, display_cmd=verbose)
16781677

1679-
16801678
# Load plugins and register them
16811679
helper = util_base.UtilHelper()
16821680
for plugin in helper.load_plugins(plugins):
16831681
helper.register_plugin(plugin, cli)
16841682

1685-
16861683
if __name__ == '__main__':
16871684
cli()

show/platform.py

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def temperature():
134134
cmd = 'tempershow'
135135
clicommon.run_command(cmd)
136136

137-
138137
# 'firmware' subcommand ("show platform firmware")
139138
@platform.command(
140139
context_settings=dict(

show/plugins/cisco-8000.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
#########################################################
3+
# Copyright 2021 Cisco Systems, Inc.
4+
# All rights reserved.
5+
#
6+
# CLI Extensions for show command
7+
#########################################################
8+
9+
try:
10+
import click
11+
import yaml
12+
from show import platform
13+
from sonic_py_common import device_info
14+
import utilities_common.cli as clicommon
15+
except ImportError as e:
16+
raise ImportError("%s - required module not found" % str(e))
17+
18+
PLATFORM_PY = '/opt/cisco/bin/platform.py'
19+
20+
@click.command()
21+
def inventory():
22+
"""Show Platform Inventory"""
23+
args = [ PLATFORM_PY, 'inventoryshow' ]
24+
clicommon.run_command(args)
25+
26+
@click.command()
27+
def idprom():
28+
"""Show Platform Idprom Inventory"""
29+
args = [ PLATFORM_PY, 'idprom' ]
30+
clicommon.run_command(args)
31+
32+
def register(cli):
33+
version_info = device_info.get_sonic_version_info()
34+
if (version_info and version_info.get('asic_type') == 'cisco-8000'):
35+
cli.commands['platform'].add_command(inventory)
36+
cli.commands['platform'].add_command(idprom)

0 commit comments

Comments
 (0)