From 2088a9adad64e73034d4bb83eddb0ab8351eccba Mon Sep 17 00:00:00 2001 From: VenkatCisco <77468614+VenkatCisco@users.noreply.github.com> Date: Mon, 20 Sep 2021 12:37:25 -0700 Subject: [PATCH] Provide support to install platform extensions (#1578) cisco-8000 : show commands support as plugins show platform idprom show platform inventory --- show/main.py | 3 --- show/platform.py | 1 - show/plugins/cisco-8000.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 show/plugins/cisco-8000.py diff --git a/show/main.py b/show/main.py index f6c49cbe61c4..fec0ccde69fe 100755 --- a/show/main.py +++ b/show/main.py @@ -57,7 +57,6 @@ from . import warm_restart from . import plugins - # Global Variables PLATFORM_JSON = 'platform.json' HWSKU_JSON = 'hwsku.json' @@ -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() diff --git a/show/platform.py b/show/platform.py index e70b4e92e108..c713472080a7 100644 --- a/show/platform.py +++ b/show/platform.py @@ -134,7 +134,6 @@ def temperature(): cmd = 'tempershow' clicommon.run_command(cmd) - # 'firmware' subcommand ("show platform firmware") @platform.command( context_settings=dict( diff --git a/show/plugins/cisco-8000.py b/show/plugins/cisco-8000.py new file mode 100644 index 000000000000..c3e5e0327b00 --- /dev/null +++ b/show/plugins/cisco-8000.py @@ -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)