def _get_if_media_type(fp_port): media_type = 0 try: media_id = _get_media_id_from_fp_port(fp_port) if media_id == 0: return media_type media_info = media.get_media_info(media_id) media_obj = cps_object.CPSObject(obj=media_info[0]) media_type = media_obj.get_attr_data('type') return media_type except: return None
def _get_if_media_obj(fp_port): ''' Method to get media object from PAS ''' if fp_port is None: nas_if.log_err("Wrong fp port or None") try: media_id = _get_media_id_from_fp_port(fp_port) media_info = media.get_media_info(media_id) media_obj = cps_object.CPSObject(obj=media_info[0]) return media_obj except: return None
def _get_if_media_type(fp_port): if fp_port == None: nas_if.log_err("Wrong fp port or None") media_type = 0 try: media_id = _get_media_id_from_fp_port(fp_port) if media_id == 0: return media_type media_info = media.get_media_info(media_id) media_obj = cps_object.CPSObject(obj=media_info[0]) media_type = media_obj.get_attr_data('type') return media_type except: return None
def set_media_type_on_port_create(phy_obj): hwport = phy_obj.get_attr_data('hardware-port-id') if hwport <= 0: return npu = phy_obj.get_attr_data('npu-id') port_id = phy_obj.get_attr_data('port-id') fp_port_details = fp.find_port_by_hwport(npu, hwport) if fp_port_details is None: return # Fetch media info from PAS pas_media_list = media.get_media_info(fp_port_details.media_id) pas_media_obj = cps_object.CPSObject(obj=pas_media_list[0]) media.nas_set_media_type_by_phy_port(npu, port_id, pas_media_obj.get_attr_data('type'))