~ubuntu-branches/ubuntu/vivid/neutron/vivid-updates

« back to all changes in this revision

Viewing changes to neutron/wsgi.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:17:19 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150330111719-h0gx7233p4jkkgfh
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream.
  - d/control: Add new dependency on oslo-log.
  - d/p/*: Rebase.
  - d/control,d/neutron-plugin-hyperv*: Dropped, decomposed into
    separate project upstream.
  - d/control,d/neutron-plugin-openflow*: Dropped, decomposed into
    separate project upstream.
  - d/neutron-common.install: Add neutron-rootwrap-daemon and 
    neutron-keepalived-state-change binaries.
  - d/rules: Ignore neutron-hyperv-agent when installing; only for Windows.
  - d/neutron-plugin-cisco.install: Drop neutron-cisco-cfg-agent as
    decomposed into separate project upstream.
  - d/neutron-plugin-vmware.install: Drop neutron-check-nsx-config and
    neutron-nsx-manage as decomposed into separate project upstream.
  - d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent.
* d/pydist-overrides: Add overrides for oslo packages.
* d/control: Fixup type in package description (LP: #1263539).
* d/p/fixup-driver-test-execution.patch: Cherry pick fix from upstream VCS
  to support unit test exection in out-of-tree vendor drivers.
* d/neutron-common.postinst: Allow general access to /etc/neutron but limit
  access to root/neutron to /etc/neutron/neutron.conf to support execution
  of unit tests in decomposed vendor drivers.
* d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import time
27
27
 
28
28
import eventlet.wsgi
29
 
eventlet.patcher.monkey_patch(all=False, socket=True, thread=True)
30
 
from oslo.config import cfg
31
 
from oslo import i18n
32
 
from oslo.serialization import jsonutils
33
 
from oslo.utils import excutils
 
29
from oslo_config import cfg
 
30
import oslo_i18n
 
31
from oslo_log import log as logging
 
32
from oslo_log import loggers
 
33
from oslo_serialization import jsonutils
 
34
from oslo_utils import excutils
34
35
import routes.middleware
35
36
import webob.dec
36
37
import webob.exc
39
40
from neutron import context
40
41
from neutron.db import api
41
42
from neutron.i18n import _LE, _LI
42
 
from neutron.openstack.common import log as logging
43
43
from neutron.openstack.common import service as common_service
44
44
from neutron.openstack.common import systemd
45
45
 
119
119
class Server(object):
120
120
    """Server class to manage multiple WSGI sockets and applications."""
121
121
 
122
 
    def __init__(self, name, threads=1000):
 
122
    def __init__(self, name, num_threads=1000):
123
123
        # Raise the default from 8192 to accommodate large tokens
124
124
        eventlet.wsgi.MAX_HEADER_LINE = CONF.max_header_line
125
 
        self.pool = eventlet.GreenPool(threads)
 
125
        self.num_threads = num_threads
 
126
        # Pool for a greenthread in which wsgi server will be running
 
127
        self.pool = eventlet.GreenPool(1)
126
128
        self.name = name
127
129
        self._server = None
128
130
        # A value of 0 is converted to None because None is what causes the
255
257
 
256
258
    def _run(self, application, socket):
257
259
        """Start a WSGI server in a new green thread."""
258
 
        eventlet.wsgi.server(socket, application, custom_pool=self.pool,
259
 
                             log=logging.WritableLogger(LOG),
 
260
        eventlet.wsgi.server(socket, application,
 
261
                             max_size=self.num_threads,
 
262
                             log=loggers.WritableLogger(LOG),
260
263
                             keepalive=CONF.wsgi_keep_alive,
261
264
                             socket_timeout=self.client_socket_timeout)
262
265
 
367
370
        """
368
371
        if not self.accept_language:
369
372
            return None
370
 
        all_languages = i18n.get_available_languages('neutron')
 
373
        all_languages = oslo_i18n.get_available_languages('neutron')
371
374
        return self.accept_language.best_match(all_languages)
372
375
 
373
376
    @property
682
685
class Router(object):
683
686
    """WSGI middleware that maps incoming requests to WSGI apps."""
684
687
 
685
 
    @classmethod
686
 
    def factory(cls, global_config, **local_config):
687
 
        """Return an instance of the WSGI Router class."""
688
 
        return cls()
689
 
 
690
688
    def __init__(self, mapper):
691
689
        """Create a router for the given routes.Mapper.
692
690
 
735
733
        if not match:
736
734
            language = req.best_match_language()
737
735
            msg = _('The resource could not be found.')
738
 
            msg = i18n.translate(msg, language)
 
736
            msg = oslo_i18n.translate(msg, language)
739
737
            return webob.exc.HTTPNotFound(explanation=msg)
740
738
        app = match['controller']
741
739
        return app