Loading .gitlab-ci.yml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -52,6 +52,8 @@ include: - local: '/src/telemetry/.gitlab-ci.yml' - local: '/src/telemetry/.gitlab-ci.yml' - local: '/src/analytics/.gitlab-ci.yml' - local: '/src/analytics/.gitlab-ci.yml' - local: '/src/qos_profile/.gitlab-ci.yml' - local: '/src/qos_profile/.gitlab-ci.yml' - local: '/src/vnt_manager/.gitlab-ci.yml' - local: '/src/e2e_orchestrator/.gitlab-ci.yml' # This should be last one: end-to-end integration tests # This should be last one: end-to-end integration tests - local: '/src/tests/.gitlab-ci.yml' - local: '/src/tests/.gitlab-ci.yml' src/device/service/__main__.py +4 −2 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,10 @@ import logging, signal, sys, threading from prometheus_client import start_http_server from prometheus_client import start_http_server from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum from common.Settings import ( from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, wait_for_environment_variables) get_env_var_name, get_log_level, get_metrics_port, wait_for_environment_variables ) from .DeviceService import DeviceService from .DeviceService import DeviceService from .driver_api.DriverFactory import DriverFactory from .driver_api.DriverFactory import DriverFactory from .driver_api.DriverInstanceCache import DriverInstanceCache, preload_drivers from .driver_api.DriverInstanceCache import DriverInstanceCache, preload_drivers Loading src/vnt_manager/Dockerfile +1 −2 Original line number Original line Diff line number Diff line Loading @@ -81,8 +81,7 @@ COPY src/context/__init__.py context/__init__.py COPY src/context/client/. context/client/ COPY src/context/client/. context/client/ COPY src/device/__init__.py device/__init__.py COPY src/device/__init__.py device/__init__.py COPY src/device/client/. device/client/ COPY src/device/client/. device/client/ COPY src/vnt_manager/__init__.py vnt_manager/__init__.py COPY src/vnt_manager/. vnt_manager/ COPY src/vnt_manager/client/. vnt_manager/client/ # Start the service # Start the service ENTRYPOINT ["python", "-m", "vnt_manager.service"] ENTRYPOINT ["python", "-m", "vnt_manager.service"] src/vnt_manager/requirements.in +0 −1 Original line number Original line Diff line number Diff line Loading @@ -12,5 +12,4 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. networkx websockets==12.0 websockets==12.0 src/vnt_manager/service/VNTManagerServiceServicerImpl.py +8 −28 Original line number Original line Diff line number Diff line Loading @@ -12,37 +12,23 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. import logging import networkx as nx import grpc import grpc import json import logging import threading import time import time from websockets.sync.client import connect from websockets.sync.client import connect from common.method_wrappers.Decorator import (MetricsPool, MetricTypeEnum, safe_and_metered_rpc_method) from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method from common.proto.context_pb2 import ContextId, Empty, Link, LinkId, LinkList, TopologyId from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest, VNTSubscriptionReply from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest, VNTSubscriptionReply from common.proto.vnt_manager_pb2_grpc import VNTManagerServiceServicer from common.proto.vnt_manager_pb2_grpc import VNTManagerServiceServicer from context.client.ContextClient import ContextClient from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from common.proto.context_pb2 import ( Empty, Event, EventTypeEnum, Link, LinkEvent, LinkId, LinkIdList, LinkList, ) from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from common.tools.object_factory.Topology import json_topology_id from common.proto.context_pb2 import ContextId, TopologyId import threading from common.proto.context_pb2 import ( ConnectionEvent, ContextEvent, DeviceEvent, EventTypeEnum, ServiceEvent, TopologyEvent) from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient from context.client.EventsCollector import EventsCollector from context.client.EventsCollector import EventsCollector from common.tests.EventTools import EVENT_CREATE, EVENT_UPDATE, check_events from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME from typing import Any, Dict, Set from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordOperationEnum, DltRecordTypeEnum from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json from .vntm_config_device import configure, deconfigure from .vntm_config_device import configure, deconfigure import json LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) Loading Loading @@ -140,7 +126,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): LOGGER.debug("Servicer Created") LOGGER.debug("Servicer Created") self.links = [] self.links = [] @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def VNTSubscript(self, request: VNTSubscriptionRequest, context: grpc.ServicerContext) -> VNTSubscriptionReply: def VNTSubscript(self, request: VNTSubscriptionRequest, context: grpc.ServicerContext) -> VNTSubscriptionReply: LOGGER.info("Subscript request: {:s}".format(str(grpc_message_to_json(request)))) LOGGER.info("Subscript request: {:s}".format(str(grpc_message_to_json(request)))) Loading @@ -148,14 +133,11 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): reply.subscription = "OK" reply.subscription = "OK" self.event_dispatcher = VNTMEventDispatcher(request.host, int(request.port)) self.event_dispatcher = VNTMEventDispatcher(request.host, int(request.port)) self.host = request.host self.host = request.host self.port = request.port self.port = request.port self.event_dispatcher.start() self.event_dispatcher.start() return reply return reply @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 [link for link in context_client.ListLinks(Empty()).links if link.virtual] return [link for link in context_client.ListLinks(Empty()).links if link.virtual] Loading @@ -165,7 +147,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): link = context_client.GetLink(request) link = context_client.GetLink(request) return link if link.virtual else Empty() return link if link.virtual else 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: Loading Loading @@ -200,4 +181,3 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): LOGGER.info('Removed') LOGGER.info('Removed') return Empty() return Empty() Loading
.gitlab-ci.yml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -52,6 +52,8 @@ include: - local: '/src/telemetry/.gitlab-ci.yml' - local: '/src/telemetry/.gitlab-ci.yml' - local: '/src/analytics/.gitlab-ci.yml' - local: '/src/analytics/.gitlab-ci.yml' - local: '/src/qos_profile/.gitlab-ci.yml' - local: '/src/qos_profile/.gitlab-ci.yml' - local: '/src/vnt_manager/.gitlab-ci.yml' - local: '/src/e2e_orchestrator/.gitlab-ci.yml' # This should be last one: end-to-end integration tests # This should be last one: end-to-end integration tests - local: '/src/tests/.gitlab-ci.yml' - local: '/src/tests/.gitlab-ci.yml'
src/device/service/__main__.py +4 −2 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,10 @@ import logging, signal, sys, threading from prometheus_client import start_http_server from prometheus_client import start_http_server from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum from common.Settings import ( from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, wait_for_environment_variables) get_env_var_name, get_log_level, get_metrics_port, wait_for_environment_variables ) from .DeviceService import DeviceService from .DeviceService import DeviceService from .driver_api.DriverFactory import DriverFactory from .driver_api.DriverFactory import DriverFactory from .driver_api.DriverInstanceCache import DriverInstanceCache, preload_drivers from .driver_api.DriverInstanceCache import DriverInstanceCache, preload_drivers Loading
src/vnt_manager/Dockerfile +1 −2 Original line number Original line Diff line number Diff line Loading @@ -81,8 +81,7 @@ COPY src/context/__init__.py context/__init__.py COPY src/context/client/. context/client/ COPY src/context/client/. context/client/ COPY src/device/__init__.py device/__init__.py COPY src/device/__init__.py device/__init__.py COPY src/device/client/. device/client/ COPY src/device/client/. device/client/ COPY src/vnt_manager/__init__.py vnt_manager/__init__.py COPY src/vnt_manager/. vnt_manager/ COPY src/vnt_manager/client/. vnt_manager/client/ # Start the service # Start the service ENTRYPOINT ["python", "-m", "vnt_manager.service"] ENTRYPOINT ["python", "-m", "vnt_manager.service"]
src/vnt_manager/requirements.in +0 −1 Original line number Original line Diff line number Diff line Loading @@ -12,5 +12,4 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. networkx websockets==12.0 websockets==12.0
src/vnt_manager/service/VNTManagerServiceServicerImpl.py +8 −28 Original line number Original line Diff line number Diff line Loading @@ -12,37 +12,23 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. import logging import networkx as nx import grpc import grpc import json import logging import threading import time import time from websockets.sync.client import connect from websockets.sync.client import connect from common.method_wrappers.Decorator import (MetricsPool, MetricTypeEnum, safe_and_metered_rpc_method) from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method from common.proto.context_pb2 import ContextId, Empty, Link, LinkId, LinkList, TopologyId from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest, VNTSubscriptionReply from common.proto.vnt_manager_pb2 import VNTSubscriptionRequest, VNTSubscriptionReply from common.proto.vnt_manager_pb2_grpc import VNTManagerServiceServicer from common.proto.vnt_manager_pb2_grpc import VNTManagerServiceServicer from context.client.ContextClient import ContextClient from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from common.proto.context_pb2 import ( Empty, Event, EventTypeEnum, Link, LinkEvent, LinkId, LinkIdList, LinkList, ) from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from common.tools.object_factory.Topology import json_topology_id from common.proto.context_pb2 import ContextId, TopologyId import threading from common.proto.context_pb2 import ( ConnectionEvent, ContextEvent, DeviceEvent, EventTypeEnum, ServiceEvent, TopologyEvent) from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient from context.client.EventsCollector import EventsCollector from context.client.EventsCollector import EventsCollector from common.tests.EventTools import EVENT_CREATE, EVENT_UPDATE, check_events from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, INTERDOMAIN_TOPOLOGY_NAME from typing import Any, Dict, Set from common.proto.dlt_gateway_pb2 import DltRecordEvent, DltRecordOperationEnum, DltRecordTypeEnum from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json from .vntm_config_device import configure, deconfigure from .vntm_config_device import configure, deconfigure import json LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) Loading Loading @@ -140,7 +126,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): LOGGER.debug("Servicer Created") LOGGER.debug("Servicer Created") self.links = [] self.links = [] @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def VNTSubscript(self, request: VNTSubscriptionRequest, context: grpc.ServicerContext) -> VNTSubscriptionReply: def VNTSubscript(self, request: VNTSubscriptionRequest, context: grpc.ServicerContext) -> VNTSubscriptionReply: LOGGER.info("Subscript request: {:s}".format(str(grpc_message_to_json(request)))) LOGGER.info("Subscript request: {:s}".format(str(grpc_message_to_json(request)))) Loading @@ -148,14 +133,11 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): reply.subscription = "OK" reply.subscription = "OK" self.event_dispatcher = VNTMEventDispatcher(request.host, int(request.port)) self.event_dispatcher = VNTMEventDispatcher(request.host, int(request.port)) self.host = request.host self.host = request.host self.port = request.port self.port = request.port self.event_dispatcher.start() self.event_dispatcher.start() return reply return reply @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 [link for link in context_client.ListLinks(Empty()).links if link.virtual] return [link for link in context_client.ListLinks(Empty()).links if link.virtual] Loading @@ -165,7 +147,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): link = context_client.GetLink(request) link = context_client.GetLink(request) return link if link.virtual else Empty() return link if link.virtual else 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: Loading Loading @@ -200,4 +181,3 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer): LOGGER.info('Removed') LOGGER.info('Removed') return Empty() return Empty()