Skip to content
Snippets Groups Projects
Commit 19d22f1a authored by Carlos Manso's avatar Carlos Manso
Browse files

Fixed bug on UpdateService

parent ef90cda5
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!89First implementation of location-aware services
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment