Skip to content
Snippets Groups Projects
Commit 0b932520 authored by delacal's avatar delacal
Browse files

Merge branch 'develop' into feat/l3-components

parents 7079e9fc 316d412d
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!93Updated L3 components + scalability
Showing
with 353 additions and 1781 deletions
ecoc22 0 → 120000
src/tests/ecoc22/
\ No newline at end of file
......@@ -35,7 +35,7 @@ spec:
image: registry.gitlab.com/teraflow-h2020/controller/webui:latest
imagePullPolicy: Always
ports:
- containerPort: 8004 # TODO: define the real port
- containerPort: 8004
env:
- name: LOG_LEVEL
value: "DEBUG"
......
# Set the URL of your local Docker registry where the images will be uploaded to.
export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/"
# Set the list of components, separated by comas, you want to build images for, and deploy.
# Set the list of components, separated by spaces, you want to build images for, and deploy.
# Supported components are:
# context device automation policy service compute monitoring webui
# interdomain slice pathcomp dlt
......@@ -11,12 +10,6 @@ export TFS_COMPONENTS="context device automation service compute monitoring webu
# Set the tag you want to use for your images.
export TFS_IMAGE_TAG="dev"
# Set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE="tfs"
# Set additional manifest files to be applied after the deployment
export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"
# Set the neew Grafana admin password
export TFS_GRAFANA_PASSWORD="admin123+"
#!/bin/bash
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
mkdir -p tmp/exec_logs/$TFS_K8S_NAMESPACE/
rm tmp/exec_logs/$TFS_K8S_NAMESPACE/*
PODS=$(kubectl get pods --namespace $TFS_K8S_NAMESPACE --no-headers --output=custom-columns=":metadata.name")
for POD in $PODS; do
CONTAINERS=$(kubectl get pods --namespace $TFS_K8S_NAMESPACE $POD -o jsonpath='{.spec.containers[*].name}')
for CONTAINER in $CONTAINERS; do
kubectl --namespace $TFS_K8S_NAMESPACE logs pod/${POD} --container ${CONTAINER} \
> tmp/exec_logs/$TFS_K8S_NAMESPACE/$POD\_\_$CONTAINER.log
done
done
......@@ -21,4 +21,5 @@ RCFILE=$PROJECTDIR/coverage/.coveragerc
# Run unitary tests and analyze coverage of code at same time
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
service/tests/test_unitary_task_scheduler.py \
service/tests/test_unitary.py
#!/bin/bash
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/sliceservice
......@@ -21,7 +21,7 @@ class DeviceTypeEnum(Enum):
DATACENTER = 'datacenter'
MICROVAWE_RADIO_SYSTEM = 'microwave-radio-system'
OPTICAL_ROADM = 'optical-roadm'
OPTICAL_TRANDPONDER = 'optical-trandponder'
OPTICAL_TRANSPONDER = 'optical-transponder'
OPEN_LINE_SYSTEM = 'open-line-system'
PACKET_ROUTER = 'packet-router'
PACKET_SWITCH = 'packet-switch'
......
......@@ -56,3 +56,11 @@ class OperationFailedException(ServiceException):
details = 'Operation({:s}) failed'.format(str(operation))
super().__init__(grpc.StatusCode.INTERNAL, details, extra_details=extra_details)
class NotImplementedException(ServiceException):
def __init__(
self, operation : str, extra_details : Union[str, Iterable[str]] = None
) -> None:
details = 'Operation({:s}) not implemented'.format(str(operation))
super().__init__(grpc.StatusCode.UNIMPLEMENTED, details, extra_details=extra_details)
......@@ -44,10 +44,20 @@ def json_service(
def json_service_l3nm_planned(
service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [],
config_rules : List[Dict] = []
config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_UUID
):
return json_service(
service_uuid, ServiceTypeEnum.SERVICETYPE_L3NM, context_id=json_context_id(DEFAULT_CONTEXT_UUID),
service_uuid, ServiceTypeEnum.SERVICETYPE_L3NM, context_id=json_context_id(context_uuid),
status=ServiceStatusEnum.SERVICESTATUS_PLANNED, endpoint_ids=endpoint_ids, constraints=constraints,
config_rules=config_rules)
def json_service_tapi_planned(
service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [],
config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_UUID
):
return json_service(
service_uuid, ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE, context_id=json_context_id(context_uuid),
status=ServiceStatusEnum.SERVICESTATUS_PLANNED, endpoint_ids=endpoint_ids, constraints=constraints,
config_rules=config_rules)
......@@ -17,38 +17,50 @@ DEFAULT_ADDRESS_FAMILIES = ['IPV4']
DEFAULT_BGP_AS = 65000
DEFAULT_BGP_ROUTE_TARGET = '{:d}:{:d}'.format(DEFAULT_BGP_AS, 333)
# TODO: improve definition of bearer mappings
# Bearer mappings:
# device_uuid:endpoint_uuid => (
# device_uuid, endpoint_uuid, router_id, route_distinguisher, sub_if_index, address_ip, address_prefix)
BEARER_MAPPINGS = {
'R1-EMU:13/1/2': ('R1-EMU', '13/1/2', '10.10.10.1', '65000:100', 400, '3.3.2.1', 24),
'R2-EMU:13/1/2': ('R2-EMU', '13/1/2', '12.12.12.1', '65000:120', 450, '3.4.2.1', 24),
'R3-EMU:13/1/2': ('R3-EMU', '13/1/2', '20.20.20.1', '65000:200', 500, '3.3.1.1', 24),
'R4-EMU:13/1/2': ('R4-EMU', '13/1/2', '22.22.22.1', '65000:220', 550, '3.4.1.1', 24),
# OFC'22
#'R1-EMU:13/2/1': ('R1-EMU', '13/2/1', '10.10.10.1', '65000:100', 400, '3.3.2.1', 24),
#'R2-EMU:13/2/1': ('R2-EMU', '13/2/1', '12.12.12.1', '65000:120', 450, '3.4.2.1', 24),
#'R3-EMU:13/2/1': ('R3-EMU', '13/2/1', '20.20.20.1', '65000:200', 500, '3.3.1.1', 24),
#'R4-EMU:13/2/1': ('R4-EMU', '13/2/1', '22.22.22.1', '65000:220', 550, '3.4.1.1', 24),
# OECC/PSC'22 - domain 1
#'R1@D1:3/1': ('R1@D1', '3/1', '10.0.1.1', '65001:101', 100, '1.1.3.1', 24),
#'R1@D1:3/2': ('R1@D1', '3/2', '10.0.1.1', '65001:101', 100, '1.1.3.2', 24),
#'R1@D1:3/3': ('R1@D1', '3/3', '10.0.1.1', '65001:101', 100, '1.1.3.3', 24),
#'R2@D1:3/1': ('R2@D1', '3/1', '10.0.1.2', '65001:102', 100, '1.2.3.1', 24),
#'R2@D1:3/2': ('R2@D1', '3/2', '10.0.1.2', '65001:102', 100, '1.2.3.2', 24),
#'R2@D1:3/3': ('R2@D1', '3/3', '10.0.1.2', '65001:102', 100, '1.2.3.3', 24),
#'R3@D1:3/1': ('R3@D1', '3/1', '10.0.1.3', '65001:103', 100, '1.3.3.1', 24),
#'R3@D1:3/2': ('R3@D1', '3/2', '10.0.1.3', '65001:103', 100, '1.3.3.2', 24),
#'R3@D1:3/3': ('R3@D1', '3/3', '10.0.1.3', '65001:103', 100, '1.3.3.3', 24),
#'R4@D1:3/1': ('R4@D1', '3/1', '10.0.1.4', '65001:104', 100, '1.4.3.1', 24),
#'R4@D1:3/2': ('R4@D1', '3/2', '10.0.1.4', '65001:104', 100, '1.4.3.2', 24),
#'R4@D1:3/3': ('R4@D1', '3/3', '10.0.1.4', '65001:104', 100, '1.4.3.3', 24),
'R1@D1:3/1': ('R1@D1', '3/1', '10.0.1.1', '65001:101', 100, '1.1.3.1', 24),
'R1@D1:3/2': ('R1@D1', '3/2', '10.0.1.1', '65001:101', 100, '1.1.3.2', 24),
'R1@D1:3/3': ('R1@D1', '3/3', '10.0.1.1', '65001:101', 100, '1.1.3.3', 24),
'R2@D1:3/1': ('R2@D1', '3/1', '10.0.1.2', '65001:102', 100, '1.2.3.1', 24),
'R2@D1:3/2': ('R2@D1', '3/2', '10.0.1.2', '65001:102', 100, '1.2.3.2', 24),
'R2@D1:3/3': ('R2@D1', '3/3', '10.0.1.2', '65001:102', 100, '1.2.3.3', 24),
'R3@D1:3/1': ('R3@D1', '3/1', '10.0.1.3', '65001:103', 100, '1.3.3.1', 24),
'R3@D1:3/2': ('R3@D1', '3/2', '10.0.1.3', '65001:103', 100, '1.3.3.2', 24),
'R3@D1:3/3': ('R3@D1', '3/3', '10.0.1.3', '65001:103', 100, '1.3.3.3', 24),
'R4@D1:3/1': ('R4@D1', '3/1', '10.0.1.4', '65001:104', 100, '1.4.3.1', 24),
'R4@D1:3/2': ('R4@D1', '3/2', '10.0.1.4', '65001:104', 100, '1.4.3.2', 24),
'R4@D1:3/3': ('R4@D1', '3/3', '10.0.1.4', '65001:104', 100, '1.4.3.3', 24),
# OECC/PSC'22 - domain 2
#'R1@D2:3/1': ('R1@D2', '3/1', '10.0.2.1', '65002:101', 100, '2.1.3.1', 24),
#'R1@D2:3/2': ('R1@D2', '3/2', '10.0.2.1', '65002:101', 100, '2.1.3.2', 24),
#'R1@D2:3/3': ('R1@D2', '3/3', '10.0.2.1', '65002:101', 100, '2.1.3.3', 24),
#'R2@D2:3/1': ('R2@D2', '3/1', '10.0.2.2', '65002:102', 100, '2.2.3.1', 24),
#'R2@D2:3/2': ('R2@D2', '3/2', '10.0.2.2', '65002:102', 100, '2.2.3.2', 24),
#'R2@D2:3/3': ('R2@D2', '3/3', '10.0.2.2', '65002:102', 100, '2.2.3.3', 24),
#'R3@D2:3/1': ('R3@D2', '3/1', '10.0.2.3', '65002:103', 100, '2.3.3.1', 24),
#'R3@D2:3/2': ('R3@D2', '3/2', '10.0.2.3', '65002:103', 100, '2.3.3.2', 24),
#'R3@D2:3/3': ('R3@D2', '3/3', '10.0.2.3', '65002:103', 100, '2.3.3.3', 24),
#'R4@D2:3/1': ('R4@D2', '3/1', '10.0.2.4', '65002:104', 100, '2.4.3.1', 24),
#'R4@D2:3/2': ('R4@D2', '3/2', '10.0.2.4', '65002:104', 100, '2.4.3.2', 24),
#'R4@D2:3/3': ('R4@D2', '3/3', '10.0.2.4', '65002:104', 100, '2.4.3.3', 24),
'R1@D2:3/1': ('R1@D2', '3/1', '10.0.2.1', '65002:101', 100, '2.1.3.1', 24),
'R1@D2:3/2': ('R1@D2', '3/2', '10.0.2.1', '65002:101', 100, '2.1.3.2', 24),
'R1@D2:3/3': ('R1@D2', '3/3', '10.0.2.1', '65002:101', 100, '2.1.3.3', 24),
'R2@D2:3/1': ('R2@D2', '3/1', '10.0.2.2', '65002:102', 100, '2.2.3.1', 24),
'R2@D2:3/2': ('R2@D2', '3/2', '10.0.2.2', '65002:102', 100, '2.2.3.2', 24),
'R2@D2:3/3': ('R2@D2', '3/3', '10.0.2.2', '65002:102', 100, '2.2.3.3', 24),
'R3@D2:3/1': ('R3@D2', '3/1', '10.0.2.3', '65002:103', 100, '2.3.3.1', 24),
'R3@D2:3/2': ('R3@D2', '3/2', '10.0.2.3', '65002:103', 100, '2.3.3.2', 24),
'R3@D2:3/3': ('R3@D2', '3/3', '10.0.2.3', '65002:103', 100, '2.3.3.3', 24),
'R4@D2:3/1': ('R4@D2', '3/1', '10.0.2.4', '65002:104', 100, '2.4.3.1', 24),
'R4@D2:3/2': ('R4@D2', '3/2', '10.0.2.4', '65002:104', 100, '2.4.3.2', 24),
'R4@D2:3/3': ('R4@D2', '3/3', '10.0.2.4', '65002:104', 100, '2.4.3.3', 24),
}
\ No newline at end of file
# ECOC'22
# bearer_ref => device_uuid, endpoint_uuid, sub_if_index, router_id, remote_router, circuit_id
'DC1-GW:CS1-GW1': ('CS1-GW1', '10/1', 0, '5.5.1.1', '5.5.2.1', 111),
'DC1-GW:CS1-GW2': ('CS1-GW2', '10/1', 0, '5.5.1.2', '5.5.2.2', 222),
'DC2-GW:CS2-GW1': ('CS2-GW1', '10/1', 0, '5.5.2.1', '5.5.1.1', 111),
'DC2-GW:CS2-GW2': ('CS2-GW2', '10/1', 0, '5.5.2.2', '5.5.1.2', 222),
}
......@@ -20,6 +20,7 @@ from common.Constants import DEFAULT_CONTEXT_UUID
from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, SliceStatusEnum
from context.client.ContextClient import ContextClient
from service.client.ServiceClient import ServiceClient
from slice.client.SliceClient import SliceClient
from .tools.Authentication import HTTP_AUTH
from .tools.ContextMethods import get_service, get_slice
from .tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR
......@@ -32,31 +33,32 @@ class L2VPN_Service(Resource):
LOGGER.debug('VPN_Id: {:s}'.format(str(vpn_id)))
LOGGER.debug('Request: {:s}'.format(str(request)))
response = jsonify({})
try:
context_client = ContextClient()
target = get_service(context_client, vpn_id)
if target is not None:
if target.service_id.service_uuid.uuid != vpn_id: # pylint: disable=no-member
raise Exception('Service retrieval failed. Wrong Service Id was returned')
service_ready_status = ServiceStatusEnum.SERVICESTATUS_ACTIVE
service_status = target.service_status.service_status # pylint: disable=no-member
response.status_code = HTTP_OK if service_status == service_ready_status else HTTP_GATEWAYTIMEOUT
return response
target = get_slice(context_client, vpn_id)
if target is not None:
if target.slice_id.slice_uuid.uuid != vpn_id: # pylint: disable=no-member
raise Exception('Slice retrieval failed. Wrong Slice Id was returned')
slice_ready_status = SliceStatusEnum.SLICESTATUS_ACTIVE
slice_status = target.slice_status.slice_status # pylint: disable=no-member
response = jsonify({})
response.status_code = HTTP_OK if slice_status == slice_ready_status else HTTP_GATEWAYTIMEOUT
return response
target = get_service(context_client, vpn_id)
if target is not None:
if target.service_id.service_uuid.uuid != vpn_id: # pylint: disable=no-member
raise Exception('Service retrieval failed. Wrong Service Id was returned')
service_ready_status = ServiceStatusEnum.SERVICESTATUS_ACTIVE
service_status = target.service_status.service_status # pylint: disable=no-member
response = jsonify({})
response.status_code = HTTP_OK if service_status == service_ready_status else HTTP_GATEWAYTIMEOUT
return response
raise Exception('VPN({:s}) not found in database'.format(str(vpn_id)))
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('Something went wrong Retrieving VPN({:s})'.format(str(request)))
LOGGER.exception('Something went wrong Retrieving VPN({:s})'.format(str(vpn_id)))
response = jsonify({'error': str(e)})
response.status_code = HTTP_SERVERERROR
return response
......@@ -66,18 +68,35 @@ class L2VPN_Service(Resource):
LOGGER.debug('VPN_Id: {:s}'.format(str(vpn_id)))
LOGGER.debug('Request: {:s}'.format(str(request)))
# pylint: disable=no-member
service_id_request = ServiceId()
service_id_request.context_id.context_uuid.uuid = DEFAULT_CONTEXT_UUID
service_id_request.service_uuid.uuid = vpn_id
try:
service_client = ServiceClient()
service_client.DeleteService(service_id_request)
context_client = ContextClient()
target = get_slice(context_client, vpn_id)
if target is not None:
if target.slice_id.slice_uuid.uuid != vpn_id: # pylint: disable=no-member
raise Exception('Slice retrieval failed. Wrong Slice Id was returned')
slice_client = SliceClient()
slice_client.DeleteSlice(target.slice_id)
response = jsonify({})
response.status_code = HTTP_NOCONTENT
return response
target = get_service(context_client, vpn_id)
if target is not None:
if target.service_id.service_uuid.uuid != vpn_id: # pylint: disable=no-member
raise Exception('Service retrieval failed. Wrong Service Id was returned')
service_client = ServiceClient()
service_client.DeleteService(target.service_id)
response = jsonify({})
response.status_code = HTTP_NOCONTENT
return response
LOGGER.warning('VPN({:s}) not found in database. Nothing done.'.format(str(vpn_id)))
response = jsonify({})
response.status_code = HTTP_NOCONTENT
return response
except Exception as e: # pylint: disable=broad-except
LOGGER.exception('Something went wrong Deleting Service {:s}'.format(str(request)))
LOGGER.exception('Something went wrong Deleting VPN({:s})'.format(str(vpn_id)))
response = jsonify({'error': str(e)})
response.status_code = HTTP_SERVERERROR
return response
......@@ -44,7 +44,11 @@ class L2VPN_Services(Resource):
vpn_services : List[Dict] = request_data['ietf-l2vpn-svc:vpn-service']
for vpn_service in vpn_services:
try:
vpn_service_type = vpn_service['vpn-svc-type']
# By now, assume requests from OSM always need transport slices
# TODO: think how to differentiate
#vpn_service_type = vpn_service['vpn-svc-type']
vpn_service_type = 'vpls'
if vpn_service_type == 'vpws':
# pylint: disable=no-member
service_request = Service()
......
......@@ -12,15 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from ctypes import Union
import json, logging
from typing import Dict
import logging
from typing import Dict, Optional, Union
from flask import request
from flask.json import jsonify
from flask.wrappers import Response
from flask_restful import Resource
from werkzeug.exceptions import UnsupportedMediaType
from common.proto.context_pb2 import ConfigActionEnum, Service, Slice
from common.proto.context_pb2 import Service, Slice
from common.tools.grpc.ConfigRules import update_config_rule_custom
from common.tools.grpc.Constraints import (
update_constraint_custom, update_constraint_endpoint_location, update_constraint_endpoint_priority,
update_constraint_sla_availability)
from common.tools.grpc.EndPointIds import update_endpoint_ids
from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient
from service.client.ServiceClient import ServiceClient
......@@ -30,150 +34,102 @@ from .tools.Authentication import HTTP_AUTH
from .tools.ContextMethods import get_service, get_slice
from .tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR
from .tools.Validator import validate_message
from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU
from .Constants import (
BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU)
LOGGER = logging.getLogger(__name__)
def process_site_network_access(context_client : ContextClient, site_network_access : Dict) -> Service:
def process_site_network_access(context_client : ContextClient, site_id : str, site_network_access : Dict) -> Service:
vpn_id = site_network_access['vpn-attachment']['vpn-id']
cvlan_id = site_network_access['connection']['tagged-interface']['dot1q-vlan-tagged']['cvlan-id']
encapsulation_type = site_network_access['connection']['encapsulation-type']
cvlan_id = site_network_access['connection']['tagged-interface'][encapsulation_type]['cvlan-id']
bearer_reference = site_network_access['bearer']['bearer-reference']
access_priority : Optional[int] = site_network_access.get('availability', {}).get('access-priority')
single_active : bool = len(site_network_access.get('availability', {}).get('single-active', [])) > 0
all_active : bool = len(site_network_access.get('availability', {}).get('all-active', [])) > 0
diversity_constraints = site_network_access.get('access-diversity', {}).get('constraints', {}).get('constraint', [])
raise_if_differs = True
diversity_constraints = {
constraint['constraint-type']:([
target[0]
for target in constraint['target'].items()
if len(target[1]) == 1
][0], raise_if_differs)
for constraint in diversity_constraints
}
mapping = BEARER_MAPPINGS.get(bearer_reference)
if mapping is None:
msg = 'Specified Bearer({:s}) is not configured.'
raise Exception(msg.format(str(bearer_reference)))
device_uuid,endpoint_uuid,router_id,route_distinguisher,sub_if_index,address_ip,address_prefix = mapping
#device_uuid,endpoint_uuid,router_id,route_dist,sub_if_index,address_ip,address_prefix = mapping
route_dist, address_ip, address_prefix = None, None, None
device_uuid, endpoint_uuid, sub_if_index, router_id, remote_router, circuit_id = mapping
target : Union[Service, Slice, None] = None
if target is None: target = get_service(context_client, vpn_id)
if target is None: target = get_slice (context_client, vpn_id)
if target is None: target = get_service(context_client, vpn_id)
if target is None: raise Exception('VPN({:s}) not found in database'.format(str(vpn_id)))
# pylint: disable=no-member
endpoint_ids = target.service_endpoint_ids if isinstance(target, Service) else target.slice_endpoint_ids
for endpoint_id in endpoint_ids:
if endpoint_id.device_id.device_uuid.uuid != device_uuid: continue
if endpoint_id.endpoint_uuid.uuid != endpoint_uuid: continue
break # found, do nothing
if isinstance(target, Service):
endpoint_ids = target.service_endpoint_ids # pylint: disable=no-member
config_rules = target.service_config.config_rules # pylint: disable=no-member
constraints = target.service_constraints # pylint: disable=no-member
elif isinstance(target, Slice):
endpoint_ids = target.slice_endpoint_ids # pylint: disable=no-member
config_rules = target.slice_config.config_rules # pylint: disable=no-member
constraints = target.slice_constraints # pylint: disable=no-member
else:
# not found, add it
endpoint_id = endpoint_ids.add()
endpoint_id.device_id.device_uuid.uuid = device_uuid
endpoint_id.endpoint_uuid.uuid = endpoint_uuid
if isinstance(target, Slice): return target
for config_rule in target.service_config.config_rules: # pylint: disable=no-member
if config_rule.WhichOneof('config_rule') != 'custom': continue
if config_rule.custom.resource_key != '/settings': continue
json_settings = json.loads(config_rule.custom.resource_value)
if 'mtu' not in json_settings: # missing, add it
json_settings['mtu'] = DEFAULT_MTU
elif json_settings['mtu'] != DEFAULT_MTU: # differs, raise exception
msg = 'Specified MTU({:s}) differs from Service MTU({:s})'
raise Exception(msg.format(str(json_settings['mtu']), str(DEFAULT_MTU)))
if 'address_families' not in json_settings: # missing, add it
json_settings['address_families'] = DEFAULT_ADDRESS_FAMILIES
elif json_settings['address_families'] != DEFAULT_ADDRESS_FAMILIES: # differs, raise exception
msg = 'Specified AddressFamilies({:s}) differs from Service AddressFamilies({:s})'
raise Exception(msg.format(str(json_settings['address_families']), str(DEFAULT_ADDRESS_FAMILIES)))
if 'bgp_as' not in json_settings: # missing, add it
json_settings['bgp_as'] = DEFAULT_BGP_AS
elif json_settings['bgp_as'] != DEFAULT_BGP_AS: # differs, raise exception
msg = 'Specified BgpAs({:s}) differs from Service BgpAs({:s})'
raise Exception(msg.format(str(json_settings['bgp_as']), str(DEFAULT_BGP_AS)))
if 'bgp_route_target' not in json_settings: # missing, add it
json_settings['bgp_route_target'] = DEFAULT_BGP_ROUTE_TARGET
elif json_settings['bgp_route_target'] != DEFAULT_BGP_ROUTE_TARGET: # differs, raise exception
msg = 'Specified BgpRouteTarget({:s}) differs from Service BgpRouteTarget({:s})'
raise Exception(msg.format(str(json_settings['bgp_route_target']), str(DEFAULT_BGP_ROUTE_TARGET)))
config_rule.custom.resource_value = json.dumps(json_settings, sort_keys=True)
break
else:
# not found, add it
config_rule = target.service_config.config_rules.add() # pylint: disable=no-member
config_rule.action = ConfigActionEnum.CONFIGACTION_SET
config_rule.custom.resource_key = '/settings'
config_rule.custom.resource_value = json.dumps({
'mtu' : DEFAULT_MTU,
'address_families': DEFAULT_ADDRESS_FAMILIES,
'bgp_as' : DEFAULT_BGP_AS,
'bgp_route_target': DEFAULT_BGP_ROUTE_TARGET,
}, sort_keys=True)
raise Exception('Target({:s}) not supported'.format(str(target.__class__.__name__)))
endpoint_id = update_endpoint_ids(endpoint_ids, device_uuid, endpoint_uuid)
service_settings_key = '/settings'
update_config_rule_custom(config_rules, service_settings_key, {
'mtu' : (DEFAULT_MTU, True),
#'address_families': (DEFAULT_ADDRESS_FAMILIES, True),
#'bgp_as' : (DEFAULT_BGP_AS, True),
#'bgp_route_target': (DEFAULT_BGP_ROUTE_TARGET, True),
})
endpoint_settings_key = '/device[{:s}]/endpoint[{:s}]/settings'.format(device_uuid, endpoint_uuid)
for config_rule in target.service_config.config_rules: # pylint: disable=no-member
if config_rule.WhichOneof('config_rule') != 'custom': continue
if config_rule.custom.resource_key != endpoint_settings_key: continue
json_settings = json.loads(config_rule.custom.resource_value)
if 'router_id' not in json_settings: # missing, add it
json_settings['router_id'] = router_id
elif json_settings['router_id'] != router_id: # differs, raise exception
msg = 'Specified RouterId({:s}) differs from Service RouterId({:s})'
raise Exception(msg.format(str(json_settings['router_id']), str(router_id)))
if 'route_distinguisher' not in json_settings: # missing, add it
json_settings['route_distinguisher'] = route_distinguisher
elif json_settings['route_distinguisher'] != route_distinguisher: # differs, raise exception
msg = 'Specified RouteDistinguisher({:s}) differs from Service RouteDistinguisher({:s})'
raise Exception(msg.format(str(json_settings['route_distinguisher']), str(route_distinguisher)))
if 'sub_interface_index' not in json_settings: # missing, add it
json_settings['sub_interface_index'] = sub_if_index
elif json_settings['sub_interface_index'] != sub_if_index: # differs, raise exception
msg = 'Specified SubInterfaceIndex({:s}) differs from Service SubInterfaceIndex({:s})'
raise Exception(msg.format(
str(json_settings['sub_interface_index']), str(sub_if_index)))
if 'vlan_id' not in json_settings: # missing, add it
json_settings['vlan_id'] = cvlan_id
elif json_settings['vlan_id'] != cvlan_id: # differs, raise exception
msg = 'Specified VLANId({:s}) differs from Service VLANId({:s})'
raise Exception(msg.format(
str(json_settings['vlan_id']), str(cvlan_id)))
if 'address_ip' not in json_settings: # missing, add it
json_settings['address_ip'] = address_ip
elif json_settings['address_ip'] != address_ip: # differs, raise exception
msg = 'Specified AddressIP({:s}) differs from Service AddressIP({:s})'
raise Exception(msg.format(
str(json_settings['address_ip']), str(address_ip)))
if 'address_prefix' not in json_settings: # missing, add it
json_settings['address_prefix'] = address_prefix
elif json_settings['address_prefix'] != address_prefix: # differs, raise exception
msg = 'Specified AddressPrefix({:s}) differs from Service AddressPrefix({:s})'
raise Exception(msg.format(
str(json_settings['address_prefix']), str(address_prefix)))
config_rule.custom.resource_value = json.dumps(json_settings, sort_keys=True)
break
else:
# not found, add it
config_rule = target.service_config.config_rules.add() # pylint: disable=no-member
config_rule.action = ConfigActionEnum.CONFIGACTION_SET
config_rule.custom.resource_key = endpoint_settings_key
config_rule.custom.resource_value = json.dumps({
'router_id': router_id,
'route_distinguisher': route_distinguisher,
'sub_interface_index': sub_if_index,
'vlan_id': cvlan_id,
'address_ip': address_ip,
'address_prefix': address_prefix,
}, sort_keys=True)
field_updates = {}
if router_id is not None: field_updates['router_id' ] = (router_id, True)
if route_dist is not None: field_updates['route_distinguisher'] = (route_dist, True)
if sub_if_index is not None: field_updates['sub_interface_index'] = (sub_if_index, True)
if cvlan_id is not None: field_updates['vlan_id' ] = (cvlan_id, True)
if address_ip is not None: field_updates['address_ip' ] = (address_ip, True)
if address_prefix is not None: field_updates['address_prefix' ] = (address_prefix, True)
if remote_router is not None: field_updates['remote_router' ] = (remote_router, True)
if circuit_id is not None: field_updates['circuit_id' ] = (circuit_id, True)
update_config_rule_custom(config_rules, endpoint_settings_key, field_updates)
field_updates = {}
if len(diversity_constraints) > 0:
field_updates.update(diversity_constraints)
update_constraint_custom(constraints, 'diversity', field_updates)
update_constraint_endpoint_location(constraints, endpoint_id, region=site_id)
if access_priority is not None: update_constraint_endpoint_priority(constraints, endpoint_id, access_priority)
if single_active or all_active:
# assume 1 disjoint path per endpoint/location included in service/slice
location_endpoints = {}
for constraint in constraints:
if constraint.WhichOneof('constraint') != 'endpoint_location': continue
str_endpoint_id = grpc_message_to_json_string(constraint.endpoint_location.endpoint_id)
str_location_id = grpc_message_to_json_string(constraint.endpoint_location.location)
location_endpoints.setdefault(str_location_id, set()).add(str_endpoint_id)
num_endpoints_per_location = {len(endpoints) for endpoints in location_endpoints.values()}
num_disjoint_paths = min(num_endpoints_per_location)
update_constraint_sla_availability(constraints, num_disjoint_paths, all_active)
return target
def process_list_site_network_access(
context_client : ContextClient, service_client : ServiceClient, slice_client : SliceClient,
context_client : ContextClient, service_client : ServiceClient, slice_client : SliceClient, site_id : str,
request_data : Dict
) -> Response:
......@@ -182,7 +138,7 @@ def process_list_site_network_access(
errors = []
for site_network_access in request_data['ietf-l2vpn-svc:site-network-access']:
sna_request = process_site_network_access(context_client, site_network_access)
sna_request = process_site_network_access(context_client, site_id, site_network_access)
LOGGER.debug('sna_request = {:s}'.format(grpc_message_to_json_string(sna_request)))
try:
if isinstance(sna_request, Service):
......@@ -196,7 +152,7 @@ def process_list_site_network_access(
else:
raise NotImplementedError('Support for Class({:s}) not implemented'.format(str(type(sna_request))))
except Exception as e: # pylint: disable=broad-except
msg = 'Something went wrong Updating Service {:s}'
msg = 'Something went wrong Updating VPN {:s}'
LOGGER.exception(msg.format(grpc_message_to_json_string(sna_request)))
errors.append({'error': str(e)})
......@@ -212,7 +168,7 @@ class L2VPN_SiteNetworkAccesses(Resource):
context_client = ContextClient()
service_client = ServiceClient()
slice_client = SliceClient()
return process_list_site_network_access(context_client, service_client, slice_client, request.json)
return process_list_site_network_access(context_client, service_client, slice_client, site_id, request.json)
@HTTP_AUTH.login_required
def put(self, site_id : str):
......@@ -221,4 +177,4 @@ class L2VPN_SiteNetworkAccesses(Resource):
context_client = ContextClient()
service_client = ServiceClient()
slice_client = SliceClient()
return process_list_site_network_access(context_client, service_client, slice_client, request.json)
return process_list_site_network_access(context_client, service_client, slice_client, site_id, request.json)
......@@ -33,6 +33,7 @@ the Layer 2 service.
import requests
import uuid
import logging
import copy
#from osm_ro_plugin.sdnconn import SdnConnectorBase, SdnConnectorError
from .sdnconn import SdnConnectorBase, SdnConnectorError
......@@ -222,8 +223,29 @@ class WimconnectorIETFL2VPN(SdnConnectorBase):
http_code=response_service_creation.status_code,
)
"""Second step, create the connections and vpn attachments"""
self.logger.info('connection_points = {:s}'.format(str(connection_points)))
# Check if protected paths are requested
extended_connection_points = []
for connection_point in connection_points:
extended_connection_points.append(connection_point)
connection_point_wan_info = self.search_mapp(connection_point)
service_mapping_info = connection_point_wan_info.get('service_mapping_info', {})
redundant_service_endpoint_ids = service_mapping_info.get('redundant')
if redundant_service_endpoint_ids is None: continue
if len(redundant_service_endpoint_ids) == 0: continue
for redundant_service_endpoint_id in redundant_service_endpoint_ids:
redundant_connection_point = copy.deepcopy(connection_point)
redundant_connection_point['service_endpoint_id'] = redundant_service_endpoint_id
extended_connection_points.append(redundant_connection_point)
self.logger.info('extended_connection_points = {:s}'.format(str(extended_connection_points)))
"""Second step, create the connections and vpn attachments"""
for connection_point in extended_connection_points:
connection_point_wan_info = self.search_mapp(connection_point)
site_network_access = {}
connection = {}
......@@ -264,6 +286,23 @@ class WimconnectorIETFL2VPN(SdnConnectorBase):
site_network_access["bearer"] = connection_point_wan_info[
"service_mapping_info"
]["bearer"]
access_priority = connection_point_wan_info["service_mapping_info"].get("priority")
if access_priority is not None:
availability = {}
availability["access-priority"] = access_priority
availability["single-active"] = [None]
site_network_access["availability"] = availability
constraint = {}
constraint['constraint-type'] = 'end-to-end-diverse'
constraint['target'] = {'all-other-accesses': [None]}
access_diversity = {}
access_diversity['constraints'] = {'constraint': []}
access_diversity['constraints']['constraint'].append(constraint)
site_network_access["access-diversity"] = access_diversity
site_network_accesses = {}
site_network_access_list = []
site_network_access_list.append(site_network_access)
......
This diff is collapsed.
......@@ -34,7 +34,7 @@ def main():
global LOGGER # pylint: disable=global-statement
log_level = get_log_level()
logging.basicConfig(level=log_level)
logging.basicConfig(level=log_level, format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s")
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING)
logging.getLogger('monitoring-client').setLevel(logging.WARNING)
......
......@@ -60,7 +60,7 @@ if LOAD_ALL_DEVICE_DRIVERS:
(TransportApiDriver, [
{
# Real OLS, specifying TAPI Driver => use TransportApiDriver
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPTICAL_LINE_SYSTEM,
FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPEN_LINE_SYSTEM,
FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.TRANSPORT_API,
}
]))
......
......@@ -20,7 +20,7 @@ from .Tools import add_value_from_collection, add_value_from_tag
LOGGER = logging.getLogger(__name__)
XPATH_PORTS = "//ocp:components/ocp:component/ocp:state[ocp:type='PORT']/.."
XPATH_PORTS = "//ocp:components/ocp:component"
XPATH_IFACE_COUNTER = "//oci:interfaces/oci:interface[oci:name='{:s}']/state/counters/{:s}"
def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
......@@ -28,6 +28,13 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
for xml_component in xml_data.xpath(XPATH_PORTS, namespaces=NAMESPACES):
#LOGGER.info('xml_component = {:s}'.format(str(ET.tostring(xml_component))))
component_type = xml_component.find('ocp:state/ocp:type', namespaces=NAMESPACES)
if component_type is None or component_type.text is None: continue
component_type = component_type.text
if component_type not in {'PORT', 'oc-platform-types:PORT'}: continue
LOGGER.info('PORT xml_component = {:s}'.format(str(ET.tostring(xml_component))))
endpoint = {}
component_name = xml_component.find('ocp:name', namespaces=NAMESPACES)
......
<interfaces xmlns="http://openconfig.net/yang/interfaces"
xmlns:oc-ip="http://openconfig.net/yang/interfaces/ip" >
<interface>
<name>{{name}}</name>
<config>
<name>{{name}}</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type>
{% if mtu is defined %}<mtu>{{mtu}}</mtu>{% endif%}
<enabled>true</enabled>
</config>
<subinterfaces>
<subinterface>
<index>{{index}}</index>
<interface>
<name>{{name}}</name>
<config>
<index>{{index}}</index>
<description>{{description}}</description>
{% if vendor=="ADVA" and vlan_id is not defined %}
<untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed>
{% endif%}
<name>{{name}}</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:{{type}}</type>
{% if mtu is defined %}<mtu>{{mtu}}</mtu>{% endif%}
<enabled>true</enabled>
</config>
{% if vlan_id is defined %}
<vlan xmlns="http://openconfig.net/yang/vlan">
<match>
<single-tagged>
<config>
<vlan-id>{{vlan_id}}</vlan-id>
</config>
</single-tagged>
</match>
</vlan>
{% endif%}
{% if address_ip is defined %}
<oc-ip:ipv4>
<oc-ip:addresses>
<oc-ip:address>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:config>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length>
</oc-ip:config>
</oc-ip:address>
</oc-ip:addresses>
</oc-ip:ipv4>
{% endif%}
</subinterface>
</subinterfaces>
</interface>
<subinterfaces>
<subinterface>
<index>{{index}}</index>
<config>
<index>{{index}}</index>
<description>{{description}}</description>
{% if vendor=="ADVA" and vlan_id is not defined %}
<untagged-allowed xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces">true</untagged-allowed>
{% endif%}
</config>
{% if vlan_id is defined %}
<vlan xmlns="http://openconfig.net/yang/vlan">
<match>
<single-tagged>
<config>
<vlan-id>{{vlan_id}}</vlan-id>
</config>
</single-tagged>
</match>
</vlan>
{% endif %}
{% if address_ip is defined %}
<oc-ip:ipv4>
<oc-ip:addresses>
<oc-ip:address>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:config>
<oc-ip:ip>{{address_ip}}</oc-ip:ip>
<oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length>
</oc-ip:config>
</oc-ip:address>
</oc-ip:addresses>
</oc-ip:ipv4>
{% endif %}
</subinterface>
</subinterfaces>
</interface>
</interfaces>
......@@ -26,4 +26,4 @@
</connection-point>
</connection-points>
</network-instance>
</network-instances>
\ No newline at end of file
</network-instances>
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