1 | [composite:osapi_compute] |
1) #create wsgi service
1 | server = service.WSGIService('osapi_compute') ---> |
2)# load WSGI applications from paste configurations
1 | wsgi.Loader() |
3) # urlmap_factory,
1 | for path, app_name in local_conf.items(): |
4) #pipeline_factory
1 | app = loader.get_app(pipeline[-1]) --> |
这里的重要之处在于,通过app = filter(app) 将后面的filter app作为前面的middleware的构造初始化,从而形成整个call stack,比如
1 | keystone = faultwrap sizelimit authtoken keystonecontext ratelimit osapi_compute_app_v2 |
这样ratelimit middleware的就会call osapi_compute_app_v2,
所以 3) 返回了第一个middleware的urlmap,从而 WSGI server可以在接收到/v2/***
进入middleware的 call stack ,最终根据APIRouter的url和controller的映射配置,进行API 的request的具体处理。
5) #APIRouter
1 | class APIRouter(nova.api.openstack.APIRouter): |
6) self._setup_routes(mapper, ext_mgr)
1 | for openstack core api, setup necessary routes |
7) self._setup_ext_routes(mapper, ext_mgr)
1 | for each resource in ext_mgr.get_resources() |
8) self._setup_extensions(ext_mgr)
1 | for each extension in returned ControllerExtension objects |
9) manage a WSGI server, serving a WSGI application —>
1 | self.server = wsgi.Server(name, |