示例#1
0
    def __init__(self, mapper):
        """Create a router for the given routes.Mapper.

        Each route in `mapper` must specify a 'controller', which is a
        WSGI app to call.  You'll probably want to specify an 'action' as
        well and have your controller be an object that can route
        the request to the action-specific method.

        Examples:
          mapper = routes.Mapper()
          sc = ServerController()

          # Explicit mapping of one route to a controller+action
          mapper.connect(None, '/svrlist', controller=sc, action='list')

          # Actions are all implicitly defined
          mapper.resource('server', 'servers', controller=sc)

          # Pointing to an arbitrary WSGI app.  You can specify the
          # {path_info:.*} parameter so the target app can be handed just that
          # section of the URL.
          mapper.connect(None, '/v1.0/{path_info:.*}', controller=BlogApp())

        """
        # if we're only running in debug, bump routes' internal logging up a
        # notch, as it's very spammy
        if CONF.debug:
            logging.getLogger('routes.middleware').setLevel(logging.INFO)

        self.map = mapper
        self._router = routes.middleware.RoutesMiddleware(self._dispatch,
                                                          self.map)
示例#2
0
 def _run(self, application, socket):
     """Start a WSGI server in a new green thread."""
     log = logging.getLogger('eventlet.wsgi.server')
     try:
         eventlet.wsgi.server(socket, application, custom_pool=self.pool,
                              log=WritableLogger(log))
     except Exception:
         LOG.exception(_('Server error'))
         raise
示例#3
0
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from keystone import config
from keystone.common import logging
from keystone.catalog.backends import kvs


LOG = logging.getLogger('keystone.catalog.backends.templated')

CONF = config.CONF
config.register_str('template_file', group='catalog')


def parse_templates(template_lines):
    o = {}
    for line in template_lines:
        if ' = ' not in line:
            continue

        k, v = line.strip().split(' = ')
        if not k.startswith('catalog.'):
            continue
示例#4
0
import eventlet.wsgi
import routes.middleware
import ssl
import webob.dec
import webob.exc

from keystone.common import config
from keystone.common import logging
from keystone.common import utils
from keystone import exception
from keystone.openstack.common import importutils
from keystone.openstack.common import jsonutils


CONF = config.CONF
LOG = logging.getLogger(__name__)

# Environment variable used to pass the request context
CONTEXT_ENV = 'openstack.context'


# Environment variable used to pass the request params
PARAMS_ENV = 'openstack.params'


class WritableLogger(object):
    """A thin wrapper that responds to `write` and logs."""

    def __init__(self, logger, level=logging.DEBUG):
        self.logger = logger
        self.level = level
示例#5
0
文件: wsgi.py 项目: jaryn/keystone
 def _run(self, application, socket):
     """Start a WSGI server in a new green thread."""
     log = logging.getLogger("eventlet.wsgi.server")
     eventlet.wsgi.server(socket, application, custom_pool=self.pool, log=WritableLogger(log))
示例#6
0
文件: test.py 项目: kwss2/keystone
from keystone.common import logging
from keystone.common import utils
from keystone.common import wsgi
from keystone import config
from keystone import exception
from keystone import identity
from keystone.openstack.common import timeutils
from keystone import policy
from keystone import token
from keystone import trust


do_monkeypatch = not os.getenv("STANDARD_THREADS")
eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=do_monkeypatch)

LOG = logging.getLogger(__name__)
ROOTDIR = os.path.dirname(os.path.abspath(os.curdir))
VENDOR = os.path.join(ROOTDIR, "vendor")
TESTSDIR = os.path.join(ROOTDIR, "tests")
ETCDIR = os.path.join(ROOTDIR, "etc")
CONF = config.CONF
DRIVERS = {}


cd = os.chdir


logging.getLogger("routes.middleware").level = logging.WARN


def rootdir(*p):
示例#7
0
policy_opts = [
    cfg.StrOpt('policy_file',
               default='policy.json',
               help=_('JSON file representing policy')),
    cfg.StrOpt('policy_default_rule',
               default='default',
               help=_('Rule checked when requested rule is not found')),
    ]


CONF = config.CONF
CONF.register_opts(policy_opts)


LOG = logging.getLogger('keystone.policy.backends.rules')


_POLICY_PATH = None
_POLICY_CACHE = {}


def reset():
    global _POLICY_PATH
    global _POLICY_CACHE
    _POLICY_PATH = None
    _POLICY_CACHE = {}
    common_policy.reset()


def init():
示例#8
0
import os
from paste import deploy
from keystone.common import logging
from keystone import config

LOG = logging.getLogger(__name__)
CONF = config.CONF
config_files = ['/etc/keystone/keystone.conf']
CONF(project='keystone', default_config_files=config_files)
config.setup_logging(CONF)

conf = CONF.config_file[0]
name = os.path.basename(__file__)

if CONF.debug:
    CONF.log_opt_values(logging.getLogger(CONF.prog), logging.DEBUG)

options = deploy.appconfig('config:%s' % CONF.config_file[0])
application = deploy.loadapp('config:%s' % conf, name=name)
示例#9
0
文件: core.py 项目: 0xffea/keystone
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import webob
import webob.dec

from keystone.common import logging
from keystone.common import wsgi
from keystone import config
from keystone.openstack.common import timeutils


CONF = config.CONF
LOG = logging.getLogger('access')
APACHE_TIME_FORMAT = '%d/%b/%Y:%H:%M:%S'
APACHE_LOG_FORMAT = (
    '%(remote_addr)s - %(remote_user)s [%(datetime)s] "%(method)s %(url)s '
    '%(http_version)s" %(status)s %(content_length)s')


class AccessLogMiddleware(wsgi.Middleware):
    """Writes an access log to INFO."""

    @webob.dec.wsgify
    def __call__(self, request):
        data = {
            'remote_addr': request.remote_addr,
            'remote_user': request.remote_user or '-',
            'method': request.method,
示例#10
0
.. warning::

    If you use this, be sure that the libraries you are using do not access
    the socket directly (xmlrpclib, I'm looking at you :/), and instead
    make all calls through httplib.
"""

import time
from urllib import quote

from eventlet.green.httplib import (CONTINUE, HTTPConnection, HTTPMessage,
                                    HTTPResponse, HTTPSConnection, _UNKNOWN)

from keystone.common import logging

LOG = logging.getLogger(__name__)


class BufferedHTTPResponse(HTTPResponse):
    """HTTPResponse class that buffers reading of headers"""
    def __init__(self,
                 sock,
                 debuglevel=0,
                 strict=0,
                 method=None):  # pragma: no cover
        self.sock = sock
        self.fp = sock.makefile('rb')
        self.debuglevel = debuglevel
        self.strict = strict
        self._method = method
示例#11
0
文件: core.py 项目: t4n6a1ka/keystone
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import webob
import webob.dec

from keystone.common import logging
from keystone.common import wsgi
from keystone import config
from keystone.openstack.common import timeutils

CONF = config.CONF
LOG = logging.getLogger('access')
APACHE_TIME_FORMAT = '%d/%b/%Y:%H:%M:%S'
APACHE_LOG_FORMAT = (
    '%(remote_addr)s - %(remote_user)s [%(datetime)s] "%(method)s %(url)s '
    '%(http_version)s" %(status)s %(content_length)s')


class AccessLogMiddleware(wsgi.Middleware):
    """Writes an access log to INFO."""
    @webob.dec.wsgify
    def __call__(self, request):
        data = {
            'remote_addr': request.remote_addr,
            'remote_user': request.remote_user or '-',
            'method': request.method,
            'url': request.url,
示例#12
0
from keystone.common import wsgi
from keystone import config
from keystone import exception
from keystone import identity
from keystone.openstack.common import timeutils
from keystone import policy
from keystone import token
from keystone import trust

do_monkeypatch = not os.getenv('STANDARD_THREADS')
eventlet.patcher.monkey_patch(all=False,
                              socket=True,
                              time=True,
                              thread=do_monkeypatch)

LOG = logging.getLogger(__name__)
ROOTDIR = os.path.dirname(os.path.abspath(os.curdir))
VENDOR = os.path.join(ROOTDIR, 'vendor')
TESTSDIR = os.path.join(ROOTDIR, 'tests')
ETCDIR = os.path.join(ROOTDIR, 'etc')
CONF = config.CONF
DRIVERS = {}

cd = os.chdir

logging.getLogger('routes.middleware').level = logging.WARN


def rootdir(*p):
    return os.path.join(ROOTDIR, *p)
示例#13
0
import os

from paste import deploy

from keystone import config
from keystone.common import logging

LOG = logging.getLogger(__name__)
CONF = config.CONF
config_files = ['/etc/keystone.conf']
CONF(config_files=config_files)

conf = CONF.config_file[0]
name = os.path.basename(__file__)

if CONF.debug:
    CONF.log_opt_values(logging.getLogger(CONF.prog), logging.DEBUG)

options = deploy.appconfig('config:%s' % CONF.config_file[0])

application = deploy.loadapp('config:%s' % conf, name=name)