def nas_set_media_type_by_media_id(slot, media_id, media_type): l = [] port_list = [] o = cps_object.CPSObject(module='base-if-phy/front-panel-port', data={'media-id': media_id}) cps.get([o.get()], l) if len(l) == 0: nas_if.log_err("No such port found... for medial " + str(media_id)) return #fetching 2 front panel port object from 1 phy media id for QSFP28-DD ports for fp_obj in l: obj = cps_object.CPSObject(obj=fp_obj) if _fp_port_key == obj.get_key(): port_list = port_list + nas_if.physical_ports_for_front_panel_port( obj) if len(port_list) == 0: nas_if.log_err("There are no physical ports for front panel port ") nas_if.log_err(l[0]) return for port in port_list: nas_if.log_info(" port id : " + str(port.get_attr_data('port-id')) + ". media type: " + str(media_type)) port.add_attr('phy-media', media_type) ch = {'operation': 'set', 'change': port.get()} cps.transaction([ch])
def if_media_type_set(pas_media_obj): try: media_id = pas_media_obj.get_attr_data('port') media_type = pas_media_obj.get_attr_data('type') except: nas_if.log_info( "media Id or media type is not present in the media event") return # fetch FP info from media ID l = nas_if.nas_os_fp_list(d={'media-id': media_id}) if len(l) == 0: nas_if.log_err("No such port found... for media " + str(media_id)) return #fetching 2 front panel port object from 1 phy media id for QSFP28-DD ports port_list = [] for fp_obj in l: obj = cps_object.CPSObject(obj=fp_obj) if _fp_port_key == obj.get_key(): port_list = port_list + nas_if.physical_ports_for_front_panel_port( obj) if len(port_list) == 0: nas_if.log_err("There are no physical ports for front panel port ") nas_if.log_err(l[0]) return # create interface set RPC obj for each phy port in the list and send it for p in port_list: npu = p.get_attr_data('npu-id') port = p.get_attr_data('port-id') hwport_list = p.get_attr_data('hardware-port-list') nas_if.log_info("send if rpc for media id set for phy port " + str(port)) ifobj = cps_object.CPSObject( module='dell-base-if-cmn/set-interface', data={ 'dell-base-if-cmn/set-interface/input/operation': 3, 'base-if-phy/if/interfaces/interface/npu-id': npu, 'base-if-phy/if/interfaces/interface/port-id': port, 'base-if-phy/if/interfaces/interface/phy-media': media_type, 'if/interfaces/interface/type': "ianaift:ethernetCsmacd" }) ch = {'operation': 'rpc', 'change': ifobj.get()} cps.transaction([ch]) if_name = str( ch['change']['data']['if/interfaces/interface/name'])[:-1] if_details = nas_if.nas_os_if_list( d={'if/interfaces/interface/name': if_name}) enable = ba.from_ba( if_details[0]['data']['if/interfaces/interface/enabled'], "uint64_t") for hwport in hwport_list: fp_details = fp.find_port_by_hwport(npu, hwport) _lane = fp_details.lane media_transceiver_set(1, fp_details.media_id, _lane, enable) nas_if.log_info("setting media id: " + str(media_id) + " media type: " + str(media_type))
def if_media_type_set(pas_media_obj): try: media_id = pas_media_obj.get_attr_data('port') media_type = pas_media_obj.get_attr_data('type') except: nas_if.log_err( "media Id or media type is not present in the media event") return # fetch FP info from media ID l = nas_if.nas_os_fp_list(d={'media-id': media_id}) if len(l) == 0: nas_if.log_err("No such port found... for media " + str(media_id)) return # fetch PHY port list for the FP port port_list = nas_if.physical_ports_for_front_panel_port( cps_object.CPSObject(obj=l[0])) if len(port_list) == 0: nas_if.log_err("There are no physical ports for front panel port ") nas_if.log_err(l[0]) return # create interface set RPC obj for each phy port in the list and send it for p in port_list: npu = p.get_attr_data('npu-id') port = p.get_attr_data('port-id') fanout = p.get_attr_data('fanout-mode') hwport = p.get_attr_data('hardware-port-id') nas_if.log_info("send if rpc for media id set for phy port " + str(port)) ifobj = cps_object.CPSObject( module='dell-base-if-cmn/set-interface', data={ 'dell-base-if-cmn/set-interface/input/operation': 3, 'base-if-phy/if/interfaces/interface/npu-id': npu, 'base-if-phy/if/interfaces/interface/port-id': port, 'base-if-phy/if/interfaces/interface/phy-media': media_type, 'if/interfaces/interface/type': "ianaift:ethernetCsmacd" }) ch = {'operation': 'rpc', 'change': ifobj.get()} cps.transaction([ch]) if_name = ba.ba_to_str( ch['change']['data']['if/interfaces/interface/name'], len(_if_name)) if_details = nas_if.nas_os_if_list( d={'if/interfaces/interface/name': if_name}) enable = ba.from_ba( if_details[0]['data']['if/interfaces/interface/enabled'], "uint64_t") fp_details = fp.find_port_by_hwport(npu, hwport) if fanout == 2: # then it is in 4x10G fanout mode BASE_PORT_BREAKOUT_MODE_BREAKOUT_4X1 _lane = fp_details.lane else: # non-fanout mode 1x40g mode _lane = None # enable/disable all channels. Do not pass Lane # media_transceiver_set(1, fp_details.media_id, _lane, enable) nas_if.log_info("setting media id: " + str(media_id) + " media type: " + str(media_type))
def nas_set_media_type_by_media_id(slot, media_id, media_type): l = [] o = cps_object.CPSObject(module='base-if-phy/front-panel-port', data={'media-id': media_id}) cps.get([o.get()], l) if len(l) == 0: print "No such port found... for medial %d" % media_id return port_list = nas_if.physical_ports_for_front_panel_port( cps_object.CPSObject(obj=l[0])) if len(port_list) == 0: print "There are no physical ports for front panel port " print l[0] return for port in port_list: print " port id : %d.. media type: %d " % ( port.get_attr_data('port-id'), media_type) port.add_attr('phy-media', media_type) ch = {'operation': 'set', 'change': port.get()} cps.transaction([ch])
def set_intf_request(pas_media_obj): try: media_id = pas_media_obj.get_attr_data('port') display_str = pas_media_obj.get_attr_data( 'base-pas/media/display-string') except: nas_if.log_info("Media String is not present in the media event") return # fetch FP info from media ID o = cps_object.CPSObject( module='base-if-phy/front-panel-port', data={'base-if-phy/front-panel-port/media-id': media_id}) l = [] fp_utils.gen_fp_port_list(o, l) if len(l) == 0: nas_if.log_err("No such port found... for media " + str(media_id)) return #fetching 2 front panel port object from 1 phy media id for QSFP28-DD ports port_list = [] for fp_obj in l: obj = cps_object.CPSObject(obj=fp_obj) if nas_comm.yang.get_value('fp_key', 'keys_id') == obj.get_key(): port_list = port_list + nas_if.physical_ports_for_front_panel_port( obj) if len(port_list) == 0: nas_if.log_err("There are no physical ports for front panel port ") nas_if.log_err(str(l[0])) return # create interface set RPC obj for each phy port in the list and send it for p in port_list: npu = p.get_attr_data('npu-id') port = p.get_attr_data('port-id') process_media_event(npu, port, pas_media_obj) hwport_list = p.get_attr_data('hardware-port-list') nas_if.log_info("send if obj for media id set for phy port " + str(port)) ifobj = cps_object.CPSObject( module='dell-base-if-cmn/if/interfaces/interface', data={ 'base-if-phy/if/interfaces/interface/npu-id': npu, 'base-if-phy/if/interfaces/interface/port-id': port, 'if/interfaces/interface/type': "ianaift:ethernetCsmacd" }) if if_lib.set_media_setting(None, ifobj) == False: return ch = {'operation': 'set', 'change': ifobj.get()} cps.transaction([ch]) if_name = if_config.if_config_get_by_npu_port(npu, port) if_details = nas_if.nas_os_if_list( d={'if/interfaces/interface/name': if_name}) enable = ba.from_ba( if_details[0]['data']['if/interfaces/interface/enabled'], "uint64_t") for hwport in hwport_list: fp_details = fp.find_port_by_hwport(npu, hwport) if fp_details.port_group_id is None: _lane = fp_details.lane else: pg_list = fp.get_port_group_list() pg_obj = pg_list[fp_details.port_group_id] if ((pg_obj.get_profile_type()) == "ethernet_ddqsfp28"): _lane = pg_obj.get_lane(hwport) else: _lane = fp_details.lane media.media_transceiver_set(1, fp_details.media_id, _lane, enable)