feat: P4 L3 service handler

Closes issue #272 (closed)

Edited by Georgios P. Katsikas

Merge request reports

Loading
+13 −0
Changes for src/service/service/service_handlers/p4_fabric_tna_l3/__init__.py: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+505 −0

File added.

Preview size limit exceeded, changes collapsed.

+7 −0
Changes for src/service/service/service_handlers/__init__.py: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ from .microwave.MicrowaveServiceHandler import MicrowaveServiceHandler
from .p4_dummy_l1.p4_dummy_l1_service_handler import P4DummyL1ServiceHandler
from .p4_fabric_tna_int.p4_fabric_tna_int_service_handler import P4FabricINTServiceHandler
from .p4_fabric_tna_l2_simple.p4_fabric_tna_l2_simple_service_handler import P4FabricL2SimpleServiceHandler
from .p4_fabric_tna_l3.p4_fabric_tna_l3_service_handler import P4FabricL3ServiceHandler
from .tapi_tapi.TapiServiceHandler import TapiServiceHandler
from .tapi_xr.TapiXrServiceHandler import TapiXrServiceHandler
from .e2e_orch.E2EOrchestratorServiceHandler import E2EOrchestratorServiceHandler
@@ -125,6 +126,12 @@ SERVICE_HANDLERS = [
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (P4FabricL3ServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE: ServiceTypeEnum.SERVICETYPE_L3NM,
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (L2NM_IETFL2VPN_ServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_L2NM,
+67 −0
Changes for src/tests/p4-fabric-tna/descriptors/service-create-l3.json: 67 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
    "services": [
        {
            "service_id": {
                "context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "p4-service-l3"}
            },
            "name": "p4-service-l3",
            "service_type": "SERVICETYPE_L3NM",
            "service_status": {"service_status": "SERVICESTATUS_PLANNED"},
            "service_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "p4-sw1"}},
                    "endpoint_uuid": {"uuid": "1"}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "p4-sw1"}},
                    "endpoint_uuid": {"uuid": "2"}
                }
            ],
            "service_config": {
                "config_rules": [
                    {
                        "action": "CONFIGACTION_SET",
                        "custom": {
                            "resource_key": "/settings",
                            "resource_value": {
                                "switch_info": {
                                    "p4-sw1": {
                                        "arch": "v1model",
                                        "dpid": 1,
                                        "port_list": [
                                            {
                                                "port_id": 1,
                                                "port_type": "host"
                                            },
                                            {
                                                "port_id": 2,
                                                "port_type": "host"
                                            }
                                        ],
                                        "routing_list": [
                                            {
                                                "port_id": 1,
                                                "ipv4_dst": "10.158.72.11",
                                                "ipv4_prefix_len": 32,
                                                "mac_src": "fa:16:3e:e2:af:28",
                                                "mac_dst": "fa:16:3e:75:9c:e5"
                                            },
                                            {
                                                "port_id": 2,
                                                "ipv4_dst": "172.16.10.9",
                                                "ipv4_prefix_len": 32,
                                                "mac_src": "fa:16:3e:75:9c:e5",
                                                "mac_dst": "fa:16:3e:e2:af:28"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "service_constraints": []
        }
    ]
}
+78 −0
Changes for src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l3.py: 78 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, ServiceTypeEnum
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Service import json_service_id
from context.client.ContextClient import ContextClient
from service.client.ServiceClient import ServiceClient
from tests.Fixtures import context_client, service_client # pylint: disable=unused-import
from tests.tools.test_tools_p4 import *

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)

def test_service_deletion_l3(
    context_client : ContextClient, # pylint: disable=redefined-outer-name
    service_client : ServiceClient  # pylint: disable=redefined-outer-name
) -> None:
    # Get the current number of devices
    response = context_client.ListDevices(ADMIN_CONTEXT_ID)
    LOGGER.warning('Devices[{:d}] = {:s}'.format(len(response.devices), grpc_message_to_json_string(response)))

    # Total devices
    dev_nb = len(response.devices)
    assert dev_nb == DEV_NB

    # P4 devices
    p4_dev_nb = identify_number_of_p4_devices(response.devices)
    assert p4_dev_nb == P4_DEV_NB

    # Get the current number of rules in the P4 devices
    p4_rules_before_deletion = get_number_of_rules(response.devices)

    # Get the current number of services
    response = context_client.ListServices(ADMIN_CONTEXT_ID)
    services_nb_before_deletion = len(response.services)
    assert verify_active_service_type(response.services, ServiceTypeEnum.SERVICETYPE_L3NM)

    for service in response.services:
        # Ignore services of other types
        if service.service_type != ServiceTypeEnum.SERVICETYPE_L3NM:
            continue

        service_id = service.service_id
        assert service_id

        service_uuid = service_id.service_uuid.uuid
        context_uuid = service_id.context_id.context_uuid.uuid
        assert service.service_status.service_status == ServiceStatusEnum.SERVICESTATUS_ACTIVE

        # Delete L3 service
        service_client.DeleteService(ServiceId(**json_service_id(service_uuid, json_context_id(context_uuid))))

    # 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"

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

    rules_diff = p4_rules_before_deletion - p4_rules_after_deletion

    assert p4_rules_after_deletion < p4_rules_before_deletion, "L3 service must contain some rules"
    assert rules_diff == P4_DEV_NB * L3_RULES, "L3 service must contain {} rules per device".format(L3_RULES)
Loading
Loading