Python oslo_service.wsgi.Server() Examples
The following are 25
code examples of oslo_service.wsgi.Server().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_service.wsgi
, or try the search function
.
Example #1
Source File: service.py From designate with Apache License 2.0 | 6 votes |
def __init__(self, app, name, listen, max_url_len=None): super(WSGIService, self).__init__(name) self.app = app self.name = name self.listen = listen self.servers = [] for address in self.listen: host, port = netutils.parse_host_port(address) server = wsgi.Server( CONF, name, app, host=host, port=port, pool_size=CONF['service:api'].threads, use_ssl=sslutils.is_enabled(CONF), max_url_len=max_url_len ) self.servers.append(server)
Example #2
Source File: service.py From vdi-broker with Apache License 2.0 | 6 votes |
def __init__(self, name): self._host = CONF.api_listen self._port = CONF.api_listen_port if platform.system() == "Windows": self._workers = 1 else: self._workers = ( CONF.api_workers or processutils.get_worker_count()) self._loader = wsgi.Loader(CONF) self._app = self._loader.load_app(name) self._server = wsgi.Server(CONF, name, self._app, host=self._host, port=self._port)
Example #3
Source File: service.py From qinling with Apache License 2.0 | 6 votes |
def __init__(self): self.app = app.setup_app() self.workers = CONF.api.api_workers if self.workers is not None and self.workers < 1: LOG.warning( "Value of config option api_workers must be integer " "greater than 1. Input value ignored." ) self.workers = None self.workers = self.workers or processutils.get_worker_count() self.server = wsgi.Server( cfg.CONF, "qinling_api", self.app, host=cfg.CONF.api.host, port=cfg.CONF.api.port, use_ssl=cfg.CONF.api.enable_ssl_api )
Example #4
Source File: service.py From cyborg with Apache License 2.0 | 6 votes |
def __init__(self, name, use_ssl=False): """Initialize, but do not start the WSGI server. :param name: The name of the WSGI server given to the loader. :param use_ssl: Wraps the socket in an SSL context if True. :returns: None """ self.name = name self.app = app.load_app() self.workers = (CONF.api.api_workers or processutils.get_worker_count()) if self.workers and self.workers < 1: raise exception.ConfigInvalid( _("api_workers value of %d is invalid, " "must be greater than 0.") % self.workers) self.server = wsgi.Server(CONF, self.name, self.app, host=CONF.api.host_ip, port=CONF.api.port, use_ssl=use_ssl)
Example #5
Source File: service.py From coriolis with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, name): self._host = CONF.api_migration_listen self._port = CONF.api_migration_listen_port if platform.system() == "Windows": self._workers = 1 else: self._workers = ( CONF.api_migration_workers or processutils.get_worker_count()) self._loader = wsgi.Loader(CONF) self._app = self._loader.load_app(name) self._server = wsgi.Server(CONF, name, self._app, host=self._host, port=self._port)
Example #6
Source File: service.py From senlin with Apache License 2.0 | 6 votes |
def __init__(self, app, name, listen, max_url_len=None): super(WSGIService, self).__init__(CONF.senlin_api.threads) self.app = app self.name = name self.listen = listen self.servers = [] for address in self.listen: host, port = netutils.parse_host_port(address) server = wsgi.Server( CONF, name, app, host=host, port=port, pool_size=CONF.senlin_api.threads, use_ssl=sslutils.is_enabled(CONF), max_url_len=max_url_len ) self.servers.append(server)
Example #7
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 6 votes |
def test_socket_options_for_simple_server(self): # test normal socket options has set properly self.config(tcp_keepidle=500) server = wsgi.Server(self.conf, "test_socket_options", None, host="127.0.0.1", port=0) server.start() sock = server.socket self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)) if hasattr(socket, 'TCP_KEEPIDLE'): self.assertEqual(self.conf.tcp_keepidle, sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE)) self.assertFalse(server._server.dead) server.stop() server.wait() self.assertTrue(server._server.dead)
Example #8
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 6 votes |
def test_uri_length_limit(self): eventlet.monkey_patch(os=False, thread=False) server = wsgi.Server(self.conf, "test_uri_length_limit", None, host="127.0.0.1", max_url_len=16384, port=33337) server.start() self.assertFalse(server._server.dead) uri = "http://127.0.0.1:%d/%s" % (server.port, 10000 * 'x') resp = requests.get(uri, proxies={"http": ""}) eventlet.sleep(0) self.assertNotEqual(requests.codes.REQUEST_URI_TOO_LARGE, resp.status_code) uri = "http://127.0.0.1:%d/%s" % (server.port, 20000 * 'x') resp = requests.get(uri, proxies={"http": ""}) eventlet.sleep(0) self.assertEqual(requests.codes.REQUEST_URI_TOO_LARGE, resp.status_code) server.stop() server.wait()
Example #9
Source File: service.py From zun with Apache License 2.0 | 6 votes |
def __init__(self, name, use_ssl=False): """Initialize, but do not start the WSGI server. :param name: The name of the WSGI server given to the loader. :param use_ssl: Wraps the socket in an SSL context if True. :returns: None """ self.name = name self.app = app.load_app() self.workers = (CONF.api.workers or processutils.get_worker_count()) if self.workers and self.workers < 1: raise exception.ConfigInvalid( _("api_workers value of %d is invalid, " "must be greater than 0.") % self.workers) self.server = wsgi.Server(CONF, name, self.app, host=CONF.api.host_ip, port=CONF.api.port, use_ssl=use_ssl)
Example #10
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 6 votes |
def test_socket_options_for_ssl_server(self): # test normal socket options has set properly self.config(tcp_keepidle=500) server = wsgi.Server(self.conf, "test_socket_options", None, host="127.0.0.1", port=0, use_ssl=True) server.start() sock = server.socket self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)) self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)) if hasattr(socket, 'TCP_KEEPIDLE'): self.assertEqual(CONF.tcp_keepidle, sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE)) server.stop() server.wait()
Example #11
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_reset_pool_size_to_default(self): server = wsgi.Server(self.conf, "test_resize", None, host="127.0.0.1", max_url_len=16384) server.start() # Stopping the server, which in turn sets pool size to 0 server.stop() self.assertEqual(0, server._pool.size) # Resetting pool size to default server.reset() server.start() self.assertEqual(CONF.wsgi_default_pool_size, server._pool.size)
Example #12
Source File: service.py From karbor with Apache License 2.0 | 5 votes |
def __init__(self, name, loader=None): """Initialize, but do not start the WSGI server. :param name: The name of the WSGI server given to the loader. :param loader: Loads the WSGI application using the given name. :returns: None """ self.name = name self.manager = self._get_manager() self.loader = loader or wsgi.Loader(CONF) self.app = self.loader.load_app(name) self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0") self.port = getattr(CONF, '%s_listen_port' % name, 0) self.workers = (getattr(CONF, '%s_workers' % name, None) or processutils.get_worker_count()) if self.workers and self.workers < 1: worker_name = '%s_workers' % name msg = (_("%(worker_name)s value of %(workers)d is invalid, " "must be greater than 0.") % {'worker_name': worker_name, 'workers': self.workers}) raise exception.InvalidInput(msg) self.server = wsgi.Server(CONF, name, self.app, host=self.host, port=self.port) super(WSGIService, self).__init__()
Example #13
Source File: wsgi_service.py From ironic-inspector with Apache License 2.0 | 5 votes |
def __init__(self): self.app = main.get_app() self.server = wsgi.Server(CONF, 'ironic_inspector', self.app, host=CONF.listen_address, port=CONF.listen_port, use_ssl=CONF.use_ssl)
Example #14
Source File: service.py From watcher with Apache License 2.0 | 5 votes |
def __init__(self, service_name, use_ssl=False): """Initialize, but do not start the WSGI server. :param service_name: The service name of the WSGI server. :param use_ssl: Wraps the socket in an SSL context if True. """ self.service_name = service_name self.app = app.VersionSelectorApplication() self.workers = (CONF.api.workers or processutils.get_worker_count()) self.server = wsgi.Server(CONF, self.service_name, self.app, host=CONF.api.host, port=CONF.api.port, use_ssl=use_ssl, logger_name=self.service_name)
Example #15
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_app_using_ipv6_and_ssl(self): greetings = 'Hello, World!!!' @webob.dec.wsgify def hello_world(req): return greetings server = wsgi.Server(self.conf, "fake_ssl", hello_world, host="::1", port=0, use_ssl=True) server.start() response = requesting( method='GET', host='::1', port=server.port, ca_certs=os.path.join(SSL_CERT_DIR, 'ca.crt'), address_familly=socket.AF_INET6 ) self.assertEqual(greetings, response[-15:]) server.stop() server.wait()
Example #16
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_two_servers(self): def test_app(env, start_response): start_response('200 OK', {}) return ['PONG'] fake_ssl_server = wsgi.Server(self.conf, "fake_ssl", test_app, host="127.0.0.1", port=0, use_ssl=True) fake_ssl_server.start() self.assertNotEqual(0, fake_ssl_server.port) fake_server = wsgi.Server(self.conf, "fake", test_app, host="127.0.0.1", port=0) fake_server.start() self.assertNotEqual(0, fake_server.port) response = requesting( method='GET', host='127.0.0.1', port=fake_ssl_server.port, ca_certs=os.path.join(SSL_CERT_DIR, 'ca.crt'), ) self.assertEqual('PONG', response[-4:]) response = requesting( method='GET', host='127.0.0.1', port=fake_server.port, ) self.assertEqual('PONG', response[-4:]) fake_ssl_server.stop() fake_ssl_server.wait() fake_server.stop() fake_server.wait()
Example #17
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_wsgi_keep_alive(self): self.config(wsgi_keep_alive=False) # mocking eventlet spawn method to check it is called with # configured 'wsgi_keep_alive' value. with mock.patch.object(eventlet, 'spawn') as mock_spawn: server = wsgi.Server(self.conf, "test_app", None, host="127.0.0.1", port=0) server.start() _, kwargs = mock_spawn.call_args self.assertEqual(self.conf.wsgi_keep_alive, kwargs['keepalive']) server.stop()
Example #18
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_client_socket_timeout(self): self.config(client_socket_timeout=5) # mocking eventlet spawn method to check it is called with # configured 'client_socket_timeout' value. with mock.patch.object(eventlet, 'spawn') as mock_spawn: server = wsgi.Server(self.conf, "test_app", None, host="127.0.0.1", port=0) server.start() _, kwargs = mock_spawn.call_args self.assertEqual(self.conf.client_socket_timeout, kwargs['socket_timeout']) server.stop()
Example #19
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_server_pool_waitall(self): # test pools waitall method gets called while stopping server server = wsgi.Server(self.conf, "test_server", None, host="127.0.0.1") server.start() with mock.patch.object(server._pool, 'waitall') as mock_waitall: server.stop() server.wait() mock_waitall.assert_called_once_with()
Example #20
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_start_random_port_with_ipv6(self): server = wsgi.Server(self.conf, "test_random_port", None, host="::1", port=0) server.start() self.assertEqual("::1", server.host) self.assertNotEqual(0, server.port) server.stop() server.wait()
Example #21
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_start_random_port(self): server = wsgi.Server(self.conf, "test_random_port", None, host="127.0.0.1", port=0) server.start() self.assertNotEqual(0, server.port) server.stop() server.wait()
Example #22
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_custom_max_header_line(self): self.config(max_header_line=4096) # Default value is 16384 wsgi.Server(self.conf, "test_custom_max_header_line", None) self.assertEqual(eventlet.wsgi.MAX_HEADER_LINE, self.conf.max_header_line)
Example #23
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_no_app(self): server = wsgi.Server(self.conf, "test_app", None) self.assertEqual("test_app", server.name)
Example #24
Source File: service.py From manila with Apache License 2.0 | 5 votes |
def __init__(self, name, loader=None): """Initialize, but do not start the WSGI server. :param name: The name of the WSGI server given to the loader. :param loader: Loads the WSGI application using the given name. :returns: None """ self.name = name self.manager = self._get_manager() self.loader = loader or wsgi.Loader(CONF) if not rpc.initialized(): rpc.init(CONF) self.app = self.loader.load_app(name) self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0") self.port = getattr(CONF, '%s_listen_port' % name, 0) self.workers = getattr(CONF, '%s_workers' % name, None) self.use_ssl = getattr(CONF, '%s_use_ssl' % name, False) if self.workers is not None and self.workers < 1: LOG.warning( "Value of config option %(name)s_workers must be integer " "greater than 1. Input value ignored.", {'name': name}) # Reset workers to default self.workers = None self.server = wsgi.Server( CONF, name, self.app, host=self.host, port=self.port, use_ssl=self.use_ssl )
Example #25
Source File: service.py From designate with Apache License 2.0 | 5 votes |
def __init__(self, name, rpc_topic, threads=None): super(RPCService, self).__init__(name, threads) LOG.debug("Creating RPC Server on topic '%s' for %s", rpc_topic, self.name) self.endpoints = [self] self.notifier = None self.rpc_server = None self.rpc_topic = rpc_topic