def start_websocket_testee_transport(self, id, config, details=None): """ """ self.log.debug("{}.start_websocket_testee_transport".format(self.__class__.__name__), id=id, config=config) # prohibit starting a transport twice # # FIXME # if id in self.transports: # emsg = "Could not start transport: a transport with ID '{}' is already running (or starting)".format(id) # self.log.error(emsg) # raise ApplicationError(u'crossbar.error.already_running', emsg) # check configuration # try: checkconfig.check_listening_transport_websocket(config) except Exception as e: emsg = "Invalid WebSocket testee transport configuration: {}".format(e) self.log.error(emsg) raise ApplicationError(u"crossbar.error.invalid_configuration", emsg) else: self.log.debug("Starting {}-transport on websocket-testee.".format(config['type'])) # WebSocket testee pseudo transport # if config['type'] == 'websocket': transport_factory = WebSocketTesteeServerFactory(config, self._templates) # Unknown transport type # else: # should not arrive here, since we did check_transport() in the beginning raise Exception("logic error") # create transport endpoint / listening port from transport factory # d = create_listening_port_from_config(config['endpoint'], self.config.extra.cbdir, transport_factory, self._reactor, self.log) def ok(port): # FIXME # self.transports[id] = RouterTransport(id, config, transport_factory, port) self.log.debug("Router transport '{}'' started and listening".format(id)) return def fail(err): emsg = "Cannot listen on transport endpoint: {}".format(err.value) self.log.error(emsg) raise ApplicationError(u"crossbar.error.cannot_listen", emsg) d.addCallbacks(ok, fail) return d
def start_websocket_testee_transport(self, id, config, details=None): """ """ self.log.debug("{}.start_websocket_testee_transport".format(self.__class__.__name__), id=id, config=config) # prohibit starting a transport twice # # FIXME # if id in self.transports: # emsg = "Could not start transport: a transport with ID '{}' is already running (or starting)".format(id) # self.log.error(emsg) # raise ApplicationError(u'crossbar.error.already_running', emsg) # check configuration # try: checkconfig.check_listening_transport_websocket(config) except Exception as e: emsg = "Invalid WebSocket testee transport configuration: {}".format(e) self.log.error(emsg) raise ApplicationError(u"crossbar.error.invalid_configuration", emsg) else: self.log.debug("Starting {}-transport on websocket-testee.".format(config['type'])) # WebSocket testee pseudo transport # if config['type'] == 'websocket': transport_factory = WebSocketTesteeServerFactory(config, self._templates) # Unknown transport type # else: # should not arrive here, since we did check_transport() in the beginning raise Exception("logic error") # create transport endpoint / listening port from transport factory # d = create_listening_port_from_config(config['endpoint'], self.config.extra.cbdir, transport_factory, self._reactor, self.log) def ok(port): # FIXME # self.transports[id] = RouterTransport(id, config, transport_factory, port) self.log.debug("Router transport '{}'' started and listening".format(id)) return def fail(err): emsg = "Cannot listen on transport endpoint: {}".format(err.value) self.log.error(emsg) raise ApplicationError(u"crossbar.error.cannot_listen", emsg) d.addCallbacks(ok, fail) return d
def start_management_transport(self, config, details = None): """ Start transport for local management router. :param config: Transport configuration. :type config: obj """ if self.debug: log.msg("{}.start_management_transport".format(self.__class__.__name__), config) if self._management_transport: emsg = "ERROR: could not start management transport - already running (or starting)" log.msg(emsg) raise ApplicationError("crossbar.error.already_started", emsg) try: checkconfig.check_listening_transport_websocket(config) except Exception as e: emsg = "ERROR: could not start management transport - invalid configuration ({})".format(e) log.msg(emsg) raise ApplicationError('crossbar.error.invalid_configuration', emsg) self._management_transport = ManagementTransport(config, details.authid) factory = WampWebSocketServerFactory(self._node._router_session_factory, debug = False) factory.setProtocolOptions(failByDrop = False) factory.noisy = False starting_topic = '{}.on_management_transport_starting'.format(self._uri_prefix) starting_info = self._management_transport.marshal() ## the caller gets a progressive result .. if details.progress: details.progress(starting_info) ## .. while all others get an event self.publish(starting_topic, starting_info, options = PublishOptions(exclude = [details.caller])) try: self._management_transport.port = yield create_listening_port_from_config(config['endpoint'], factory, self.cbdir, reactor) except Exception as e: self._management_transport = None emsg = "ERROR: local management service endpoint cannot listen - {}".format(e) log.msg(emsg) raise ApplicationError("crossbar.error.cannot_listen", emsg) ## alright, manhole has started self._management_transport.started = datetime.utcnow() self._management_transport.status = 'started' started_topic = '{}.on_management_transport_started'.format(self._uri_prefix) started_info = self._management_transport.marshal() self.publish(started_topic, started_info, options = PublishOptions(exclude = [details.caller])) returnValue(started_info)
def start_management_transport(self, config, details=None): """ Start a (listening) transport for the local management router. :param config: Transport configuration. :type config: obj """ if self.debug: self.log.debug("{me}.start_management_transport", me=self.__class__.__name__, config=config) if self._management_transport: emsg = "ERROR: could not start management transport - already running (or starting)" self.log.failure(emsg) raise ApplicationError("crossbar.error.already_started", emsg) try: checkconfig.check_listening_transport_websocket(config) except Exception as e: emsg = "ERROR: could not start management transport - invalid configuration ({})".format(e) self.log.failure(emsg) raise ApplicationError('crossbar.error.invalid_configuration', emsg) self._management_transport = ManagementTransport(config, details.caller) factory = WampWebSocketServerFactory(self._node._router_session_factory, debug=False) factory.setProtocolOptions(failByDrop=False) factory.noisy = False starting_topic = '{}.on_management_transport_starting'.format(self._uri_prefix) starting_info = self._management_transport.marshal() # the caller gets a progressive result .. if details.progress: details.progress(starting_info) # .. while all others get an event self.publish(starting_topic, starting_info, options=PublishOptions(exclude=[details.caller])) try: self._management_transport.port = yield create_listening_port_from_config(config['endpoint'], factory, self.cbdir, reactor) except Exception as e: self._management_transport = None emsg = "ERROR: local management service endpoint cannot listen - {}".format(e) self.log.failure(emsg) raise ApplicationError("crossbar.error.cannot_listen", emsg) # alright, the transport has started self._management_transport.started = datetime.utcnow() self._management_transport.status = 'started' started_topic = '{}.on_management_transport_started'.format(self._uri_prefix) started_info = self._management_transport.marshal() self.publish(started_topic, started_info, options=PublishOptions(exclude=[details.caller])) returnValue(started_info)