Skip to content
Snippets Groups Projects
Commit adfd2178 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tools - Mock MW SDN Ctrl:

- Renamed folder
- Improved error reporting
parent f29a712f
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!71OFC'23 + IETF L2VPN Device Driver + Device Controllers + Multiple small improvements
Showing
with 141 additions and 26 deletions
...@@ -37,30 +37,30 @@ LOG_LEVEL = logging.DEBUG ...@@ -37,30 +37,30 @@ LOG_LEVEL = logging.DEBUG
NETWORK_NODES = [ NETWORK_NODES = [
{'node-id': '172.18.0.1', 'ietf-network-topology:termination-point': [ {'node-id': '172.18.0.1', 'ietf-network-topology:termination-point': [
{'tp-id': '172.18.0.1:1', 'ietf-te-topology:te': {'name': 'ethernet'}}, {'tp-id': '1', 'ietf-te-topology:te': {'name': 'ethernet'}},
{'tp-id': '172.18.0.1:2', 'ietf-te-topology:te': {'name': 'antena' }}, {'tp-id': '2', 'ietf-te-topology:te': {'name': 'antena' }},
]}, ]},
{'node-id': '172.18.0.2', 'ietf-network-topology:termination-point': [ {'node-id': '172.18.0.2', 'ietf-network-topology:termination-point': [
{'tp-id': '172.18.0.2:1', 'ietf-te-topology:te': {'name': 'ethernet'}}, {'tp-id': '1', 'ietf-te-topology:te': {'name': 'ethernet'}},
{'tp-id': '172.18.0.2:2', 'ietf-te-topology:te': {'name': 'antena' }}, {'tp-id': '2', 'ietf-te-topology:te': {'name': 'antena' }},
]}, ]},
{'node-id': '172.18.0.3', 'ietf-network-topology:termination-point': [ {'node-id': '172.18.0.3', 'ietf-network-topology:termination-point': [
{'tp-id': '172.18.0.3:1', 'ietf-te-topology:te': {'name': 'ethernet'}}, {'tp-id': '1', 'ietf-te-topology:te': {'name': 'ethernet'}},
{'tp-id': '172.18.0.3:2', 'ietf-te-topology:te': {'name': 'antena' }}, {'tp-id': '2', 'ietf-te-topology:te': {'name': 'antena' }},
]}, ]},
{'node-id': '172.18.0.4', 'ietf-network-topology:termination-point': [ {'node-id': '172.18.0.4', 'ietf-network-topology:termination-point': [
{'tp-id': '172.18.0.4:1', 'ietf-te-topology:te': {'name': 'ethernet'}}, {'tp-id': '1', 'ietf-te-topology:te': {'name': 'ethernet'}},
{'tp-id': '172.18.0.4:2', 'ietf-te-topology:te': {'name': 'antena' }}, {'tp-id': '2', 'ietf-te-topology:te': {'name': 'antena' }},
]} ]}
] ]
NETWORK_LINKS = [ NETWORK_LINKS = [
{ {
'source' : {'source-node': '172.18.0.1', 'source-tp': '172.18.0.1:2'}, 'source' : {'source-node': '172.18.0.1', 'source-tp': '2'},
'destination': {'dest-node' : '172.18.0.2', 'dest-tp' : '172.18.0.2:2'}, 'destination': {'dest-node' : '172.18.0.2', 'dest-tp' : '2'},
}, },
{ {
'source' : {'source-node': '172.18.0.3', 'source-tp': '172.18.0.3:2'}, 'source' : {'source-node': '172.18.0.3', 'source-tp': '2'},
'destination': {'dest-node' : '172.18.0.4', 'dest-tp' : '172.18.0.4:2'}, 'destination': {'dest-node' : '172.18.0.4', 'dest-tp' : '2'},
} }
] ]
NETWORK_SERVICES = {} NETWORK_SERVICES = {}
...@@ -91,17 +91,21 @@ class Services(Resource): ...@@ -91,17 +91,21 @@ class Services(Resource):
return jsonify({'ietf-eth-tran-service:etht-svc': {'etht-svc-instances': services}}) return jsonify({'ietf-eth-tran-service:etht-svc': {'etht-svc-instances': services}})
def post(self): def post(self):
json_request = request.json try:
if not json_request: abort(400) json_request = request.json
if not isinstance(json_request, dict): abort(400) if not json_request: abort(400)
if 'etht-svc-instances' not in json_request: abort(400) if not isinstance(json_request, dict): abort(400)
json_services = json_request['etht-svc-instances'] if 'etht-svc-instances' not in json_request: abort(400)
if not isinstance(json_services, list): abort(400) json_services = json_request['etht-svc-instances']
if len(json_services) != 1: abort(400) if not isinstance(json_services, list): abort(400)
svc_data = json_services[0] if len(json_services) != 1: abort(400)
etht_svc_name = svc_data['etht-svc-name'] svc_data = json_services[0]
NETWORK_SERVICES[etht_svc_name] = svc_data etht_svc_name = svc_data['etht-svc-name']
return jsonify({}), 201 NETWORK_SERVICES[etht_svc_name] = svc_data
return jsonify({}), 201
except:
LOGGER.exception('Exception in POST')
class DelServices(Resource): class DelServices(Resource):
def delete(self, service_uuid : str): def delete(self, service_uuid : str):
......
...@@ -12,8 +12,8 @@ Follow the steps below to perform the test: ...@@ -12,8 +12,8 @@ Follow the steps below to perform the test:
## 1. Deploy TeraFlowSDN controller and the scenario ## 1. Deploy TeraFlowSDN controller and the scenario
Deploy the test scenario "microwave_deploy.sh": Deploy the test scenario "microwave_deploy.sh":
```bash ```bash
source src/tests/tools/microwave_deploy.sh source src/tests/tools/mock_mw_sdn_ctrl/scenario/microwave_deploy.sh
./deploy.sh ./deploy/all.sh
``` ```
## 2. Install requirements and run the Mock MicroWave SDN controller ## 2. Install requirements and run the Mock MicroWave SDN controller
...@@ -27,7 +27,7 @@ pip install Flask==2.1.3 Flask-RESTful==0.3.9 ...@@ -27,7 +27,7 @@ pip install Flask==2.1.3 Flask-RESTful==0.3.9
Run the Mock MicroWave SDN Controller as follows: Run the Mock MicroWave SDN Controller as follows:
```bash ```bash
python src/tests/tools/mock_sdn_ctrl/MockMWSdnCtrl.py python src/tests/tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py
``` ```
## 3. Deploy the test descriptors ## 3. Deploy the test descriptors
......
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.
FROM python:3.9-slim
# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0
# Get generic Python packages
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 -m pip install --upgrade pip-tools
# Create component sub-folder, and copy content
RUN mkdir -p /var/teraflow/mock_mw_sdn_ctrl
WORKDIR /var/teraflow/mock_mw_sdn_ctrl
COPY . .
# Get specific Python packages
RUN pip-compile --quiet --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt
# Start the service
ENTRYPOINT ["python", "MockMWSdnCtrl.py"]
#!/bin/bash
docker build -t mock-mw-sdn-ctrl:test -f Dockerfile .
docker tag mock-mw-sdn-ctrl:test localhost:32000/tfs/mock-mw-sdn-ctrl:test
docker push localhost:32000/tfs/mock-mw-sdn-ctrl:test
#!/bin/bash
kubectl delete namespace mocks
kubectl --namespace mocks apply -f mock-mw-sdn-ctrl.yaml
kind: Namespace
apiVersion: v1
metadata:
name: mocks
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mock-mw-sdn-ctrl
spec:
selector:
matchLabels:
app: mock-mw-sdn-ctrl
replicas: 1
template:
metadata:
labels:
app: mock-mw-sdn-ctrl
spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: localhost:32000/tfs/mock-mw-sdn-ctrl:test
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8443
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 700m
memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
name: mock-mw-sdn-ctrl
spec:
type: ClusterIP
selector:
app: mock-mw-sdn-ctrl
ports:
- name: https
port: 8443
targetPort: 8443
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.
cryptography==39.0.1
pyopenssl==23.0.0
Flask==2.1.3
Flask-HTTPAuth==4.5.0
Flask-RESTful==0.3.9
jsonschema==4.4.0
requests==2.27.1
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