示例#1
0
# -*- coding: UTF-8 -*-

# 功能:
# 版权信息:华为技术有限公司,版本所有(C)
# 修改记录:2015/4/30 10:26  创建
import time
from neutron.plugins.openvswitch.common.rpc.rpc_business.rpc_client import RpcClient
from neutron.plugins.openvswitch.common.log import getLogger
from concurrent.futures import ThreadPoolExecutor

LOG = getLogger(__name__)
REMOTE = ("localhost", 12581)


class BusClientFactory():
    def __init__(self):
        self.port = 0
        self.interface = None
        self.name = None
        self.client = None
        self.executor = ThreadPoolExecutor(max_workers=1)

    def setPort(self, port):
        '''
        设置该client使用的端口号,不设置则会分配一个随机端口号
        :param port:
        :return:
        '''
        self.port = port

    def setInterface(self, interface):
示例#2
0
# -*- coding: UTF-8 -*-
"""
            功    能:ClientHandler类,rpc客户端新增断开连接的处理类
            版权信息:华为技术有限公司,版本所有(C) 2014
            作者:
            修改记录:2014-11-3 14:30  ClientHandler 创建
"""
from neutron.plugins.openvswitch.common.rpc.rpc_inner.server_aware import ServerAware
from neutron.plugins.openvswitch.common.log import getLogger

logger = getLogger(__name__)


class ClientHandler(ServerAware):
    def __init__(self, addCallback, removeCallback):
        self.addCallback = addCallback
        self.removeCallback = removeCallback

    def added(self, terminal):
        logger.info("rpc client add terminal, address=%s", terminal.address)
        if self.addCallback:
            self.addCallback(terminal)

    def removed(self, terminal):
        logger.info("rpc client remove terminal, address=%s", terminal.address)
        if self.removeCallback:
            self.removeCallback(terminal)
# -*- coding: UTF-8 -*-

# 功能:
# 版权信息:华为技术有限公司,版本所有(C)
# 修改记录:2015/4/30 10:26  创建
import time
from neutron.plugins.openvswitch.common.rpc.rpc_business.rpc_client import RpcClient
from neutron.plugins.openvswitch.common.log import getLogger
from concurrent.futures import ThreadPoolExecutor

LOG = getLogger(__name__)
REMOTE = ("localhost", 12581)


class BusClientFactory():
    def __init__(self):
        self.port = 0
        self.interface = None
        self.name = None
        self.client = None
        self.executor = ThreadPoolExecutor(max_workers=1)

    def setPort(self, port):
        '''
        设置该client使用的端口号,不设置则会分配一个随机端口号
        :param port:
        :return:
        '''
        self.port = port

    def setInterface(self, interface):