@@ -133,6 +133,10 @@ def __init__(self, xcvr_eeprom):
133133 def _get_vdm_key_to_db_prefix_map (self ):
134134 return CMIS_VDM_KEY_TO_DB_PREFIX_KEY_MAP
135135
136+ @staticmethod
137+ def _strip_str (val ):
138+ return val .rstrip () if isinstance (val , str ) else val
139+
136140 def _update_vdm_dict (self , dict_to_update , new_key , vdm_raw_dict , vdm_observable_type , vdm_subtype_index , lane ):
137141 """
138142 Updates the dictionary with the VDM value if the vdm_observable_type exists.
@@ -200,14 +204,14 @@ def get_manufacturer(self):
200204 '''
201205 This function returns the manufacturer of the module
202206 '''
203- return self .xcvr_eeprom .read (consts .VENDOR_NAME_FIELD )
207+ return self ._strip_str ( self . xcvr_eeprom .read (consts .VENDOR_NAME_FIELD ) )
204208
205209 @read_only_cached_api_return
206210 def get_model (self ):
207211 '''
208212 This function returns the part number of the module
209213 '''
210- return self .xcvr_eeprom .read (consts .VENDOR_PART_NO_FIELD )
214+ return self ._strip_str ( self . xcvr_eeprom .read (consts .VENDOR_PART_NO_FIELD ) )
211215
212216 def get_cable_length_type (self ):
213217 '''
@@ -227,14 +231,14 @@ def get_vendor_rev(self):
227231 '''
228232 This function returns the revision level for part number provided by vendor
229233 '''
230- return self .xcvr_eeprom .read (consts .VENDOR_REV_FIELD )
234+ return self ._strip_str ( self . xcvr_eeprom .read (consts .VENDOR_REV_FIELD ) )
231235
232236 @read_only_cached_api_return
233237 def get_serial (self ):
234238 '''
235239 This function returns the serial number of the module
236240 '''
237- return self .xcvr_eeprom .read (consts .VENDOR_SERIAL_NO_FIELD )
241+ return self ._strip_str ( self . xcvr_eeprom .read (consts .VENDOR_SERIAL_NO_FIELD ) )
238242
239243 @read_only_cached_api_return
240244 def get_module_type (self ):
@@ -328,13 +332,13 @@ def get_transceiver_info(self):
328332 "type" : admin_info [consts .ID_FIELD ],
329333 "type_abbrv_name" : admin_info [consts .ID_ABBRV_FIELD ],
330334 "hardware_rev" : self .get_module_hardware_revision (),
331- "serial" : admin_info [consts .VENDOR_SERIAL_NO_FIELD ],
332- "manufacturer" : admin_info [consts .VENDOR_NAME_FIELD ],
333- "model" : admin_info [consts .VENDOR_PART_NO_FIELD ],
335+ "serial" : self . _strip_str ( admin_info [consts .VENDOR_SERIAL_NO_FIELD ]) ,
336+ "manufacturer" : self . _strip_str ( admin_info [consts .VENDOR_NAME_FIELD ]) ,
337+ "model" : self . _strip_str ( admin_info [consts .VENDOR_PART_NO_FIELD ]) ,
334338 "connector" : admin_info [consts .CONNECTOR_FIELD ],
335339 "ext_identifier" : "%s (%sW Max)" % (power_class , max_power ),
336340 "cable_length" : float (admin_info [consts .LENGTH_ASSEMBLY_FIELD ]),
337- "vendor_date" : admin_info [consts .VENDOR_DATE_FIELD ],
341+ "vendor_date" : self . _strip_str ( admin_info [consts .VENDOR_DATE_FIELD ]) ,
338342 "vendor_oui" : admin_info [consts .VENDOR_OUI_FIELD ],
339343 "application_advertisement" : str (self .get_application_advertisement ()) if len (self .get_application_advertisement ()) > 0 else 'N/A' ,
340344 "host_electrical_interface" : self .get_host_electrical_interface (),
@@ -345,7 +349,7 @@ def get_transceiver_info(self):
345349 "media_lane_assignment_option" : self .get_media_lane_assignment_option (),
346350 "cable_type" : self .get_cable_length_type (),
347351 "media_interface_technology" : self .get_media_interface_technology (),
348- "vendor_rev" : self .get_vendor_rev (),
352+ "vendor_rev" : self ._strip_str ( self . get_vendor_rev () ),
349353 "cmis_rev" : self .get_cmis_rev (),
350354 "specification_compliance" : self .get_module_media_type (),
351355 "vdm_supported" : self .is_transceiver_vdm_supported ()
0 commit comments