コード例 #1
0
def _get_dbdriver_instance():
    """Return a DB API instance."""
    if CONF.db_type == 'sql':
        return IMPL
    elif CONF.db_type == 'etcd':
        import zun.db.etcd.api as etcd_api
        return etcd_api.get_connection()
    else:
        raise exception.ConfigInvalid(
            _("db_type value of %s is invalid, "
              "must be sql or etcd") % CONF.db_type)
コード例 #2
0
ファイル: auth_token.py プロジェクト: zukobronja/zun
    def __init__(self, app, conf, public_api_routes=None):
        if public_api_routes is None:
            public_api_routes = []
        route_pattern_tpl = '%s(\.json)?$'

        try:
            self.public_api_routes = [re.compile(route_pattern_tpl % route_tpl)
                                      for route_tpl in public_api_routes]
        except re.error as e:
            msg = _('Cannot compile public API routes: %s') % e

            LOG.error(msg)
            raise exception.ConfigInvalid(error_msg=msg)

        super(AuthTokenMiddleware, self).__init__(app, conf)
コード例 #3
0
    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)