diff --git a/proto/context.proto b/proto/context.proto index 3ccc13ab199ae7587b0c99340c85524f16e86431..7570a4596a0abd254d93c77131f03fa432cf09c7 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -201,6 +201,7 @@ enum DeviceDriverEnum { DEVICEDRIVER_XR = 6; DEVICEDRIVER_IETF_L2VPN = 7; DEVICEDRIVER_GNMI_OPENCONFIG = 8; + DEVICEDRIVER_FLEXSCALE = 9; } enum DeviceOperationalStatusEnum { @@ -285,6 +286,7 @@ enum ServiceTypeEnum { SERVICETYPE_L2NM = 2; SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; SERVICETYPE_TE = 4; + SERVICETYPE_E2E = 5; } enum ServiceStatusEnum { diff --git a/src/context/service/database/models/enums/ServiceType.py b/src/context/service/database/models/enums/ServiceType.py index 0ed1938a7ca1e566bea815d9ce936150bb91d9dc..ce198f8c1f795f25da547e2d5974059062489709 100644 --- a/src/context/service/database/models/enums/ServiceType.py +++ b/src/context/service/database/models/enums/ServiceType.py @@ -27,6 +27,7 @@ class ORM_ServiceTypeEnum(enum.Enum): L2NM = ServiceTypeEnum.SERVICETYPE_L2NM TAPI_CONNECTIVITY_SERVICE = ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE TE = ServiceTypeEnum.SERVICETYPE_TE + E2E = ServiceTypeEnum.SERVICETYPE_E2E grpc_to_enum__service_type = functools.partial( grpc_to_enum, ServiceTypeEnum, ORM_ServiceTypeEnum) diff --git a/src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/Handlers.py b/src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/Handlers.py index 8490eb91581dc80f837e2baec851553560fc9deb..2192ea94214201697d196ca7546a906a13197a93 100644 --- a/src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/Handlers.py +++ b/src/nbi/service/rest_server/nbi_plugins/ietf_l3vpn/Handlers.py @@ -15,7 +15,7 @@ import logging, netaddr from typing import Dict, List, Optional, Tuple from common.Constants import DEFAULT_CONTEXT_NAME -from common.proto.context_pb2 import Service, ServiceStatusEnum +from common.proto.context_pb2 import Service, ServiceStatusEnum, ServiceTypeEnum from common.tools.context_queries.Service import get_service_by_uuid from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Constraints import ( @@ -35,6 +35,7 @@ def create_service( service_request = Service() service_request.service_id.context_id.context_uuid.uuid = context_uuid service_request.service_id.service_uuid.uuid = service_uuid + service_request.service_type = ServiceTypeEnum.SERVICETYPE_L3NM service_request.service_status.service_status = ServiceStatusEnum.SERVICESTATUS_PLANNED try: @@ -57,6 +58,7 @@ def update_service_endpoint( vlan_tag : int, ipv4_address : str, ipv4_prefix_length : int, capacity_gbps : Optional[float] = None, e2e_latency_ms : Optional[float] = None, availability : Optional[float] = None, mtu : Optional[int] = None, + static_routing : Optional[Dict[Tuple[str, str], str]] = None, context_uuid : Optional[str] = DEFAULT_CONTEXT_NAME, ) -> Optional[Exception]: context_client = ContextClient() @@ -79,6 +81,16 @@ def update_service_endpoint( if mtu is not None: service_settings['mtu'] = (mtu, True) update_config_rule_custom(config_rules, service_settings_key, service_settings) + if static_routing is not None: + service_static_routing_key = '/static_routing' + update_config_rule_custom(config_rules, service_static_routing_key, { + '{:d}-{:s}/{:d}'.format(lan_tag, ip_range, ip_prefix_len): ( + {'vlan-id': lan_tag, 'ip-network': '{:s}/{:d}'.format(ip_range, ip_prefix_len), 'next-hop': next_hop}, + True + ) + for (ip_range, ip_prefix_len, lan_tag), next_hop in static_routing.items() + }) + ENDPOINT_SETTINGS_KEY = '/device[{:s}]/endpoint[{:s}]/vlan[{:d}]/settings' endpoint_settings_key = ENDPOINT_SETTINGS_KEY.format(device_uuid, endpoint_uuid, vlan_tag) field_updates = {} @@ -166,7 +178,7 @@ def process_site_network_access( exc = update_service_endpoint( service_uuid, site_id, device_uuid, endpoint_uuid, vlan_tag, ipv4_provider_address, ipv4_prefix_length, capacity_gbps=service_bandwidth_gbps, e2e_latency_ms=max_e2e_latency_ms, availability=availability, - mtu=service_mtu + mtu=service_mtu, static_routing=site_static_routing ) if exc is not None: errors.append({'error': str(exc)}) diff --git a/src/nbi/tests/data/ietf_l3vpn_req_svc2.json b/src/nbi/tests/data/ietf_l3vpn_req_svc2.json index fa142f4fa318df8469d8bb057d34261a98664af1..2d2ea2c22e2bb490027b8033bb4fb94a39b35049 100644 --- a/src/nbi/tests/data/ietf_l3vpn_req_svc2.json +++ b/src/nbi/tests/data/ietf_l3vpn_req_svc2.json @@ -55,7 +55,7 @@ "site-network-accesses": { "site-network-access": [ { - "site-network-access-id": "service access 3", + "site-network-access-id": "500", "site-network-access-type": "ietf-l3vpn-svc:multipoint", "device-reference": "128.32.33.5", "vpn-attachment": { @@ -158,7 +158,7 @@ "site-network-accesses": { "site-network-access": [ { - "site-network-access-id": "service access 4", + "site-network-access-id": "500", "site-network-access-type": "ietf-l3vpn-svc:multipoint", "device-reference": "172.10.33.5", "vpn-attachment": { diff --git a/src/nbi/tests/data/topology-dummy.json b/src/nbi/tests/data/topology-dummy.json index 4735bf4465220432641793ab253d94de1365c534..f066051eedf4e2c09b6987ec781c9c17ea4afd82 100644 --- a/src/nbi/tests/data/topology-dummy.json +++ b/src/nbi/tests/data/topology-dummy.json @@ -366,6 +366,177 @@ "device_type": "emu-packet-router", "name": "128.32.10.1" }, + { + "components": [], + "controller_id": {}, + "device_config": { + "config_rules": [ + { + "action": 1, + "custom": { + "resource_key": "_connect/address", + "resource_value": "127.0.0.1" + } + }, + { + "action": 1, + "custom": { + "resource_key": "_connect/port", + "resource_value": 0 + } + }, + { + "action": 1, + "custom": { + "resource_key": "_connect/settings", + "resource_value": { + "endpoints": [ + { + "name": "200", + "type": "copper", + "uuid": "200" + }, + { + "name": "201", + "type": "copper", + "uuid": "201" + }, + { + "name": "500", + "type": "copper", + "uuid": "500" + } + ] + } + } + }, + { + "action": 1, + "custom": { + "resource_key": "/endpoints/endpoint[200]", + "resource_value": { + "name": "200", + "type": "copper", + "uuid": "200" + } + } + }, + { + "action": 1, + "custom": { + "resource_key": "/endpoints/endpoint[201]", + "resource_value": { + "name": "201", + "type": "copper", + "uuid": "201" + } + } + }, + { + "action": 1, + "custom": { + "resource_key": "/endpoints/endpoint[500]", + "resource_value": { + "name": "500", + "type": "copper", + "uuid": "500" + } + } + } + ] + }, + "device_drivers": [ + 0 + ], + "device_endpoints": [ + { + "endpoint_id": { + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "endpoint_uuid": { + "uuid": "227b6bb2-dacf-5b3d-84e9-c1d0c107bcd8" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + }, + "endpoint_location": {}, + "endpoint_type": "copper", + "kpi_sample_types": [], + "name": "201" + }, + { + "endpoint_id": { + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "endpoint_uuid": { + "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + }, + "endpoint_location": {}, + "endpoint_type": "copper", + "kpi_sample_types": [], + "name": "500" + }, + { + "endpoint_id": { + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "endpoint_uuid": { + "uuid": "d8528b70-9215-59ed-851d-b9590ab0c94b" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + }, + "endpoint_location": {}, + "endpoint_type": "copper", + "kpi_sample_types": [], + "name": "200" + } + ], + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "device_operational_status": 2, + "device_type": "emu-datacenter", + "name": "172.10.33.5" + }, { "components": [], "controller_id": {}, @@ -1917,6 +2088,60 @@ }, "name": "10.0.30.1-500" }, + { + "attributes": { + "total_capacity_gbps": 10.0, + "used_capacity_gbps": 0.0 + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "endpoint_uuid": { + "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "0392c251-b5d3-526b-8f3b-a3d4137829fa" + } + }, + "endpoint_uuid": { + "uuid": "1e35cf03-d55d-5648-9cb6-fca37bfbf23a" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + } + ], + "link_id": { + "link_uuid": { + "uuid": "36643dba-e8fa-5fb7-952d-dff313db957b" + } + }, + "name": "172.10.33.5-500" + }, { "link_endpoint_ids": [ { @@ -2337,6 +2562,60 @@ }, "name": "128.32.20.1-200" }, + { + "attributes": { + "total_capacity_gbps": 10.0, + "used_capacity_gbps": 0.0 + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "0392c251-b5d3-526b-8f3b-a3d4137829fa" + } + }, + "endpoint_uuid": { + "uuid": "1e35cf03-d55d-5648-9cb6-fca37bfbf23a" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, + "endpoint_uuid": { + "uuid": "3d0c36bb-80dc-5bab-8a7d-c47cce8d474f" + }, + "topology_id": { + "context_id": { + "context_uuid": { + "uuid": "admin" + } + }, + "topology_uuid": { + "uuid": "admin" + } + } + } + ], + "link_id": { + "link_uuid": { + "uuid": "808b54e8-3d5a-5e03-a42e-d6c2a57cf6f3" + } + }, + "name": "10.0.30.1-200" + }, { "link_endpoint_ids": [ { @@ -2671,6 +2950,11 @@ "uuid": "118295c8-318a-52ec-a394-529fc4b70f2f" } }, + { + "device_uuid": { + "uuid": "4c367472-545c-544d-935d-829f0a0e1c72" + } + }, { "device_uuid": { "uuid": "4f2234d0-a9b8-5a86-b1dd-9139d86e3925" @@ -2753,6 +3037,11 @@ "uuid": "35801e61-45f3-564e-ad5c-09baf4aae906" } }, + { + "link_uuid": { + "uuid": "36643dba-e8fa-5fb7-952d-dff313db957b" + } + }, { "link_uuid": { "uuid": "36856920-3387-5384-b1b1-dbc9e54da226" @@ -2793,6 +3082,11 @@ "uuid": "6fa77ad9-e4d7-5830-bf84-ab206eff613a" } }, + { + "link_uuid": { + "uuid": "808b54e8-3d5a-5e03-a42e-d6c2a57cf6f3" + } + }, { "link_uuid": { "uuid": "85a18715-3ce0-57f9-8025-5634fe622a06" diff --git a/src/nbi/tests/data/topology-real.json b/src/nbi/tests/data/topology-real.json index 72f04a1df987c0d41ddbd1cd5993ae874b60f8ef..bb158d920ecbd0bf3e9998f4bd856a349c9e91c7 100644 --- a/src/nbi/tests/data/topology-real.json +++ b/src/nbi/tests/data/topology-real.json @@ -114,7 +114,18 @@ {"uuid": "201", "name": "201", "type": "copper"}, {"uuid": "500", "name": "500", "type": "copper"} ]}}} - ]}} + ]}}, + + {"device_id": {"device_uuid": {"uuid": "172.10.33.5"}}, "name": "172.10.33.5", "device_type": "emu-datacenter", + "device_operational_status": 1, "device_drivers": [0], "device_config": {"config_rules": [ + {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}}, + {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}}, + {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [ + {"uuid": "200", "name": "200", "type": "copper"}, + {"uuid": "201", "name": "201", "type": "copper"}, + {"uuid": "500", "name": "500", "type": "copper"} + ]}}} + ]}} ], "links": [ @@ -232,6 +243,17 @@ "attributes": {"total_capacity_gbps": 10, "used_capacity_gbps": 0}, "link_endpoint_ids": [ {"device_id": {"device_uuid": {"uuid": "10.0.10.1"}}, "endpoint_uuid": {"uuid": "200"}}, {"device_id": {"device_uuid": {"uuid": "128.32.33.5"}}, "endpoint_uuid": {"uuid": "500"}} + ]}, + + {"link_id": {"link_uuid": {"uuid": "172.10.33.5-500"}}, "name": "172.10.33.5-500", + "attributes": {"total_capacity_gbps": 10, "used_capacity_gbps": 0}, "link_endpoint_ids": [ + {"device_id": {"device_uuid": {"uuid": "172.10.33.5"}}, "endpoint_uuid": {"uuid": "500"}}, + {"device_id": {"device_uuid": {"uuid": "10.0.30.1"}}, "endpoint_uuid": {"uuid": "200"}} + ]}, + {"link_id": {"link_uuid": {"uuid": "10.0.30.1-200"}}, "name": "10.0.30.1-200", + "attributes": {"total_capacity_gbps": 10, "used_capacity_gbps": 0}, "link_endpoint_ids": [ + {"device_id": {"device_uuid": {"uuid": "10.0.30.1"}}, "endpoint_uuid": {"uuid": "200"}}, + {"device_id": {"device_uuid": {"uuid": "172.10.33.5"}}, "endpoint_uuid": {"uuid": "500"}} ]} ] } diff --git a/src/service/Dockerfile b/src/service/Dockerfile index 3926770f887d20d7c6bb93ce787bf7550bc38f92..85454350f1eb9413af0ef995386868d09222121c 100644 --- a/src/service/Dockerfile +++ b/src/service/Dockerfile @@ -62,11 +62,15 @@ RUN python3 -m pip install -r requirements.txt # Add component files into working directory WORKDIR /var/teraflow -COPY src/context/. context/ -COPY src/device/. device/ -COPY src/pathcomp/frontend/. pathcomp/frontend/ COPY src/service/. service/ -COPY src/e2eorchestrator/. e2eorchestrator/ +COPY src/context/__init__.py context/__init__.py +COPY src/context/client/. context/client/ +COPY src/device/__init__.py device/__init__.py +COPY src/device/client/. device/client/ +COPY src/pathcomp/frontend/__init__.py pathcomp/frontend/__init__.py +COPY src/pathcomp/frontend/client/. pathcomp/frontend/client/ +COPY src/e2e_orchestrator/__init__.py e2e_orchestrator/__init__.py +COPY src/e2e_orchestrator/client/. e2e_orchestrator/client/ # Start the service ENTRYPOINT ["python", "-m", "service.service"] diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py index 9f15368fdd0714b1fe8886ca3fa07c3a85c6d03d..d7a983dc97cefd9a796ab97629ba2dbe58a71b22 100644 --- a/src/service/service/ServiceServiceServicerImpl.py +++ b/src/service/service/ServiceServiceServicerImpl.py @@ -26,7 +26,7 @@ from common.proto.service_pb2_grpc import ServiceServiceServicer from common.tools.context_queries.Service import get_service_by_id from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from context.client.ContextClient import ContextClient -from e2eorchestrator.client.E2EOrchestratorClient import E2EOrchestratorClient +from e2e_orchestrator.client.E2EOrchestratorClient import E2EOrchestratorClient from pathcomp.frontend.client.PathCompClient import PathCompClient from service.service.tools.ConnectionToString import connection_to_string from service.client.TEServiceClient import TEServiceClient