Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CLI For Ext Media Lib #1156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions scripts/sfpshow
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,42 @@ class SFPShow(object):

def display_eeprom(self):
click.echo(self.output)
@multi_asic_util.run_on_multi_asic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add blank line above this

def display_summary(self, interfacename):
out_put = ''
info_table = []
header = ['Interface' ,'Media Name', 'Max Power(W)', 'Vendor Name','Serial Num.','Part Num.', 'QSA Adapter','Qualified' ]

if interfacename is not None:
if not interfacename.startswith('Ethernet'):
if interfacename.isnumeric():
interfacename = 'Ethernet'+interfacename

sfp_info_dict = self.sdb.get_all(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interfacename))
if sfp_info_dict is None:
sfp_info_dict = dict()
sub = \
[interfacename, sfp_info_dict.get('display_name', 'N/A'), sfp_info_dict.get('power_rating_max', 'N/A'),
sfp_info_dict.get('vendor_name', 'N/A'), sfp_info_dict.get('vendor_serial_number', 'N/A'),
sfp_info_dict.get('vendor_part_number', 'N/A'), sfp_info_dict.get('qsa_adapter', 'N/A'), sfp_info_dict.get('qualified', 'N/A')]
info_table.append(sub)
else:
port_table_keys = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*")
sorted_table_keys = natsorted(port_table_keys)
for i in sorted_table_keys:
interface = re.split(':', i, maxsplit=1)[-1].strip()
if interface and interface.startswith('Ethernet'):
sfp_info_dict = self.db.get_all(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface))
if sfp_info_dict is None:
sfp_info_dict = dict()
sub = \
[interface, sfp_info_dict.get('display_name', 'N/A'), sfp_info_dict.get('power_rating_max', 'N/A'),
sfp_info_dict.get('vendor_name', 'N/A'), sfp_info_dict.get('vendor_serial_number', 'N/A'),
sfp_info_dict.get('vendor_part_number', 'N/A'), sfp_info_dict.get('qsa_adapter', 'N/A'), sfp_info_dict.get('qualified', 'N/A')]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make the "Qualified" field in the show command optional, via a platform.json parameter? Concerned that it may cause confusion among users and vendors if vendors don’t implement it.

info_table.append(sub)
click.echo("\n")
click.echo(tabulate(info_table, header))
click.echo("\n")

def display_presence(self):
header = ['Port', 'Presence']
Expand All @@ -368,6 +404,21 @@ class SFPShow(object):
def cli():
"""sfpshow - Command line utility for display SFP transceivers information"""
pass
# 'summary' subcommand
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add blank line above this

@cli.command()
@click.option('-p', '--port', metavar='<port_name>', help="Display SFP summary data for port <port_name> only")
@click.option('-n', '--namespace', default=None, help="Display interfaces for specific namespace")
def summary(port, namespace):
if port and multi_asic.is_multi_asic() and namespace is None:
try:
ns = multi_asic.get_namespace_for_port(port)
namespace=ns
except Exception:
display_invalid_intf_eeprom(port)
sys.exit(1)

sfp = SFPShow(port, namespace)
sfp.display_summary(port)

# 'eeprom' subcommand
@cli.command()
Expand Down
16 changes: 16 additions & 0 deletions show/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ def transceiver():
"""Show SFP Transceiver information"""
pass

@transceiver.command()
@click.argument('interfacename', required=False)
@click.option('-d', '--dom', 'dump_dom', is_flag=True, help="Also display Digital Optical Monitoring (DOM) data")
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def summary(interfacename, dump_dom, verbose):
"""Show interface transceiver summary information"""
cmd = "sfpshow summary"
if dump_dom:
cmd += " --dom"
if interfacename is not None:
if get_interface_mode() == "alias":
interfacename = iface_alias_converter.alias_to_name(interfacename)

cmd += " -p {}".format(interfacename)
clicommon.run_command(cmd, display_cmd=verbose)

@transceiver.command()
@click.argument('interfacename', required=False)
@click.option('-d', '--dom', 'dump_dom', is_flag=True, help="Also display Digital Optical Monitoring (DOM) data")
Expand Down