本文整理汇总了Python中oslo_service.wsgi.Loader方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.Loader方法的具体用法?Python wsgi.Loader怎么用?Python wsgi.Loader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_service.wsgi
的用法示例。
在下文中一共展示了wsgi.Loader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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)
示例2: __init__
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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)
示例3: initialize_application
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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')
示例4: setUp
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
def setUp(self):
super(TestWSGIService, self).setUp()
self.mock_object(wsgi.Loader, 'load_app')
self.test_service = service.WSGIService("test_service")
示例5: test_service_random_port
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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")
示例6: test_reset_pool_size_to_default
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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")
示例7: __init__
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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
)
示例8: test_relpath_config_not_found
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
def test_relpath_config_not_found(self):
self.config(api_paste_config='api-paste.ini')
self.assertRaises(
wsgi.ConfigNotFound,
wsgi.Loader,
self.conf
)
示例9: test_asbpath_config_not_found
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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
)
示例10: setUp
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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)
示例11: __init__
# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Loader [as 别名]
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__()