def get_hwp_speed(breakout, phy_speed, phy_mode): hwp_count = breakout_to_hwp_count[breakout] _phy_speed_mbps = nas_if.from_yang_speed(phy_speed) if _phy_speed_mbps is None or hwp_count is None or hwp_count == 0: return None _hwp_speed_mbps = _phy_speed_mbps / hwp_count if phy_mode == yang_phy_mode_fc: hwp_speed_eth = get_hwp_fc_to_eth_speed( nas_if.to_yang_speed(_hwp_speed_mbps)) return nas_if.from_yang_speed(hwp_speed_eth) else: return _hwp_speed_mbps
def get_hwp_speed(breakout, phy_speed, phy_mode): hwp_count = nas_comm.yang.get_value(breakout, 'breakout-to-hwp-count') _phy_speed_mbps = nas_if.from_yang_speed(phy_speed) if _phy_speed_mbps is None or hwp_count is None or hwp_count == 0: return None _hwp_speed_mbps = _phy_speed_mbps / hwp_count if phy_mode == nas_comm.yang.get_value('fc', 'yang-phy-mode'): hwp_speed_eth = nas_comm.get_hwp_fc_to_eth_speed( nas_if.to_yang_speed(_hwp_speed_mbps)) return nas_if.from_yang_speed(hwp_speed_eth) else: return _hwp_speed_mbps
def _gen_media_list(media_obj, resp): _media_type = media_obj.get_attr_data('media-type') # Fetch media-type information _m_info = get_media_info(_media_type) _m_info.show() if _m_info == None: nas_if.log_err("Null Media info") return _data = {} _data['media-type'] = _media_type if _m_info.speed != None: _data['speed'] = nas_if.to_yang_speed(_m_info.speed) if _m_info.autoneg != None: _data['autoneg'] = nas_if.to_yang_autoneg(_m_info.autoneg) if _m_info.duplex != None: _data['duplex'] = nas_if.to_yang_duplex(_m_info.duplex) elem = cps_object.CPSObject(module='base-media/media-info', data=_data) resp.append(elem.get())
def _gen_media_list(media_obj, resp): try: _media_type = media_obj.get_attr_data('media-type') except ValueError: _media_type = None if _media_type != None: # Fetch media-type information _m_info = get_media_info(_media_type) _m_info.show() if _m_info is None: nas_if.log_err("Null Media info") return _media_list = {_media_type: _m_info} else: _media_list = MEDIA_LIST for _media_type, _m_info in _media_list.items(): _data = {} _data['media-type'] = _media_type _data['media-name'] = _m_info.name _data['supported-phy-mode'] = [] if _m_info.speed != None: _data['speed'] = nas_if.to_yang_speed(_m_info.speed) if _m_info.autoneg != None: _data['autoneg'] = nas_if.to_yang_autoneg(_m_info.autoneg) if _m_info.duplex != None: _data['duplex'] = nas_if.to_yang_duplex(_m_info.duplex) if _m_info.hw_profile != None: _data['hw-profile'] = _m_info.hw_profile for mode in _m_info.supported_phy_mode: _phy_mode = get_value(yang_phy_mode, mode) _data['supported-phy-mode'].append(_phy_mode) elem = cps_object.CPSObject(module='base-media/media-info', data= _data) resp.append(elem.get())