def test_ssl(self): """Tests SSL server functionality.""" # TODO: TLS version enforcement is necessary to avoid # vulnerable versions. Currently, this only tests TLS # connectivity. this_dir = os.path.dirname(sys.modules[__name__].__file__) saved_exception = None try: ssl_version = ssl.PROTOCOL_TLS except AttributeError: # For compatibility with older pythons. ssl_version = ssl.PROTOCOL_TLSv1 for i in range(3): try: # Try a few times as this can fail with EADDRINUSE port = random.randint(5000, 10000) server = hub.spawn(self._test_ssl, this_dir, port) hub.sleep(1) client = hub.StreamClient(("127.0.0.1", port), timeout=5, ssl_version=ssl_version) if client.connect() is not None: break except Exception as e: saved_exception = e continue finally: try: hub.kill(server) except Exception: pass else: self.fail("Failed to connect: " + str(saved_exception))
def set_querier_mode(self, dpid, server_port): """set the datapath to work as a querier. note that you can set up only the one querier. when you called this method several times, only the last one becomes effective.""" self.dpid = dpid self.server_port = server_port if self._querier_thread: hub.kill(self._querier_thread) self._querier_thread = None
def stop(self): # NOTE(jkoelker) Attempt to gracefully stop the accept loop self.is_active = False # NOTE(jkoelker) Forceably kill the loop and clear the main_thread if self.main_thread: hub.kill(self.main_thread) self.main_thread = None # NOTE(jkoelker) Stop all the clients for c in self._clients.values(): c.stop() # NOTE(jkoelker) super will only take care of the event and joining now super(OVSDB, self).stop()
def serve(self): send_thr = hub.spawn(self._send_loop) # send hello message immediately hello = self.ofproto_parser.OFPHello(self) self.send_msg(hello) echo_thr = hub.spawn(self._echo_request_loop) try: self._recv_loop() finally: hub.kill(send_thr) hub.kill(echo_thr) hub.joinall([send_thr, echo_thr]) self.is_active = False
def stop_loop(self): """stop QUERY thread.""" hub.kill(self._querier_thread) self._querier_thread = None self._datapath = None self.logger.info("stopped a querier.")
def stop(self): if self.main_thread: hub.kill(self.main_thread) self.is_active = False self._send_event(self._event_stop, None) hub.joinall(self.threads)
def stop(self): super().stop() if self.is_active(): hub.kill(self.thread) hub.joinall([self.thread]) self.thread = None
def stop(self): if self.thread is not None: hub.kill(self.thread) hub.joinall([self.thread]) self.thread = None