Skip to content

Commit

Permalink
Provide support to install platform extensions (#1578)
Browse files Browse the repository at this point in the history
cisco-8000 : show commands support as plugins
show platform idprom
show platform inventory
  • Loading branch information
VenkatCisco authored Sep 20, 2021
1 parent c97fe54 commit 2088a9a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
3 changes: 0 additions & 3 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
from . import warm_restart
from . import plugins


# Global Variables
PLATFORM_JSON = 'platform.json'
HWSKU_JSON = 'hwsku.json'
Expand Down Expand Up @@ -1676,12 +1675,10 @@ def ztp(status, verbose):
cmd = cmd + " --verbose"
run_command(cmd, display_cmd=verbose)


# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
helper.register_plugin(plugin, cli)


if __name__ == '__main__':
cli()
1 change: 0 additions & 1 deletion show/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def temperature():
cmd = 'tempershow'
clicommon.run_command(cmd)


# 'firmware' subcommand ("show platform firmware")
@platform.command(
context_settings=dict(
Expand Down
36 changes: 36 additions & 0 deletions show/plugins/cisco-8000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
#########################################################
# Copyright 2021 Cisco Systems, Inc.
# All rights reserved.
#
# CLI Extensions for show command
#########################################################

try:
import click
import yaml
from show import platform
from sonic_py_common import device_info
import utilities_common.cli as clicommon
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))

PLATFORM_PY = '/opt/cisco/bin/platform.py'

@click.command()
def inventory():
"""Show Platform Inventory"""
args = [ PLATFORM_PY, 'inventoryshow' ]
clicommon.run_command(args)

@click.command()
def idprom():
"""Show Platform Idprom Inventory"""
args = [ PLATFORM_PY, 'idprom' ]
clicommon.run_command(args)

def register(cli):
version_info = device_info.get_sonic_version_info()
if (version_info and version_info.get('asic_type') == 'cisco-8000'):
cli.commands['platform'].add_command(inventory)
cli.commands['platform'].add_command(idprom)

0 comments on commit 2088a9a

Please sign in to comment.