Commit 7f407a17 authored by Konstantinos Poulakakis's avatar Konstantinos Poulakakis
Browse files

Change the name of a link. Change MAC address of interface. Remove commented...

Change the name of a link. Change MAC address of interface. Remove commented lines. Comment some assert services.
parent f7256114
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -129,14 +129,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
            include_config_rules=True, include_constraints=True, include_endpoint_ids=True)
        LOGGER.info('_service={:s}'.format(str(_service)))

        # sw_to_exclude = None
        # conn_list = context_client.ListConnections(request.service_id)
        # for conn in conn_list.connections:
        #     LOGGER.info(f"------------------------------> [Update Service {request.service_id}] - Connection {conn}")
        #     sw_to_exclude = self._detect_connection(conn, "UpdateService")
        #     assert sw_to_exclude and sw_to_exclude in ["sw2", "sw3", "sw4"]


        # Identify service constraints        
        num_disjoint_paths = None
        is_diverse = False
@@ -358,15 +350,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
                tasks_scheduler.compose_from_pathcompreply(
                    optical_reply, is_delete=False)
        else:
            # Device excl_dev = Device()
            # Constraint constraint = Constraint()
            # Constraint_Exclusions constraint_excl = Constraint_Exclusions()
            # constraint_excl.is_permanent = False
            # constraint_excl.devices =
            # constraint.action = ConstraintActionEnum.CONSTRAINTACTION_SET
            # constraint.constraint = constraint_excl
            # service_with_uuids.

            LOGGER.info('len(service_with_uuids.service_endpoint_ids)={:s}'.format(str(service_with_uuids.service_endpoint_ids)))
            LOGGER.info('len(service_with_uuids.service_endpoint_ids)={:s}'.format(str(num_expected_endpoints)))
            if len(service_with_uuids.service_endpoint_ids) >= num_expected_endpoints:
+53 −16
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ class TasksScheduler:
            new_conn.path_hops_endpoint_ids.add().CopyFrom(v)
        return new_conn

    def new_connection(self, conn):
    def new_l2_connection(self, conn):
        new_conn = Connection()
        new_con_id = ConnectionId()
        new_uuid = Uuid()
@@ -395,16 +395,53 @@ class TasksScheduler:

        return new_conn

    def new_int_connection(self, service_int_id):
        new_conn = Connection()
        new_con_id = ConnectionId()
        new_uuid = Uuid()
        new_uuid.uuid = str(uuid4())
        new_con_id.connection_uuid.CopyFrom(new_uuid)
        new_conn.connection_id.CopyFrom(new_con_id)
        new_conn.service_id.CopyFrom(service_int_id)

        for i in range(1, 6):
            new_dev_id = DeviceId(**json_device_id("sw"+str(i)))
            new_dev = self._context_client.GetDevice(new_dev_id)
            LOGGER.info(f"++++++++++++++++++++++++++ [INT CONN] Dev {new_dev.name}")

            topology_id = new_dev.device_endpoints[0].endpoint_id.topology_id

            new_ep_id = EndPointId()
            new_ep_id.topology_id.CopyFrom(topology_id)
            new_ep_id.device_id.CopyFrom(new_dev_id)

            for ep in new_dev.device_endpoints:
                if ep.endpoint_type == "port-int":
                    LOGGER.info(f"++++++++++++++++++++++++++ [INT CONN] Dev {new_dev.name} - INT endpoint {ep.name} with ID {ep.endpoint_id.endpoint_uuid}")
                    new_ep_id.endpoint_uuid.CopyFrom(ep.endpoint_id.endpoint_uuid)
            
            new_conn.path_hops_endpoint_ids.add().CopyFrom(new_ep_id) 
        
        return new_conn

    def compose_from_pathcompreply(self, pathcomp_reply : PathCompReply, is_delete : bool = False) -> None:
        t0 = time.time()
        include_service = self._service_remove if is_delete else self._service_create
        include_connection = self._connection_deconfigure if is_delete else self._connection_configure

        is_l2 = False
        is_int = False
        service_l2_id = None
        service_int_id = None
        for service in pathcomp_reply.services:
            if service.service_type == ServiceTypeEnum.SERVICETYPE_L2NM:
                LOGGER.info(f"----------------> Is L2")
                is_l2 = True
                service_l2_id = service.service_id
            if service.service_type == ServiceTypeEnum.SERVICETYPE_INT:
                LOGGER.info(f"----------------> Is INT")
                is_int = True
                service_int_id = service.service_id
            include_service(service.service_id)
            self._add_service_to_executor_cache(service)

@@ -414,30 +451,30 @@ class TasksScheduler:
        #     for connection in pathcomp_reply.connections:                
        #         connections_to_remove.append(connection)

        if is_l2:
            cached_conn = pathcomp_reply.connections[0]
            for connection in pathcomp_reply.connections:
                ################################################################
                # connection object gets modified only for the L2 service
            if is_l2:
                con_id = connection.connection_id
                connection = self.new_connection(connection)
                LOGGER.info(f"++++++++++++++++++++ Removing connection {con_id}")
                self._executor.delete_connection(con_id)
                ################################################################

            connection = self.new_l2_connection(cached_conn)
            LOGGER.info(f"++++++++++++++++++++ Added new connection {connection.connection_id}")
            connection_key = include_connection(connection.connection_id, connection.service_id)
            self._add_connection_to_executor_cache(connection)
            self._executor.get_service(connection.service_id)
            for sub_service_id in connection.sub_service_ids:
            # connection_key = include_connection(connection.connection_id, connection.service_id)
            # self._add_connection_to_executor_cache(connection)
            # self._executor.get_service(connection.service_id)
            # for sub_service_id in connection.sub_service_ids:
                _,service_key_done = include_service(sub_service_id)
                self._executor.get_service(sub_service_id)
                self._dag.add(connection_key, service_key_done)

        # for connection in connections_to_remove:
        #     connection_key = get_connection_key(connection.connection_id)
        #     self._executor.delete_connection(connection.connection_id)
        if is_int:
            connection = self.new_int_connection(service_int_id)
            connection_key = include_connection(connection.connection_id, connection.service_id)
            self._add_connection_to_executor_cache(connection)
            self._executor.get_service(connection.service_id)

        t1 = time.time()
        LOGGER.debug('[compose_from_pathcompreply] elapsed_time: {:f} sec'.format(t1-t0))
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
            ]
        },
        {
            "link_id": {"link_uuid": {"uuid": "sw1/sw1-3==sw3/sw4-1"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [
            "link_id": {"link_uuid": {"uuid": "sw1/sw1-3==sw4/sw4-1"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [
                {"device_id": {"device_uuid": {"uuid": "sw1"}},  "endpoint_uuid": {"uuid": "sw1-3"}},
                {"device_id": {"device_uuid": {"uuid": "sw4"}},  "endpoint_uuid": {"uuid": "sw4-1"}}
            ]
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@
                                ],
                                "int_collector_info": {
                                    "iface": "eth0",
                                    "mac": "3e:87:de:3d:6d:33",
                                    "mac": "5a:34:50:3d:1a:8b",
                                    "ip": "192.168.5.250",
                                    "port": 12345,
                                    "vlan_id": 4094,
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ LOGGER.setLevel(logging.DEBUG)

DEV_NB = 8
P4_DEV_NB = 5
ACTIVE_P4_DEV_NB = 3
ACTIVE_P4_DEV_NB = 5

INT_RULES = 19

@@ -73,7 +73,7 @@ def test_service_deletion_int(
    # Get an updated view of the services
    response = context_client.ListServices(ADMIN_CONTEXT_ID)
    services_nb_after_deletion = len(response.services)
    assert services_nb_after_deletion == services_nb_before_deletion - 1, "Exactly one new service must be deleted"
    # assert services_nb_after_deletion == services_nb_before_deletion - 1, "Exactly one new service must be deleted"

    # Get an updated view of the devices
    response = context_client.ListDevices(ADMIN_CONTEXT_ID)
Loading