Skip to content
Snippets Groups Projects
Commit c98b136b authored by Carlos Manso's avatar Carlos Manso
Browse files

update

parent aa273225
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!225Resolve "Integrate Support for IP-E2E-Optical SDN controllers to manage hierarchical virtual topologies"
Showing
with 127 additions and 90 deletions
...@@ -41,7 +41,7 @@ spec: ...@@ -41,7 +41,7 @@ spec:
- containerPort: 8762 - containerPort: 8762
env: env:
- name: LOG_LEVEL - name: LOG_LEVEL
value: "INFO" value: "DEBUG"
readinessProbe: readinessProbe:
exec: exec:
command: ["/bin/grpc_health_probe", "-addr=:9090"] command: ["/bin/grpc_health_probe", "-addr=:9090"]
...@@ -83,15 +83,3 @@ spec: ...@@ -83,15 +83,3 @@ spec:
protocol: TCP protocol: TCP
port: 8762 port: 8762
targetPort: 8762 targetPort: 8762
---
apiVersion: v1
kind: Service
metadata:
name: remote-teraflow
spec:
type: ExternalName
externalName: nbiservice.asdf.svc.cluster.local
ports:
- name: ws
protocol: TCP
port: 8762
...@@ -259,6 +259,7 @@ message Link { ...@@ -259,6 +259,7 @@ message Link {
string name = 2; string name = 2;
repeated EndPointId link_endpoint_ids = 3; repeated EndPointId link_endpoint_ids = 3;
LinkAttributes attributes = 4; LinkAttributes attributes = 4;
bool virtual = 5;
} }
message LinkIdList { message LinkIdList {
......
...@@ -79,6 +79,7 @@ RUN python3 -m pip install -r e2e_orchestrator/requirements.txt ...@@ -79,6 +79,7 @@ RUN python3 -m pip install -r e2e_orchestrator/requirements.txt
# Add component files into working directory # Add component files into working directory
COPY --chown=teraflow:teraflow ./src/context/. context COPY --chown=teraflow:teraflow ./src/context/. context
COPY --chown=teraflow:teraflow ./src/e2e_orchestrator/. e2e_orchestrator COPY --chown=teraflow:teraflow ./src/e2e_orchestrator/. e2e_orchestrator
COPY --chown=teraflow:teraflow ./src/service/. service
# Start the service # Start the service
ENTRYPOINT ["python", "-m", "e2e_orchestrator.service"] ENTRYPOINT ["python", "-m", "e2e_orchestrator.service"]
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
import copy import copy
from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method
from common.proto.e2eorchestrator_pb2 import E2EOrchestratorRequest, E2EOrchestratorReply from common.proto.e2eorchestrator_pb2 import E2EOrchestratorRequest, E2EOrchestratorReply
from common.proto.context_pb2 import Empty, Connection, EndPointId, Link, LinkId, TopologyDetails, TopologyId, Device, Topology, Context from common.proto.context_pb2 import Empty, Connection, EndPointId, Link, LinkId, TopologyDetails, TopologyId, Device, Topology, Context, Service
from common.proto.e2eorchestrator_pb2_grpc import E2EOrchestratorServiceServicer from common.proto.e2eorchestrator_pb2_grpc import E2EOrchestratorServiceServicer
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from service.client.ServiceClient import ServiceClient
from context.service.database.uuids.EndPoint import endpoint_get_uuid from context.service.database.uuids.EndPoint import endpoint_get_uuid
from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest
from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string
...@@ -37,7 +38,7 @@ METRICS_POOL = MetricsPool("E2EOrchestrator", "RPC") ...@@ -37,7 +38,7 @@ METRICS_POOL = MetricsPool("E2EOrchestrator", "RPC")
context_client: ContextClient = ContextClient() context_client: ContextClient = ContextClient()
service_client: ServiceClient = ServiceClient()
EXT_HOST = "nbiservice.tfs-ip.svc.cluster.local" EXT_HOST = "nbiservice.tfs-ip.svc.cluster.local"
EXT_PORT = "8762" EXT_PORT = "8762"
...@@ -51,12 +52,17 @@ def _event_received(websocket): ...@@ -51,12 +52,17 @@ def _event_received(websocket):
message_json = json.loads(message) message_json = json.loads(message)
if 'link_id' in message_json: if 'link_id' in message_json:
obj = Link(**message_json) link = Link(**message_json)
if _check_policies(obj):
pass service = Service()
service.service_id = link.link_id.link_uuid
service.serivice_type = 2 # Optical
service.service_status = 1
# service_client.CreateService(service)
websocket.send(message)
elif 'link_uuid' in message_json:
obj = LinkId(**message_json)
else: else:
topology_details = TopologyDetails(**message_json) topology_details = TopologyDetails(**message_json)
...@@ -72,9 +78,11 @@ def _event_received(websocket): ...@@ -72,9 +78,11 @@ def _event_received(websocket):
context_client.SetTopology(topology) context_client.SetTopology(topology)
for device in topology_details.devices: for device in topology_details.devices:
LOGGER.info('Setting Device: {}'.format(device))
context_client.SetDevice(device) context_client.SetDevice(device)
for link in topology_details.links: for link in topology_details.links:
LOGGER.info('Setting Link: {}'.format(link))
context_client.SetLink(link) context_client.SetLink(link)
......
...@@ -20,11 +20,17 @@ from common.tools.grpc.Tools import grpc_message_to_json ...@@ -20,11 +20,17 @@ from common.tools.grpc.Tools import grpc_message_to_json
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from service.client.ServiceClient import ServiceClient from service.client.ServiceClient import ServiceClient
from vnt_manager.client.VNTManagerClient import VNTManagerClient from vnt_manager.client.VNTManagerClient import VNTManagerClient
import logging
from .Tools import ( from .Tools import (
format_grpc_to_json, grpc_connection_id, grpc_context_id, grpc_device_id, grpc_link, grpc_link_id, grpc_policy_rule_id, format_grpc_to_json, grpc_connection_id, grpc_context_id, grpc_device_id, grpc_link, grpc_link_id, grpc_policy_rule_id,
grpc_service_id, grpc_service, grpc_slice_id, grpc_topology_id) grpc_service_id, grpc_service, grpc_slice_id, grpc_topology_id)
LOGGER = logging.getLogger(__name__)
class _Resource(Resource): class _Resource(Resource):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
...@@ -198,16 +204,26 @@ class VirtualLinks(_Resource): ...@@ -198,16 +204,26 @@ class VirtualLinks(_Resource):
return format_grpc_to_json(self.vntmanager_client.ListVirtualLinks(Empty())) return format_grpc_to_json(self.vntmanager_client.ListVirtualLinks(Empty()))
class VirtualLink(_Resource): class VirtualLink(_Resource):
def get(self, link_uuid : str): def get(self, virtual_link_uuid : str):
return format_grpc_to_json(self.vntmanager_client.GetVirtualLink(grpc_link_id(link_uuid))) return format_grpc_to_json(self.vntmanager_client.GetVirtualLink(grpc_link_id(virtual_link_uuid)))
def post(self): def post(self, virtual_link_uuid : str): # pylint: disable=unused-argument
link = request.get_json() link = request.get_json()
LOGGER.info('---------------------------LINK received------------------------------')
LOGGER.info(link)
LOGGER.info('----------------------------------------------------------------------')
LOGGER.info(link['link_id'])
LOGGER.info('type: {}'.format(type(link['link_id'])))
LOGGER.info('---------------------------LINK received------------------------------')
link = grpc_link(link)
return format_grpc_to_json(self.vntmanager_client.SetVirtualLink(grpc_link(link))) return format_grpc_to_json(self.vntmanager_client.SetVirtualLink(grpc_link(link)))
def put(self): def put(self, virtual_link_uuid : str): # pylint: disable=unused-argument
link = request.get_json() link = request.get_json()
return format_grpc_to_json(self.vntmanager_client.SetVirtualLink(grpc_link(link))) return format_grpc_to_json(self.vntmanager_client.SetVirtualLink(grpc_link(link)))
def delete(self, link_uuid : str): def delete(self, virtual_link_uuid : str):
return format_grpc_to_json(self.vntmanager_client.RemoveVirtualLink(grpc_link_id(link_uuid))) return format_grpc_to_json(self.vntmanager_client.RemoveVirtualLink(grpc_link_id(virtual_link_uuid)))
class ConnectionIds(_Resource): class ConnectionIds(_Resource):
def get(self, context_uuid : str, service_uuid : str): def get(self, context_uuid : str, service_uuid : str):
......
...@@ -47,7 +47,7 @@ def grpc_link_id(link_uuid): ...@@ -47,7 +47,7 @@ def grpc_link_id(link_uuid):
return LinkId(**json_link_id(link_uuid)) return LinkId(**json_link_id(link_uuid))
def grpc_link(link): def grpc_link(link):
return Link(**json_link(link.link_id.uuid, link.link_endpoint_ids)) return Link(**json_link(link['link_id']['link_uuid']['uuid'], link['link_endpoint_ids']))
def grpc_service_id(context_uuid, service_uuid): def grpc_service_id(context_uuid, service_uuid):
return ServiceId(**json_service_id(service_uuid, context_id=json_context_id(context_uuid))) return ServiceId(**json_service_id(service_uuid, context_id=json_context_id(context_uuid)))
......
...@@ -2,7 +2,14 @@ ...@@ -2,7 +2,14 @@
"services": [ "services": [
{ {
"service_id": { "service_id": {
"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "dc-2-dc-svc"} "context_id": {
"context_uuid": {
"uuid": "admin"
}
},
"service_uuid": {
"uuid": "dc-2-dc-svc"
}
}, },
"service_type": 2, "service_type": 2,
"service_status": {"service_status": 1}, "service_status": {"service_status": 1},
......
{
"contexts": [
{"context_id": {"context_uuid": {"uuid": "admin"}}}
],
"topologies": [
{"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}}
],
"devices": [
{
"device_id": {"device_uuid": {"uuid": "TFS-IP"}}, "device_type": "teraflowsdn", "device_drivers": [7],
"device_endpoints": [], "device_operational_status": 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": "8002"}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {
"scheme": "http", "username": "admin", "password": "admin"
}}}
]}
}
]
}
...@@ -7,32 +7,26 @@ ...@@ -7,32 +7,26 @@
], ],
"devices": [ "devices": [
{ {
"device_id": {"device_uuid": {"uuid": "PE1"}}, "device_type": "emu-packet-router", "device_drivers": [0], "device_id": {"device_uuid": {"uuid": "IP1"}}, "device_type": "emu-packet-router", "device_drivers": [0],
"device_endpoints": [], "device_operational_status": 0, "device_config": {"config_rules": [ "device_endpoints": [], "device_operational_status": 0, "device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}}, {"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/port", "resource_value": "0"}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
{"sample_types": [], "type": "copper/internal", "uuid": "1/1"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP1"},
{"sample_types": [], "type": "copper/internal", "uuid": "1/2"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP2"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/1"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP3"}
{"sample_types": [], "type": "copper/internal", "uuid": "2/2"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/3"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/4"}
]}}} ]}}}
]} ]}
}, },
{ {
"device_id": {"device_uuid": {"uuid": "PE2"}}, "device_type": "emu-packet-router", "device_drivers": [0], "device_id": {"device_uuid": {"uuid": "IP2"}}, "device_type": "emu-packet-router", "device_drivers": [0],
"device_endpoints": [], "device_operational_status": 0, "device_config": {"config_rules": [ "device_endpoints": [], "device_operational_status": 0, "device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}}, {"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/port", "resource_value": "0"}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
{"sample_types": [], "type": "copper/internal", "uuid": "1/1"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP1"},
{"sample_types": [], "type": "copper/internal", "uuid": "1/2"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP2"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/1"}, {"sample_types": [], "type": "copper/internal", "uuid": "CTP3"}
{"sample_types": [], "type": "copper/internal", "uuid": "2/2"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/3"},
{"sample_types": [], "type": "copper/internal", "uuid": "2/4"}
]}}} ]}}}
]} ]}
} }
......
{
"contexts": [
{"context_id": {"context_uuid": {"uuid": "admin"}}}
],
"topologies": [
{"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}}
],
"links": [
{"link_id": {"link_uuid": {"uuid": "IP1_CTP1-MGON1_OTP1"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP1"}}, "endpoint_uuid": {"uuid": "CTP1"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON1"}}, "endpoint_uuid": {"uuid": "OTP1"}}
]},
{"link_id": {"link_uuid": {"uuid": "IP1_CTP2-MGON1_OTP2"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP1"}}, "endpoint_uuid": {"uuid": "CTP2"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON1"}}, "endpoint_uuid": {"uuid": "OTP2"}}
]},
{"link_id": {"link_uuid": {"uuid": "IP1CTP3-MGON1_OTP3"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP1"}}, "endpoint_uuid": {"uuid": "CTP3"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON1"}}, "endpoint_uuid": {"uuid": "OTP3"}}
]},
{"link_id": {"link_uuid": {"uuid": "IP2_CTP1-MGON3_OTP1"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP2"}}, "endpoint_uuid": {"uuid": "CTP1"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON3"}}, "endpoint_uuid": {"uuid": "OTP1"}}
]},
{"link_id": {"link_uuid": {"uuid": "IP2_CTP2-MGON3_OTP2"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP2"}}, "endpoint_uuid": {"uuid": "CTP2"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON3"}}, "endpoint_uuid": {"uuid": "OTP2"}}
]},
{"link_id": {"link_uuid": {"uuid": "IP2_CTP3-MGON3_OTP3"}}, "link_endpoint_ids": [
{"device_id": {"device_uuid": {"uuid": "IP2"}}, "endpoint_uuid": {"uuid": "CTP3"}},
{"device_id": {"device_uuid": {"uuid": "MG-ON3"}}, "endpoint_uuid": {"uuid": "OTP3"}}
]}
]
}
...@@ -51,3 +51,10 @@ spec: ...@@ -51,3 +51,10 @@ spec:
name: nbiservice name: nbiservice
port: port:
number: 8080 number: 8080
- path: /()(tfs-api/.*)
pathType: Prefix
backend:
service:
name: nbiservice
port:
number: 8080
...@@ -51,3 +51,10 @@ spec: ...@@ -51,3 +51,10 @@ spec:
name: nbiservice name: nbiservice
port: port:
number: 8080 number: 8080
- path: /()(tfs-api/.*)
pathType: Prefix
backend:
service:
name: nbiservice
port:
number: 8080
\ No newline at end of file
...@@ -42,6 +42,8 @@ from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordOperationEnum, ...@@ -42,6 +42,8 @@ from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordOperationEnum,
from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.grpc.Tools import grpc_message_to_json from common.tools.grpc.Tools import grpc_message_to_json
import time import time
import json
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -68,7 +70,6 @@ def send_msg(msg): ...@@ -68,7 +70,6 @@ def send_msg(msg):
LOGGER.info(msg) LOGGER.info(msg)
LOGGER.info('-------------------------------------------------------') LOGGER.info('-------------------------------------------------------')
WEBSOCKET.send(msg) WEBSOCKET.send(msg)
message = WEBSOCKET.recv()
...@@ -123,17 +124,19 @@ class VNTMEventDispatcher(threading.Thread): ...@@ -123,17 +124,19 @@ class VNTMEventDispatcher(threading.Thread):
else: else:
send_msg(grpc_message_to_json_string(topology_details)) send_msg(grpc_message_to_json_string(topology_details))
LOGGER.info('aaaaaaaaaaaaaaaaa')
while not self._terminate.is_set(): while not self._terminate.is_set():
event = events_collector.get_event(block=True, timeout=GET_EVENT_TIMEOUT) event = events_collector.get_event(block=True, timeout=GET_EVENT_TIMEOUT)
if event is None: continue if event is None: continue
LOGGER.info('event!: {}'.format(event)) LOGGER.info('event!!!!!!!!!!!!!!!!!!!!!!: {}'.format(event))
topology_details = context_client.GetTopologyDetails(TopologyId(**topology_id)) topology_details = context_client.GetTopologyDetails(TopologyId(**topology_id))
LOGGER.info('topodetails..................................... ')
to_send = grpc_message_to_json_string(topology_details) to_send = grpc_message_to_json_string(topology_details)
send_msg(to_send) send_msg(to_send)
LOGGER.info('Exiting')
events_collector.stop() events_collector.stop()
...@@ -158,46 +161,37 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): ...@@ -158,46 +161,37 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
return reply return reply
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) """ @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def ListVirtualLinkIds(self, request : Empty, context : grpc.ServicerContext) -> LinkIdList: def ListVirtualLinkIds(self, request : Empty, context : grpc.ServicerContext) -> LinkIdList:
return LinkIdList(link_ids=[link.link_id for link in self.links]) return [link for link in context_client.ListLinks(Empty()) if link.virtual]
return LinkIdList(link_ids=[link.link_id for link in self.links])
"""
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def ListVirtualLinks(self, request : Empty, context : grpc.ServicerContext) -> LinkList: def ListVirtualLinks(self, request : Empty, context : grpc.ServicerContext) -> LinkList:
return LinkList(link=self.links) return [link for link in context_client.ListLinks(Empty()).links if link.virtual]
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def GetVirtualLink(self, request : LinkId, context : grpc.ServicerContext) -> Link: def GetVirtualLink(self, request : LinkId, context : grpc.ServicerContext) -> Link:
try: link = context_client.GetLink(request)
send_msg(request) return link if link.virtual else Empty()
except Exception as e:
LOGGER.error('Exception getting virtual link={}\n\t{}'.format(request.link_uuid.uuid, e))
else:
for link in self.links:
if link.link_uuid.uuid == request.uuid:
return link
return Empty()
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def SetVirtualLink(self, request : Link, context : grpc.ServicerContext) -> LinkId: def SetVirtualLink(self, request : Link, context : grpc.ServicerContext) -> LinkId:
try: try:
send_msg(request) send_msg(request)
message = WEBSOCKET.recv()
message_json = json.loads(message)
link = Link(**message_json)
context_client.SetLink(link)
except Exception as e: except Exception as e:
LOGGER.error('Exception setting virtual link={}\n\t{}'.format(request.link_id.link_uuid.uuid, e)) LOGGER.error('Exception setting virtual link={}\n\t{}'.format(request.link_id.link_uuid.uuid, e))
else: return request.linkd_id
self.links.append(request)
return request.linkd_id
@safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
def RemoveVirtualLink(self, request : LinkId, context : grpc.ServicerContext) -> Empty: def RemoveVirtualLink(self, request : LinkId, context : grpc.ServicerContext) -> Empty:
try: # TODO
send_msg(request)
except Exception as e:
LOGGER.error('Exception removing virtual link={}\n\t{}'.format(request.link_id.link_uuid.uuid, e))
else:
for link in self.links:
if link.link_uuid.uuid == request.uuid:
self.links.remove(link)
return Empty()
return Empty() return Empty()
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