diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py index c2fe6356269b983ca7b74ed9c7236fb728fedcd3..686597a77dc7c7e5d4b054189b9f99aa0b1f8afe 100644 --- a/src/service/service/ServiceServiceServicerImpl.py +++ b/src/service/service/ServiceServiceServicerImpl.py @@ -142,10 +142,11 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): if constraint.WhichOneof('constraint') == 'sla_availability': num_disjoint_paths = constraint.sla_availability.num_disjoint_paths break - service_locations = [] + + service_locations = None for constraint in request.service_constraints: if constraint.WhichOneof('constraint') == 'endpoint_location': - service_locations.append(constraint.endpoint_location.location) + service_location = constraint.endpoint_location.location num_disjoint_paths = 1 if num_disjoint_paths is None or num_disjoint_paths == 0 else num_disjoint_paths @@ -156,21 +157,22 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): len(service_locations) >= num_expected_endpoints: pathcomp_request = PathCompRequest() pathcomp_request.services.append(service_with_uuids) # pylint: disable=no-member + LOGGER.warning('__PR1: {}'.format(grpc_message_to_json(pathcomp_request))) if service_locations: context_client = ContextClient() device_list = context_client.ListDevices(Empty()) - closer_endpoint_ids = [] - for service_location in service_locations: + closer_endpoint_id = None + if service_location: distances = {} for device in device_list.devices: for endpoint in device.device_endpoints: distances[gps_distance(service_location.gps_position, endpoint.endpoint_location.gps_position)] = endpoint.endpoint_id min_distance = min(distances) - closer_endpoint_ids.append(distances[min_distance]) + closer_endpoint_id = distances[min_distance] - pathcomp_request.services[0].service_endpoint_ids.extend(closer_endpoint_ids) + pathcomp_request.services[0].service_endpoint_ids.extend(closer_endpoint_id) if num_disjoint_paths is None or num_disjoint_paths in {0, 1}: pathcomp_request.shortest_path.Clear() # pylint: disable=no-member