Commit d966bfef authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

VNT Manager component:

- Code cleanup
parent 9ebc0ca7
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -59,12 +59,11 @@ class VNTMEventDispatcher(threading.Thread):
    def stop(self):
        self._terminate.set()

    
    def send_msg(self, msg):
        try:
            self.websocket.send(msg)
        except Exception as e:
            LOGGER.info(e)
            LOGGER.exception('Unable to send message')

    def recv_msg(self):
        message = self.websocket.recv()
@@ -72,27 +71,27 @@ class VNTMEventDispatcher(threading.Thread):

    def run(self) -> None:
        events_collector = EventsCollector(
            context_client, log_events_received=True,
            context_client,
            log_events_received            = True,
            activate_context_collector     = True,
            activate_topology_collector    = True,
            activate_device_collector      = True,
            activate_link_collector        = True,
            activate_service_collector     = False,
            activate_slice_collector       = False,
            activate_connection_collector  = False,)
            activate_connection_collector  = False,
        )
        events_collector.start()


        url = "ws://" + str(self.host) + ":" + str(self.port)
        LOGGER.debug('Connecting to {}'.format(url))

        try:
            LOGGER.info("Connecting to events server...: {}".format(url))
            url = "ws://" + str(self.host) + ":" + str(self.port)
            LOGGER.info("Connecting to events server...: {:s}".format(url))
            self.websocket = connect(url)
        except Exception as ex:
            LOGGER.error(f'Error connecting to {url}\n\t{ex}')
            MSG = 'Error connecting to {:s}'
            LOGGER.exception(MSG.format(str(url)))
        else:
            LOGGER.info('Connected to {}'.format(url))
            LOGGER.info('Connected to {:s}'.format(url))
            context_id = json_context_id(DEFAULT_CONTEXT_NAME)
            topology_id = json_topology_id(DEFAULT_TOPOLOGY_NAME, context_id)
            
@@ -155,7 +154,8 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):
            link = Link(**message_json)
            context_client.SetLink(link)
        except Exception as e:
            LOGGER.error(f'Exception setting virtual link={request.link_id.link_uuid.uuid}\n\t{e}')
            MSG = 'Exception setting virtual link={:s}')
            LOGGER.exception(MSG.format(str(request.link_id.link_uuid.uuid)))
        return request.link_id

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
@@ -171,8 +171,8 @@ class VNTManagerServiceServicerImpl(VNTManagerServiceServicer):

            LOGGER.info('Removed')
        except Exception as e:
            msg_error = 'Exception removing virtual link={}\n\t{}'.format(request.link_uuid.uuid, e)
            LOGGER.error(msg_error)
            MSG = 'Exception removing virtual link={:s}'
            LOGGER.exception(MSG.format(str(request.link_uuid.uuid)))
            return msg_error
        else:
            context_client.RemoveLink(request)