-
Notifications
You must be signed in to change notification settings - Fork 647
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,6 +357,43 @@ class SFPShow(object): | |
|
||
def display_eeprom(self): | ||
click.echo(self.output) | ||
|
||
@multi_asic_util.run_on_multi_asic | ||
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')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'] | ||
|
@@ -369,6 +406,22 @@ def cli(): | |
"""sfpshow - Command line utility for display SFP transceivers information""" | ||
pass | ||
|
||
# 'summary' subcommand | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
@click.option('-p', '--port', metavar='<port_name>', help="Display SFP EEPROM data for port <port_name> only") | ||
|
There was a problem hiding this comment.
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