Exemple #1
0
def _wrap_app(app):
    app = request_id.RequestId(app)
    if cfg.CONF.auth_strategy == 'noauth':
        pass
    elif cfg.CONF.auth_strategy == 'keystone':
        app = auth_token.AuthProtocol(app, {})
    else:
        raise n_exc.InvalidConfigurationOption(
            opt_name='auth_strategy', opt_value=cfg.CONF.auth_strategy)

    # version can be unauthenticated so it goes outside of auth
    app = versions.Versions(app)

    # This should be the last middleware in the list (which results in
    # it being the first in the middleware chain). This is to ensure
    # that any errors thrown by other middleware, such as an auth
    # middleware - are annotated with CORS headers, and thus accessible
    # by the browser.
    app = cors.CORS(app, cfg.CONF)
    app.set_latent(allow_headers=[
        'X-Auth-Token', 'X-Identity-Status', 'X-Roles', 'X-Service-Catalog',
        'X-User-Id', 'X-Tenant-Id', 'X-OpenStack-Request-ID', 'X-Trace-Info',
        'X-Trace-HMAC'
    ],
                   allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
                   expose_headers=[
                       'X-Auth-Token', 'X-Subject-Token', 'X-Service-Token',
                       'X-OpenStack-Request-ID', 'X-Trace-Info', 'X-Trace-HMAC'
                   ])

    return app
Exemple #2
0
 def __init__(self, host=None, conf=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.dhcp_ready_ports = set()
     self.conf = conf or cfg.CONF
     # If 'resync_throttle' is configured more than 'resync_interval' by
     # mistake, raise exception and log with message.
     if self.conf.resync_throttle > self.conf.resync_interval:
         msg = _("DHCP agent must have resync_throttle <= resync_interval")
         LOG.exception(msg)
         raise exceptions.InvalidConfigurationOption(
             opt_name='resync_throttle',
             opt_value=self.conf.resync_throttle)
     self._periodic_resync_event = threading.Event()
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, self.conf.host)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     fileutils.ensure_tree(dhcp_dir, mode=0o755)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     # keep track of mappings between networks and routers for
     # metadata processing
     self._metadata_routers = {}  # {network_id: router_id}
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf,
         resource_type='dhcp')
     self._pool_size = DHCP_PROCESS_GREENLET_MIN
     self._pool = eventlet.GreenPool(size=self._pool_size)
     self._queue = queue.ResourceProcessingQueue()
Exemple #3
0
 def __init__(self, host=None, conf=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.dhcp_ready_ports = set()
     self.dhcp_prio_ready_ports = set()
     self.conf = conf or cfg.CONF
     # If 'resync_throttle' is configured more than 'resync_interval' by
     # mistake, raise exception and log with message.
     if self.conf.resync_throttle > self.conf.resync_interval:
         LOG.exception("DHCP agent must have resync_throttle <= "
                       "resync_interval")
         raise exceptions.InvalidConfigurationOption(
             opt_name='resync_throttle',
             opt_value=self.conf.resync_throttle)
     self._periodic_resync_event = threading.Event()
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, self.conf.host)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     fileutils.ensure_tree(dhcp_dir, mode=0o755)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     # keep track of mappings between networks and routers for
     # metadata processing
     self._metadata_routers = {}  # {network_id: router_id}
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf,
         resource_type='dhcp')
     self._pool_size = DHCP_PROCESS_GREENLET_MIN
     self._pool = eventlet.GreenPool(size=self._pool_size)
     self._queue = queue.ResourceProcessingQueue()
     self._network_bulk_allocations = {}
     # Each dhcp-agent restart should trigger a restart of all
     # metadata-proxies too. This way we can ensure that changes in
     # the metadata-proxy config we generate will be applied soon
     # after a new version of dhcp-agent is started. This makes
     # the metadata service transiently offline. However similar
     # metadata-proxy restarts were always done by l3-agent so people
     # can apparently live with short metadata outages. We only stop
     # the process here and let the process monitor restart it,
     # first because it knows everything about how to restart it,
     # second because (unless we temporarily disable the monitor too)
     # we could race with the monitor restarting the process. See also
     # method update_isolated_metadata_proxy().
     self.restarted_metadata_proxy_set = set()