def set_media_transceiver(interface_obj): # get front panel port from ifindex if_obj = cps_object.CPSObject(obj=interface_obj) npu = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/npu-id') port = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/port-id') enable = if_obj.get_attr_data('if/interfaces/interface/enabled') nas_if.log_info("set_media_transceiver as " + str(enable) + " for " + str(npu) + " , " + str(port)) port_list = nas_if.nas_os_phy_list(d={'npu-id': npu, 'port-id': port}) phy_obj = cps_object.CPSObject(obj=port_list[0]) try: hwport_list = phy_obj.get_attr_data('hardware-port-list') except: nas_if.log_err(" Error in setting media Transceiver for %s" % if_obj.get_attr_data('name')) return # set media transceiver using media Id and channel ID # 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)
def gen_port_group_state_list(obj, resp): pg_name = nas_if.get_cps_attr(obj, pg_state_attr('id')) pg_list = fp.get_port_group_list() if pg_name != None: pg = pg_list[pg_name] return create_and_add_pg_state_obj(pg, resp) else: # return all port groups for name in pg_list: ret = create_and_add_pg_state_obj(pg_list[name], resp) return True
def gen_port_group_list(obj, resp): pg_name = nas_if.get_cps_attr(obj, pg_attr('id')) pg_list = fp.get_port_group_list() if pg_name != None: pg = pg_list[pg_name] obj = create_pg_cps_obj(pg) if obj == None: return False resp.append(obj.get()) else: # return all port groups for name in pg_list: obj = create_pg_cps_obj(pg_list[name]) if obj != None: resp.append(obj.get()) return True
def set_int_pg_cb(methods, params): nas_if.log_info("set port group config") obj = cps_object.CPSObject(obj=params['change']) if obj.get_key() == _port_group_key: pg_name = nas_if.get_cps_attr(obj, pg_attr('id')) if pg_name == None: nas_if.log_err('port group name not present') return False phy_mode = nas_if.get_cps_attr(obj, pg_attr('phy-mode')) br_mode = nas_if.get_cps_attr(obj, pg_attr('breakout-mode')) port_speed = nas_if.get_cps_attr(obj, pg_attr('port-speed')) pg_list = fp.get_port_group_list() ret = set_port_group_config(pg_list[pg_name], phy_mode, br_mode, port_speed) if ret == True: obj = create_pg_cps_obj(pg_list[pg_name]) params['change'] = obj.get() else: return False return True
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)