Beispiel #1
0
 def __init__(self, ws):
     self.ws = ws
     self.queue = hub.Queue()
     super(WebSocketRPCClient, self).__init__(
         JSONRPCProtocol(),
         WebSocketClientTransport(ws, self.queue),
     )
Beispiel #2
0
    def __init__(self, socket, address):
        super(Datapath, self).__init__()

        self.socket = socket
        self.socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
        self.socket.settimeout(CONF.socket_timeout)
        self.address = address
        self.is_active = True

        # The limit is arbitrary. We need to limit queue size to
        # prevent it from eating memory up.
        self.send_q = hub.Queue(16)
        self._send_q_sem = hub.BoundedSemaphore(self.send_q.maxsize)

        self.echo_request_interval = CONF.echo_request_interval
        self.max_unreplied_echo_requests = CONF.maximum_unreplied_echo_requests
        self.unreplied_echo_requests = []

        self.xid = random.randint(0, self.ofproto.MAX_XID)
        self.id = None  # datapath_id is unknown yet
        self._ports = None
        self.flow_format = ofproto_v1_0.NXFF_OPENFLOW10
        self.ofp_brick = os_ken.base.app_manager.lookup_service_brick(
            'ofp_event')
        self.state = None  # for pylint
        self.set_state(HANDSHAKE_DISPATCHER)
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super(ZClient, self).__init__(*args, **kwargs)
     self.zserv = None  # ZServer instance
     self.zserv_addr = (CONF.server_host, CONF.server_port)
     self.zserv_ver = CONF.server_version
     self.send_q = hub.Queue(16)
     self.route_type = get_zebra_route_type_by_name(CONF.client_route_type)
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     super(VRRPManager, self).__init__(*args, **kwargs)
     self._args = args
     self._kwargs = kwargs
     self.name = vrrp_event.VRRP_MANAGER_NAME
     self._instances = {}    # name -> VRRPInstance
     self.shutdown = hub.Queue()
Beispiel #5
0
    def __init__(self, server, sock, addr):
        self.server = server
        self.sock = sock
        self.addr = addr
        self.logger = server.logger
        self.is_active = False
        self._threads = []
        self.send_q = hub.Queue(16)

        # Zebra protocol version
        self.zserv_ver = CONF.server_version

        # Zebra route type distributed by client (not initialized yet)
        self.route_type = None
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super(RpcVRRPManager, self).__init__(*args, **kwargs)
        self.CONF.register_opts([
            cfg.IntOpt('vrrp-rpc-port',
                       default=VRRP_RPC_PORT,
                       help='port for vrrp rpc interface')
        ])

        self._args = args
        self._kwargs = kwargs
        self._peers = []
        self._rpc_events = hub.Queue(128)
        self.server_thread = hub.spawn(self._peer_accept_thread)
        self.event_thread = hub.spawn(self._rpc_request_loop_thread)
Beispiel #7
0
    def send_request(self, req):
        """
        Make a synchronous request.
        Set req.sync to True, send it to a OSKen application specified by
        req.dst, and block until receiving a reply.
        Returns the received reply.
        The argument should be an instance of EventRequestBase.
        """

        assert isinstance(req, EventRequestBase)
        req.sync = True
        req.reply_q = hub.Queue()
        self.send_event(req.dst, req)
        # going to sleep for the reply
        return req.reply_q.get()
Beispiel #8
0
    def __init__(self, *_args, **_kwargs):
        super(OSKenApp, self).__init__()
        self.name = self.__class__.__name__
        self.event_handlers = {}        # ev_cls -> handlers:list
        self.observers = {}     # ev_cls -> observer-name -> states:set
        self.threads = []
        self.main_thread = None
        self.events = hub.Queue(128)
        self._events_sem = hub.BoundedSemaphore(self.events.maxsize)
        if hasattr(self.__class__, 'LOGGER_NAME'):
            self.logger = logging.getLogger(self.__class__.LOGGER_NAME)
        else:
            self.logger = logging.getLogger(self.name)
        self.CONF = cfg.CONF

        # prevent accidental creation of instances of this class outside OSKenApp
        class _EventThreadStop(event.EventBase):
            pass
        self._event_stop = _EventThreadStop()
        self.is_active = True