Commit 948e9589 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code cleanup

parent a392d2e0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ include:
  - local: '/src/telemetry/.gitlab-ci.yml'
  - local: '/src/analytics/.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
  - local: '/src/tests/.gitlab-ci.yml'
+4 −2
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@ import logging, signal, sys, threading
from prometheus_client import start_http_server
from common.Constants import ServiceNameEnum
from common.Settings import (
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port,
    wait_for_environment_variables)
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC,
    get_env_var_name, get_log_level, get_metrics_port,
    wait_for_environment_variables
)
from .DeviceService import DeviceService
from .driver_api.DriverFactory import DriverFactory
from .driver_api.DriverInstanceCache import DriverInstanceCache, preload_drivers
+1 −2
Original line number Diff line number Diff line
@@ -81,8 +81,7 @@ 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/vnt_manager/__init__.py vnt_manager/__init__.py
COPY src/vnt_manager/client/. vnt_manager/client/
COPY src/vnt_manager/. vnt_manager/

# Start the service
ENTRYPOINT ["python", "-m", "vnt_manager.service"]
+0 −1
Original line number Diff line number Diff line
@@ -12,5 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

networkx
websockets==12.0
+8 −28
Original line number Diff line number Diff line
@@ -12,37 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

import networkx as nx
import grpc
import json
import logging
import threading
import time
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_grpc import VNTManagerServiceServicer
from context.client.ContextClient import ContextClient
from common.proto.context_pb2 import (
    Empty,
    Event, EventTypeEnum,  
    Link, LinkEvent, LinkId, LinkIdList, LinkList,
)
from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_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.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
import json

LOGGER = logging.getLogger(__name__)

@@ -140,7 +126,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
        LOGGER.debug("Servicer Created")
        self.links = []


    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def VNTSubscript(self, request: VNTSubscriptionRequest, context: grpc.ServicerContext) -> VNTSubscriptionReply:
        LOGGER.info("Subscript request: {:s}".format(str(grpc_message_to_json(request))))
@@ -148,14 +133,11 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
        reply.subscription = "OK"

        self.event_dispatcher = VNTMEventDispatcher(request.host, int(request.port))

        self.host = request.host
        self.port = request.port
        self.event_dispatcher.start()

        return reply


    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def ListVirtualLinks(self, request : Empty, context : grpc.ServicerContext) -> LinkList:
        return [link for link in context_client.ListLinks(Empty()).links if link.virtual]
@@ -165,7 +147,6 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
        link = context_client.GetLink(request)
        return link if link.virtual else Empty()


    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def SetVirtualLink(self, request : Link, context : grpc.ServicerContext) -> LinkId:
        try:
@@ -200,4 +181,3 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
            LOGGER.info('Removed')

        return Empty()
Loading