Esempio n. 1
0
    def get(self):
        response = {
            "jormungandr_version": __version__,
            "regions": [],
            "bss_providers": [provider.status() for provider in bss_provider_manager.get_providers()],
        }

        regions = i_manager.get_regions()
        for key_region in regions:
            req = request_pb2.Request()
            instance = i_manager.instances[key_region]
            req.requested_api = type_pb2.STATUS
            try:
                resp = instance.send_and_receive(req, timeout=1000)

                raw_resp_dict = protobuf_to_dict(resp, use_enum_labels=True)
                add_common_status(raw_resp_dict, instance)
                resp_dict = CommonStatusSerializer(raw_resp_dict['status']).data
            except DeadSocketException:
                resp_dict = {
                    "status": "dead",
                    "realtime_proxies": [],
                    "error": {"code": "dead_socket", "value": "The region {} is dead".format(key_region)},
                }
            resp_dict['region_id'] = key_region
            response['regions'].append(resp_dict)

        # if we use our implementation of redisCache display the status
        cache_status_op = getattr(cache.cache, "status", None)
        if callable(cache_status_op):
            response['redis'] = cache_status_op()

        return response
Esempio n. 2
0
 def get(self, region=None, lon=None, lat=None):
     region_str = i_manager.get_region(region, lon, lat)
     response = protobuf_to_dict(
         i_manager.dispatch({}, "status", instance_name=region_str), use_enum_labels=True
     )
     instance = i_manager.instances[region_str]
     add_common_status(response, instance)
     response['status']['parameters'] = instance
     response['status']['traveler_profiles'] = travelers_profile.TravelerProfile.get_profiles_by_coverage(
         region_str
     )
     return response, 200
Esempio n. 3
0
    def get(self, region=None, lon=None, lat=None):
        region_str = i_manager.get_region(region, lon, lat)
        response = protobuf_to_dict(i_manager.dispatch(
            {}, "status", instance_name=region_str),
                                    use_enum_labels=True)
        instance = i_manager.instances[region_str]
        add_common_status(response, instance)
        response['status']['parameters'] = instance
        response['status'][
            'traveler_profiles'] = travelers_profile.TravelerProfile.get_profiles_by_coverage(
                region_str)
        logging.getLogger(__name__).info("status reponse: %s", response)
        response['status']['configuration_database'] = (
            'connected' if can_connect_to_database() else 'no_SQL_connection')

        return response, 200
def call_add_common_status_with_Karos(disable_database):
    instance = FakeInstance(
        disable_database,
        ridesharing_configurations=karos_system_ridesharing_config,
        equipment_details_config=sytral_equipment_details_config,
        instance_equipment_providers=["sytral"],
    )
    response = {'status': {}}
    add_common_status(response, instance)

    # We sort this list because the order is not important
    # And it is easier to compare
    ridesharing_status = response['status']["ridesharing_services"]
    ridesharing_status.sort()
    assert ridesharing_status == expected_karos_ridesharing_status

    return OrderedDict(response)
Esempio n. 5
0
def call_add_common_status(disable_database):
    instance = FakeInstance(disable_database)
    response = {}
    response['status'] = {}
    add_common_status(response, instance)

    assert response['status']["is_open_data"] == False
    assert response['status']["is_open_service"] == False
    assert response['status']['realtime_proxies'] == []

    # We sort this list because the order is not important
    # And it is easier to compare
    streetnetworks_status = response['status']["street_networks"]
    streetnetworks_status.sort()
    assert streetnetworks_status == expected_streetnetworks_status

    assert response['status']['ridesharing_services'] == []
    assert response['status']['autocomplete'] == {'class': 'Kraken'}

    # We sort the response because the order is not important
    # And it is easier to compare
    return OrderedDict(response)
def call_add_common_status(disable_database):
    instance = FakeInstance(
        disable_database,
        ridesharing_configurations=instant_system_ridesharing_config,
        equipment_details_config=sytral_equipment_details_config,
        instance_equipment_providers=["sytral"],
    )
    response = {}
    response['status'] = {}
    add_common_status(response, instance)

    assert response['status']["is_open_data"] == False
    assert response['status']["is_open_service"] == False
    assert response['status']['realtime_proxies'] == []

    # We sort this list because the order is not important
    # And it is easier to compare
    streetnetworks_status = response['status']["street_networks"]
    compare_list_of_dicts("id", streetnetworks_status,
                          expected_streetnetworks_status)

    ridesharing_status = response['status']["ridesharing_services"]
    ridesharing_status.sort()
    assert ridesharing_status == expected_ridesharing_status

    equipment_providers_keys = response['status'][
        "equipment_providers_services"]['equipment_providers_keys']
    assert equipment_providers_keys == expected_equipment_providers_keys
    equipment_providers = response['status']["equipment_providers_services"][
        'equipment_providers']
    equipment_providers.sort()
    assert equipment_providers == expected_equipment_providers

    assert response['status']['autocomplete'] == {'class': 'Kraken'}

    # We sort the response because the order is not important
    # And it is easier to compare
    return OrderedDict(response)