From dad05a6f0263fd5ac945daae84053c784f19a4ce Mon Sep 17 00:00:00 2001
From: Carlos Manso <carlos.manso@cttc.es>
Date: Thu, 6 Jul 2023 17:28:52 +0200
Subject: [PATCH] cleanup

---
 src/context/service/database/Constraint.py       |  3 +--
 .../service/ServiceServiceServicerImpl.py        | 16 ----------------
 src/service/tests/CommonObjects.py               |  8 ++++----
 src/service/tests/ServiceHandlersToTest.py       |  3 +--
 src/service/tests/test_unitary.py                |  3 ---
 5 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/src/context/service/database/Constraint.py b/src/context/service/database/Constraint.py
index 3b77670a7..6869b7b71 100644
--- a/src/context/service/database/Constraint.py
+++ b/src/context/service/database/Constraint.py
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import datetime, logging
+import datetime, logging, json
 from sqlalchemy import delete
 #from sqlalchemy.dialects import postgresql
 from sqlalchemy.dialects.postgresql import insert
@@ -24,7 +24,6 @@ from .models.ConstraintModel import ConstraintKindEnum, ServiceConstraintModel,
 from .models.enums.ConstraintAction import ORM_ConstraintActionEnum, grpc_to_enum__constraint_action
 from .uuids._Builder import get_uuid_from_string
 from .uuids.EndPoint import endpoint_get_uuid
-import json
 
 LOGGER = logging.getLogger(__name__)
 
diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index 8326e15d9..11d191d4b 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -135,22 +135,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
         for config_rule in request.service_config.config_rules:
             service.service_config.config_rules.add().CopyFrom(config_rule) # pylint: disable=no-member
 
-        """
-        for constraint in request.service_constraints:
-            if constraint.WhichOneof('constraint') == 'endpoint_location':
-                device_list = context_client.ListDevices(Empty())
-                service_location = constraint.endpoint_location.location
-                distances = {}
-                for device in device_list.devices:
-                    for endpoint in device.device_endpoints:
-                        if not endpoint.endpoint_location.HasField('gps_position'): continue
-                        distance = gps_distance(service_location.gps_position, endpoint.endpoint_location.gps_position)
-                        distances[distance] = endpoint.endpoint_id
-
-                closer_endpoint_uuid = distances[min(distances)]
-                service.service_endpoint_ids.append(closer_endpoint_uuid)
-        """
-
         service_id_with_uuids = context_client.SetService(service)
 
         # PathComp requires endpoints, constraints and config rules
diff --git a/src/service/tests/CommonObjects.py b/src/service/tests/CommonObjects.py
index c69844d07..6b7fa86f1 100644
--- a/src/service/tests/CommonObjects.py
+++ b/src/service/tests/CommonObjects.py
@@ -19,12 +19,12 @@ from common.tools.object_factory.Topology import json_topology, json_topology_id
 from context.service.database.uuids._Builder import get_uuid_from_string
 
 # ----- Context --------------------------------------------------------------------------------------------------------
-CONTEXT_ID = json_context_id(get_uuid_from_string(DEFAULT_CONTEXT_NAME))
-CONTEXT    = json_context(get_uuid_from_string(DEFAULT_CONTEXT_NAME))
+CONTEXT_ID = json_context_id(DEFAULT_CONTEXT_NAME)
+CONTEXT    = json_context(DEFAULT_CONTEXT_NAME)
 
 # ----- Topology -------------------------------------------------------------------------------------------------------
-TOPOLOGY_ID = json_topology_id(get_uuid_from_string(DEFAULT_TOPOLOGY_NAME), context_id=CONTEXT_ID)
-TOPOLOGY    = json_topology(get_uuid_from_string(DEFAULT_TOPOLOGY_NAME), context_id=CONTEXT_ID)
+TOPOLOGY_ID = json_topology_id(DEFAULT_TOPOLOGY_NAME, context_id=CONTEXT_ID)
+TOPOLOGY    = json_topology(DEFAULT_TOPOLOGY_NAME, context_id=CONTEXT_ID)
 
 # ----- Monitoring Samples ---------------------------------------------------------------------------------------------
 PACKET_PORT_SAMPLE_TYPES = [
diff --git a/src/service/tests/ServiceHandlersToTest.py b/src/service/tests/ServiceHandlersToTest.py
index 18a45ca98..c50a0b457 100644
--- a/src/service/tests/ServiceHandlersToTest.py
+++ b/src/service/tests/ServiceHandlersToTest.py
@@ -21,10 +21,9 @@ try:
     SERVICE_HANDLERS_TO_TEST.append(TEST_SERVICE_HANDLER)
 except ImportError:
     pass
-"""
+
 try:
     from service.tests.ServiceHandler_L3NM_OC import TEST_SERVICE_HANDLER
     SERVICE_HANDLERS_TO_TEST.append(TEST_SERVICE_HANDLER)
 except ImportError:
     pass
-"""
diff --git a/src/service/tests/test_unitary.py b/src/service/tests/test_unitary.py
index 5847129aa..0779a1f3c 100644
--- a/src/service/tests/test_unitary.py
+++ b/src/service/tests/test_unitary.py
@@ -170,9 +170,6 @@ class TestServiceHandlers:
         service_with_settings = copy.deepcopy(service_descriptor)
         service_with_settings['service_config']['config_rules'].extend(service_config_rules)
         service_with_settings['service_constraints'].extend(service_constraints_location)
-        LOGGER.warning('---------------------------------------------------------')
-        LOGGER.warning(service_with_settings)
-        LOGGER.warning('---------------------------------------------------------')
         service_client.UpdateService(Service(**service_with_settings))
 
         for endpoint_id in service_endpoint_ids:
-- 
GitLab