|
63 | 63 | 'application_advertisement': 'Application Advertisement'
|
64 | 64 | }
|
65 | 65 |
|
| 66 | +QSFP_DD_DATA_MAP = { |
| 67 | + 'model': 'Vendor PN', |
| 68 | + 'vendor_oui': 'Vendor OUI', |
| 69 | + 'vendor_date': 'Vendor Date Code(YYYY-MM-DD Lot)', |
| 70 | + 'manufacturer': 'Vendor Name', |
| 71 | + 'vendor_rev': 'Vendor Rev', |
| 72 | + 'serial': 'Vendor SN', |
| 73 | + 'type': 'Identifier', |
| 74 | + 'ext_identifier': 'Extended Identifier', |
| 75 | + 'ext_rateselect_compliance': 'Extended RateSelect Compliance', |
| 76 | + 'cable_length': 'cable_length', |
| 77 | + 'cable_type': 'Length', |
| 78 | + 'nominal_bit_rate': 'Nominal Bit Rate(100Mbs)', |
| 79 | + 'specification_compliance': 'Specification compliance', |
| 80 | + 'encoding': 'Encoding', |
| 81 | + 'connector': 'Connector', |
| 82 | + 'application_advertisement': 'Application Advertisement', |
| 83 | + 'active_firmware': 'Active Firmware Version', |
| 84 | + 'inactive_firmware': 'Inactive Firmware Version', |
| 85 | + 'hardware_rev': 'Hardware Revision', |
| 86 | + 'media_interface_code': 'Media Interface Code', |
| 87 | + 'host_electrical_interface': 'Host Electrical Interface', |
| 88 | + 'host_lane_count': 'Host Lane Count', |
| 89 | + 'media_lane_count': 'Media Lane Count', |
| 90 | + 'host_lane_assignment_option': 'Host Lane Assignment Options', |
| 91 | + 'media_lane_assignment_option': 'Media Lane Assignment Options', |
| 92 | + 'active_apsel_hostlane1': 'Active App Selection Host Lane 1', |
| 93 | + 'active_apsel_hostlane2': 'Active App Selection Host Lane 2', |
| 94 | + 'active_apsel_hostlane3': 'Active App Selection Host Lane 3', |
| 95 | + 'active_apsel_hostlane4': 'Active App Selection Host Lane 4', |
| 96 | + 'active_apsel_hostlane5': 'Active App Selection Host Lane 5', |
| 97 | + 'active_apsel_hostlane6': 'Active App Selection Host Lane 6', |
| 98 | + 'active_apsel_hostlane7': 'Active App Selection Host Lane 7', |
| 99 | + 'active_apsel_hostlane8': 'Active App Selection Host Lane 8', |
| 100 | + 'media_interface_technology': 'Media Interface Technology', |
| 101 | + 'cmis_rev': 'CMIS Revision', |
| 102 | + 'supported_max_tx_power': 'Supported Max TX Power', |
| 103 | + 'supported_min_tx_power': 'Supported Min TX Power', |
| 104 | + 'supported_max_laser_freq': 'Supported Max Laser Frequency', |
| 105 | + 'supported_min_laser_freq': 'Supported Min Laser Frequency' |
| 106 | +} |
| 107 | + |
66 | 108 | SFP_DOM_CHANNEL_MONITOR_MAP = {
|
67 | 109 | 'rx1power': 'RXPower',
|
68 | 110 | 'tx1bias': 'TXBias',
|
@@ -273,31 +315,68 @@ def format_dict_value_to_string(sorted_key_table,
|
273 | 315 | def convert_sfp_info_to_output_string(sfp_info_dict):
|
274 | 316 | indent = ' ' * 8
|
275 | 317 | output = ''
|
276 |
| - |
277 |
| - sorted_qsfp_data_map_keys = sorted(QSFP_DATA_MAP, key=QSFP_DATA_MAP.get) |
278 |
| - for key in sorted_qsfp_data_map_keys: |
279 |
| - if key == 'cable_type': |
280 |
| - output += '{}{}: {}\n'.format(indent, sfp_info_dict['cable_type'], sfp_info_dict['cable_length']) |
281 |
| - elif key == 'cable_length': |
282 |
| - pass |
283 |
| - elif key == 'specification_compliance': |
284 |
| - if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver" or \ |
285 |
| - sfp_info_dict['type'] == "OSFP 8X Pluggable Transceiver" or \ |
286 |
| - sfp_info_dict['type'] == "QSFP+ or later with CMIS": |
287 |
| - output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) |
| 318 | + sfp_type = sfp_info_dict['type'] |
| 319 | + # CMIS supported module types include QSFP-DD and OSFP |
| 320 | + if sfp_type.startswith('QSFP-DD') or sfp_type.startswith('OSFP'): |
| 321 | + sorted_qsfp_data_map_keys = sorted(QSFP_DD_DATA_MAP, key=QSFP_DD_DATA_MAP.get) |
| 322 | + for key in sorted_qsfp_data_map_keys: |
| 323 | + if key == 'cable_type': |
| 324 | + output += '{}{}: {}\n'.format(indent, sfp_info_dict['cable_type'], sfp_info_dict['cable_length']) |
| 325 | + elif key == 'cable_length': |
| 326 | + pass |
| 327 | + elif key == 'specification_compliance': |
| 328 | + if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver" or \ |
| 329 | + sfp_info_dict['type'] == "OSFP 8X Pluggable Transceiver" or \ |
| 330 | + sfp_info_dict['type'] == "QSFP+ or later with CMIS": |
| 331 | + output += '{}{}: {}\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) |
| 332 | + else: |
| 333 | + output += '{}{}:\n'.format(indent, QSFP_DD_DATA_MAP['specification_compliance']) |
| 334 | + |
| 335 | + spec_compliance_dict = {} |
| 336 | + try: |
| 337 | + spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) |
| 338 | + sorted_compliance_key_table = natsorted(spec_compliance_dict) |
| 339 | + for compliance_key in sorted_compliance_key_table: |
| 340 | + output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) |
| 341 | + except ValueError as e: |
| 342 | + output += '{}N/A\n'.format((indent * 2)) |
| 343 | + elif key == 'application_advertisement': |
| 344 | + pass |
| 345 | + elif key == 'supported_max_tx_power' or key == 'supported_min_tx_power': |
| 346 | + output += '{}{}: {}dBm\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) |
| 347 | + elif key == 'supported_max_laser_freq' or key == 'supported_min_laser_freq': |
| 348 | + output += '{}{}: {}GHz\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) |
288 | 349 | else:
|
289 |
| - output += '{}{}:\n'.format(indent, QSFP_DATA_MAP['specification_compliance']) |
290 |
| - |
291 |
| - spec_compliance_dict = {} |
292 | 350 | try:
|
293 |
| - spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) |
294 |
| - sorted_compliance_key_table = natsorted(spec_compliance_dict) |
295 |
| - for compliance_key in sorted_compliance_key_table: |
296 |
| - output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) |
297 |
| - except ValueError as e: |
298 |
| - output += '{}N/A\n'.format((indent * 2)) |
299 |
| - else: |
300 |
| - output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) |
| 351 | + output += '{}{}: {}\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) |
| 352 | + except (KeyError, ValueError) as e: |
| 353 | + output += '{}{}: N/A\n'.format(indent, QSFP_DD_DATA_MAP[key]) |
| 354 | + |
| 355 | + else: |
| 356 | + sorted_qsfp_data_map_keys = sorted(QSFP_DATA_MAP, key=QSFP_DATA_MAP.get) |
| 357 | + for key in sorted_qsfp_data_map_keys: |
| 358 | + if key == 'cable_type': |
| 359 | + output += '{}{}: {}\n'.format(indent, sfp_info_dict['cable_type'], sfp_info_dict['cable_length']) |
| 360 | + elif key == 'cable_length': |
| 361 | + pass |
| 362 | + elif key == 'specification_compliance': |
| 363 | + if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver" or \ |
| 364 | + sfp_info_dict['type'] == "OSFP 8X Pluggable Transceiver" or \ |
| 365 | + sfp_info_dict['type'] == "QSFP+ or later with CMIS": |
| 366 | + output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) |
| 367 | + else: |
| 368 | + output += '{}{}:\n'.format(indent, QSFP_DATA_MAP['specification_compliance']) |
| 369 | + |
| 370 | + spec_compliance_dict = {} |
| 371 | + try: |
| 372 | + spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) |
| 373 | + sorted_compliance_key_table = natsorted(spec_compliance_dict) |
| 374 | + for compliance_key in sorted_compliance_key_table: |
| 375 | + output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) |
| 376 | + except ValueError as e: |
| 377 | + output += '{}N/A\n'.format((indent * 2)) |
| 378 | + else: |
| 379 | + output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) |
301 | 380 |
|
302 | 381 | return output
|
303 | 382 |
|
|
0 commit comments