コード例 #1
0
    def start(self):
        if ip.valid_ipv6(self._address):
            server = hub.listen((self._address, self._port),
                                family=socket.AF_INET6)
        else:
            server = hub.listen((self._address, self._port))
        key = self.CONF.ovsdb.mngr_privkey or self.CONF.ctl_privkey
        cert = self.CONF.ovsdb.mngr_cert or self.CONF.ctl_cert

        if key is not None and cert is not None:
            ssl_kwargs = dict(keyfile=key, certfile=cert, server_side=True)

            if self.CONF.ca_certs is not None:
                ssl_kwargs['cert_reqs'] = ssl.CERT_REQUIRED
                ssl_kwargs['ca_certs'] = self.CONF.ca_certs

            server = ssl.wrap_socket(server, **ssl_kwargs)

        self._server = server

        if ip.valid_ipv6(self._address):
            self.logger.info('Listening on [%s]:%s for clients', self._address,
                             self._port)
        else:
            self.logger.info('Listening on %s:%s for clients', self._address,
                             self._port)
        t = hub.spawn(self._accept, self._server)
        super(OVSDB, self).start()
        return t
コード例 #2
0
    def _listen_tcp(self, loc_addr, conn_handle):
        """Creates a TCP server socket which listens on `port` number.

        For each connection `server_factory` starts a new protocol.
        """
        if ':' in loc_addr[0]:
            server = hub.listen(loc_addr, family=socket.AF_INET6)
        else:
            server = hub.listen(loc_addr)

        server_name = self.name + '_server@' + str(loc_addr)
        self._asso_socket_map[server_name] = server

        # We now wait for connection requests from client.
        while True:
            sock, client_address = server.accept()
            client_address, port = client_address[:2]
            LOG.debug('Connect request received from client for port'
                      ' %s:%s' % (client_address, port))
            if 'ffff:' in client_address:
                client_address = str(netaddr.IPAddress(client_address).ipv4())

            client_name = self.name + '_client@' + client_address
            self._asso_socket_map[client_name] = sock
            self._spawn(client_name, conn_handle, sock)
コード例 #3
0
ファイル: base.py プロジェクト: ItoYuichi/ryu
    def _listen_tcp(self, loc_addr, conn_handle):
        """Creates a TCP server socket which listens on `port` number.

        For each connection `server_factory` starts a new protocol.
        """
        if ':' in loc_addr[0]:
            server = hub.listen(loc_addr, family=socket.AF_INET6)
        else:
            server = hub.listen(loc_addr)

        server_name = self.name + '_server@' + str(loc_addr)
        self._asso_socket_map[server_name] = server

        # We now wait for connection requests from client.
        while True:
            sock, client_address = server.accept()
            client_address, port = client_address[:2]
            LOG.debug('Connect request received from client for port'
                      ' %s:%s' % (client_address, port))
            if 'ffff:' in client_address:
                client_address = str(netaddr.IPAddress(client_address).ipv4())

            client_name = self.name + '_client@' + client_address
            self._asso_socket_map[client_name] = sock
            self._spawn(client_name, conn_handle, sock)
コード例 #4
0
    def __init__(self, *args, **kwargs):
        super(Plexus, self).__init__(*args, **kwargs)

        # logger configure
        PlexusController.set_logger(self.logger)

        # Set up backdoor REPL, if requested.
        if CONF.plexus.backdoor_enable:
            hub.spawn(backdoor.backdoor_server, hub.listen(('localhost', CONF.plexus.backdoor_listen_port)))

        wsgi = kwargs['wsgi']
        self.waiters = {}
        self.data = {'waiters': self.waiters}

        mapper = wsgi.mapper
        wsgi.registory['PlexusController'] = self.data
        requirements = {'switch_id': SWITCHID_PATTERN,
                        'vlan_id': VLANID_PATTERN}

        # For no vlan data
        path = '/router/{switch_id}'
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='get_data',
                       conditions=dict(method=['GET']))
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='set_data',
                       conditions=dict(method=['POST']))
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='delete_data',
                       conditions=dict(method=['DELETE']))
        # For vlan data
        path = '/router/{switch_id}/{vlan_id}'
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='get_vlan_data',
                       conditions=dict(method=['GET']))
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='set_vlan_data',
                       conditions=dict(method=['POST']))
        mapper.connect('router', path, controller=PlexusController,
                       requirements=requirements,
                       action='delete_vlan_data',
                       conditions=dict(method=['DELETE']))
コード例 #5
0
    def _listen_tcp(self, loc_addr, conn_handle):
        """Creates a TCP server socket which listens on `port` number.

        For each connection `server_factory` starts a new protocol.
        """
        server = hub.listen(loc_addr)
        server_name = self.name + '_server@' + str(loc_addr)
        self._asso_socket_map[server_name] = server

        # We now wait for connection requests from client.
        while True:
            sock, client_address = server.accept()
            LOG.debug('Connect request received from client for port'
                      ' %s:%s' % client_address)
            client_name = self.name + '_client@' + str(client_address)
            self._asso_socket_map[client_name] = sock
            self._spawn(client_name, conn_handle, sock)
コード例 #6
0
ファイル: manager.py プロジェクト: bahjatmanesh/ryu
    def start(self):
        server = hub.listen((self._address, self._port))
        key = self.CONF.ovsdb.mngr_privkey or self.CONF.ctl_privkey
        cert = self.CONF.ovsdb.mngr_cert or self.CONF.ctl_cert

        if key is not None and cert is not None:
            ssl_kwargs = dict(keyfile=key, certfile=cert, server_side=True)

            if self.CONF.ca_certs is not None:
                ssl_kwargs["cert_reqs"] = ssl.CERT_REQUIRED
                ssl_kwargs["ca_certs"] = self.CONF.ca_certs

            server = ssl.wrap_socket(server, **ssl_kwargs)

        self._server = server

        self.logger.info("Listening on %s:%s for clients" % (self._address, self._port))
        t = hub.spawn(self._accept, self._server)
        super(OVSDB, self).start()
        return t