def _empty_enb_status() -> SingleEnodebStatus: enb_status = SingleEnodebStatus() enb_status.device_serial = 'N/A' enb_status.ip_address = 'N/A' enb_status.connected = '0' enb_status.configured = '0' enb_status.opstate_enabled = '0' enb_status.rf_tx_on = '0' enb_status.rf_tx_desired = 'N/A' enb_status.gps_connected = '0' enb_status.ptp_connected = '0' enb_status.mme_connected = '0' enb_status.gps_longitude = '0.0' enb_status.gps_latitude = '0.0' enb_status.fsm_state = 'N/A' return enb_status
def get_single_enb_status( device_serial: str, state_machine_manager: StateMachineManager ) -> SingleEnodebStatus: try: handler = state_machine_manager.get_handler_by_serial(device_serial) except KeyError: return _empty_enb_status() # This namedtuple is missing IP and serial info status = get_enb_status(handler) # Get IP info ip = state_machine_manager.get_ip_of_serial(device_serial) def get_status_property(status: bool) -> SingleEnodebStatus.StatusProperty: if status: return SingleEnodebStatus.StatusProperty.Value('ON') return SingleEnodebStatus.StatusProperty.Value('OFF') # Build the message to return through gRPC enb_status = SingleEnodebStatus() enb_status.device_serial = device_serial enb_status.ip_address = ip enb_status.connected = get_status_property(status.enodeb_connected) enb_status.configured = get_status_property(status.enodeb_configured) enb_status.opstate_enabled = get_status_property(status.opstate_enabled) enb_status.rf_tx_on = get_status_property(status.rf_tx_on) enb_status.rf_tx_desired = get_status_property(status.rf_tx_desired) enb_status.gps_connected = get_status_property(status.gps_connected) enb_status.ptp_connected = get_status_property(status.ptp_connected) enb_status.mme_connected = get_status_property(status.mme_connected) enb_status.gps_longitude = status.gps_longitude enb_status.gps_latitude = status.gps_latitude enb_status.fsm_state = status.fsm_state return enb_status