def create_tenant_rpc_server(self, tid): """create_ blocking rpc server @param tid: openstack tenant id """ ret = {} if tid in self.rpc_servers: LOG.warning(_LW("already in message queue and server. queue=%s"), self.rpc_servers[tid]['topic']) return {'result': 'FAILED'} topic = "%s-%s" % (self.topic, tid) target = Target(topic=topic, server=cfg.CONF.host, fanout=False) assert n_rpc.TRANSPORT is not None serializer = n_rpc.RequestContextSerializer(None) server = get_rpc_server(n_rpc.TRANSPORT, target, self.agent_top.endpoints, 'blocking', serializer) self.rpc_servers[tid] = {'server': server, 'topic': topic} LOG.debug("RPCServer create: topic=%s", topic) self.rpc_servers[tid]['server'].start() ret['result'] = 'SUCCESS' ret['tenant_id'] = tid ret['topic'] = topic return ret
def create_tenant_rpc_server(self, tid): """create_ blocking rpc server @param tid: openstack tenant id """ ret = {} if tid in self.rpc_servers: LOG.warning(_LW("already in message queue and server. queue=%s"), self.rpc_servers[tid]['topic']) return {'result': 'FAILED'} topic = "%s-%s" % (self.topic, tid) target = Target(topic=topic, server=cfg.CONF.host, fanout=False) assert n_rpc.TRANSPORT is not None serializer = n_rpc.RequestContextSerializer(None) server = get_rpc_server(n_rpc.TRANSPORT, target, self.agent_top.endpoints, 'blocking', serializer) LOG.debug("RPCServer create: topic=%s", topic) if self.greenpool.free() < 1: self.greenpool_size += nwa_const.NWA_GREENPOOL_ADD_SIZE self.greenpool.resize(self.greenpool_size) LOG.info(_LI('RPCServer greenpool resize %s'), self.greenpool_size) def server_start(): while True: try: LOG.debug('RPCServer thread %d start %s', (self.greenpool.running(), server)) server.start() LOG.debug('RPCServer thread end %s', server) break except Exception as e: LOG.exception(_LE('RPCServer thread start failed: %s'), e) self.rpc_servers[tid] = { 'thread': self.greenpool.spawn(server_start), 'server': server, 'topic': topic } eventlet.sleep(0) LOG.info(_LI('RPCServer started: %(topic)s server=%(server)s'), { 'topic': topic, 'server': server }) ret['result'] = 'SUCCESS' ret['tenant_id'] = tid ret['topic'] = topic return ret
def setUp(self): super(TestRequestContextSerializer, self).setUp() self.mock_base = mock.Mock() self.ser = rpc.RequestContextSerializer(self.mock_base) self.ser_null = rpc.RequestContextSerializer(None)