def initialize_all():
    ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
    ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
    # At this stage we have a fully populated resource attribute map;
    # build Pecan controllers and routes for every resource (both core
    # and extensions)
    pecanized_exts = [ext for ext in ext_mgr.extensions.values() if
                      hasattr(ext, 'get_pecan_controllers')]
    non_pecanized_exts = set(ext_mgr.extensions.values()) - set(pecanized_exts)
    pecan_controllers = {}
    for ext in pecanized_exts:
        LOG.info(_LI("Extension %s is pecan-aware. Fetching resources "
                     "and controllers"), ext.get_name())
        controllers = ext.get_pecan_controllers()
        # controllers is actually a list of pairs where the first element is
        # the collection name and the second the actual controller
        for (collection, coll_controller) in controllers:
            pecan_controllers[collection] = coll_controller

    for collection in attributes.RESOURCE_ATTRIBUTE_MAP:
        resource = _handle_plurals(collection)

        plugin = _plugin_for_resource(collection)
        if plugin:
            manager.NeutronManager.set_plugin_for_resource(
                resource, plugin)
        else:
            LOG.warning(_LW("No plugin found for resource:%s. API calls "
                            "may not be correctly dispatched"), resource)

        controller = pecan_controllers.get(collection)
        if not controller:
            LOG.debug("Building controller for resource:%s", resource)
            controller = res_ctrl.CollectionsController(collection, resource)
        else:
            LOG.debug("There are already controllers for resource: %s",
                      resource)

        manager.NeutronManager.set_controller_for_resource(
            controller.collection, controller)
        LOG.info(_LI("Added controller for resource %(resource)s "
                     "via URI path segment:%(collection)s"),
                 {'resource': resource,
                  'collection': collection})

    initialize_legacy_extensions(non_pecanized_exts)

    # NOTE(salv-orlando): If you are care about code quality, please read below
    # Hackiness is strong with the piece of code below. It is used for
    # populating resource plurals and registering resources with the quota
    # engine, but the method it calls were not conceived with this aim.
    # Therefore it only leverages side-effects from those methods. Moreover,
    # as it is really not advisable to load an instance of
    # neutron.api.v2.router.APIRouter just to register resources with the
    # quota  engine, core resources are explicitly registered here.
    # TODO(salv-orlando): The Pecan WSGI support should provide its own
    # solution to manage resource plurals and registration of resources with
    # the quota engine
    for resource in router.RESOURCES.keys():
        resource_registry.register_resource_by_name(resource)
    for ext in ext_mgr.extensions.values():
        # make each extension populate its plurals
        if hasattr(ext, 'get_resources'):
            ext.get_resources()
        if hasattr(ext, 'get_extended_resources'):
            ext.get_extended_resources('v2.0')
    # Certain policy checks require that the extensions are loaded
    # and the RESOURCE_ATTRIBUTE_MAP populated before they can be
    # properly initialized. This can only be claimed with certainty
    # once this point in the code has been reached. In the event
    # that the policies have been initialized before this point,
    # calling reset will cause the next policy check to
    # re-initialize with all of the required data in place.
    policy.reset()
dataset/ETHPy150Open openstack/neutron/neutron/pecan_wsgi/startup.py/initialize_all/original