Python oslo_service.wsgi.Loader() Examples
The following are 11
code examples of oslo_service.wsgi.Loader().
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 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 #2
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 #3
Source File: wsgi.py From manila with Apache License 2.0 | 5 votes |
def initialize_application(): log.register_options(CONF) CONF(sys.argv[1:], project="manila", version=version.version_string()) config.verify_share_protocols() log.setup(CONF, "manila") rpc.init(CONF) return wsgi.Loader(CONF).load_app(name='osapi_share')
Example #4
Source File: test_service.py From manila with Apache License 2.0 | 5 votes |
def setUp(self): super(TestWSGIService, self).setUp() self.mock_object(wsgi.Loader, 'load_app') self.test_service = service.WSGIService("test_service")
Example #5
Source File: test_service.py From manila with Apache License 2.0 | 5 votes |
def test_service_random_port(self): self.assertEqual(0, self.test_service.port) self.test_service.start() self.assertNotEqual(0, self.test_service.port) self.test_service.stop() wsgi.Loader.load_app.assert_called_once_with("test_service")
Example #6
Source File: test_service.py From manila with Apache License 2.0 | 5 votes |
def test_reset_pool_size_to_default(self): self.test_service.start() # Stopping the service, which in turn sets pool size to 0 self.test_service.stop() self.assertEqual(0, self.test_service.server._pool.size) # Resetting pool size to default self.test_service.reset() self.test_service.start() self.assertGreater(self.test_service.server._pool.size, 0) wsgi.Loader.load_app.assert_called_once_with("test_service")
Example #7
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 #8
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_relpath_config_not_found(self): self.config(api_paste_config='api-paste.ini') self.assertRaises( wsgi.ConfigNotFound, wsgi.Loader, self.conf )
Example #9
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def test_asbpath_config_not_found(self): self.config(api_paste_config='/etc/openstack-srv/api-paste.ini') self.assertRaises( wsgi.ConfigNotFound, wsgi.Loader, self.conf )
Example #10
Source File: test_wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def setUp(self): super(TestLoaderNormalFilesystem, self).setUp() self.paste_config = tempfile.NamedTemporaryFile(mode="w+t") self.paste_config.write(self._paste_config.lstrip()) self.paste_config.seek(0) self.paste_config.flush() self.config(api_paste_config=self.paste_config.name) self.loader = wsgi.Loader(CONF)
Example #11
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__()