def get_enb_status(enodeb: EnodebAcsStateMachine) -> EnodebStatus: """ Returns a dict representing the status of an enodeb The returned dictionary will be a subset of the following keys: - enodeb_connected - enodeb_configured - opstate_enabled - rf_tx_on - rf_tx_desired - gps_connected - ptp_connected - mme_connected - gps_latitude - gps_longitude The set of keys returned will depend on the connection status of the enodeb. A missing key indicates that the value is unknown. Returns: Status dictionary for the enodeb state """ enodeb_configured = enodeb.is_enodeb_configured() # We cache GPS coordinates so try to read them before the early return # if the enB is not connected gps_lat, gps_lon = _get_and_cache_gps_coords(enodeb) enodeb_connected = enodeb.is_enodeb_connected() opstate_enabled = _parse_param_as_bool(enodeb, ParameterName.OP_STATE) rf_tx_on = _parse_param_as_bool(enodeb, ParameterName.RF_TX_STATUS) rf_tx_on = rf_tx_on and enodeb_connected try: enb_serial = \ enodeb.device_cfg.get_parameter(ParameterName.SERIAL_NUMBER) rf_tx_desired = get_enb_rf_tx_desired(enodeb.mconfig, enb_serial) except (KeyError, ConfigurationError): rf_tx_desired = False mme_connected = _parse_param_as_bool(enodeb, ParameterName.MME_STATUS) gps_connected = _get_gps_status_as_bool(enodeb) try: ptp_connected = _parse_param_as_bool(enodeb, ParameterName.PTP_STATUS) except ConfigurationError: ptp_connected = False return EnodebStatus(enodeb_configured=enodeb_configured, gps_latitude=gps_lat, gps_longitude=gps_lon, enodeb_connected=enodeb_connected, opstate_enabled=opstate_enabled, rf_tx_on=rf_tx_on, rf_tx_desired=rf_tx_desired, gps_connected=gps_connected, ptp_connected=ptp_connected, mme_connected=mme_connected, fsm_state=enodeb.get_state())
def get_enb_status(enodeb: EnodebAcsStateMachine) -> EnodebStatus: """ Returns a dict representing the status of an enodeb The returned dictionary will be a subset of the following keys: - enodeb_connected - enodeb_configured - opstate_enabled - rf_tx_on - gps_connected - ptp_connected - mme_connected - gps_latitude - gps_longitude The set of keys returned will depend on the connection status of the enodeb. A missing key indicates that the value is unknown. Returns: Status dictionary for the enodeb state """ enodeb_configured = '1' if enodeb.is_enodeb_configured() else '0' # We cache GPS coordinates so try to read them before the early return # if the enB is not connected gps_lat, gps_lon = _get_and_cache_gps_coords(enodeb) enodeb_connected = '1' if enodeb.is_enodeb_connected() else '0' opstate_enabled = _parse_param_as_bool(enodeb, ParameterName.OP_STATE) rf_tx_on = _parse_param_as_bool(enodeb, ParameterName.RF_TX_STATUS) mme_connected = _parse_param_as_bool(enodeb, ParameterName.MME_STATUS) try: if not enodeb.has_parameter(ParameterName.GPS_STATUS): gps_connected = '0' else: param = enodeb.get_parameter(ParameterName.GPS_STATUS) pval = param.lower().strip() if pval == '0' or pval == '1': gps_connected = pval elif pval == '2': # 2 = GPS locking gps_connected = '0' else: logging.warning( 'GPS status parameter not understood (%s)', param) gps_connected = '0' except (KeyError, ConfigurationError): gps_connected = '0' try: if not enodeb.has_parameter(ParameterName.PTP_STATUS): ptp_connected = '0' else: param = enodeb.get_parameter(ParameterName.PTP_STATUS) pval = param.lower().strip() if pval == '0' or pval == '1': ptp_connected = pval else: logging.warning( 'PTP status parameter not understood (%s)', param) ptp_connected = '0' except (KeyError, ConfigurationError): ptp_connected = '0' return EnodebStatus(enodeb_configured=enodeb_configured, gps_latitude=gps_lat, gps_longitude=gps_lon, enodeb_connected=enodeb_connected, opstate_enabled=opstate_enabled, rf_tx_on=rf_tx_on, gps_connected=gps_connected, ptp_connected=ptp_connected, mme_connected=mme_connected, enodeb_state=enodeb.get_state())