| |--> rpcapi --> manager --> driver
SERVERS
2. nova/api/openstack/compute/servers.py:
2.1 进入NewController中create函数处理,其中
此类NewController继承于servers.Controller,servers被定义成nova.api.openstack.compute
2.2 调用父类Controller中create函数处理
3. nova/api/openstack/compute/servers.py:
3.1 进入Controller 中 create函数处理,其中:
self.compute_api = compute.API()
3.2 调用函数self.compute_api.create
API
4. nova/compute/api.py:
4.1 进入API中create函数处理, 其中:
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
scheduler_rpcapi被定义成nova.scheduler.rpcapi
4.2 进一步调用函数_create_instance
4.3 最终调用函数self.scheduler_rpcapi.run_instance
SCHEDULER
5. nova/scheduler/rpcapi.py:
5.1 进入SchedulerAPI中run_instance函数处理,其中
SchedulerAPI继承自nova.openstack.common.rpc.proxy.RpcProxy
5.2 调用函数cast(nova/openstack/common/rpc/proxy.py)
6. nova/scheduler/manager.py(配置文件中定义的scheduler_manager):
此类SchedulerManager继承于SchedulerManager
7. nova/scheduler/manager.py:
7.1 进入SchedulerManager中run_instance函数处理,其中
scheduler_driver = FLAGS.scheduler_driver
self.driver = importutils.import_object(scheduler_driver)
7.2 调用函数self.driver.schedule_run_instance
8. nova/scheduler/multi.py(配置文件中定义的scheduler_driver):
此类MultiScheduler继承于MultiScheduler
9. nova/scheduler/multi.py:
进入MultiScheduler中schedule_run_instance函数处理,其中
self.drivers = {'compute': compute_driver,
... }
compute_driver = FLAGS.compute_scheduler_driver
而volume_scheduler_driver配置文件定义成nova.scheduler.zone_filter_scheduler.ZoneFilterScheduler
10. nova/scheduler/zone_filter_scheduler.py:
10.1 进入ZoneFilterScheduler中,其继承scheduler.FilterScheduler
进入nova/scheduler/filter_scheduler.py中FilterScheduler,其又继承dirvier.Scheduler
进入nova/scheduler/driver.py中Scheduler, 得到
self.compute_api = compute_api.API(),[from nova.compute import api as compute_api]
self.compute_rpcapi = compute_rpcapi.ComputeAPI() [from nova.compute import rpcapi as compute_rpcapi]
10.2 调用schedule_run_instance函数处理
* 调用_schedule计算各种权值,主要是内存、cpu、磁盘大小等。
* 调用_provision_resource函数处理,进一步调用compute_rpcapi.run_instance函数处理,其中:
从10.1中可以知道,compute_api定义为nova.compute.rpcapi
COMPUTE
11. nova/compute/rpcapi.py:
11.1 进入ComputeAPI中run_instance函数处理,其中:
ComputeAPI继承于nova.openstack.common.rpc.proxy.RpcProxy
11.2 调用函数cast(nova/openstack/common/rpc/proxy.py)
12. nova/compute/manager.py(配置文件中定义的compute_manager):
12.1 此类ComputeManager继承于ComputeManager类
12.2 先调用nova/compute/manager.py中函数run_instance
12.3 再调用nova/compute/manager.py中函数_run_instance
13. nova/compute/manager.py:
调用函数self.driver.spawn函数处理,其中
compute_driver = FLAGS.compute_driver
self.driver = nova.virt.*.compute_driver
在配置文件中compute_driver配置成libvirt.driver.LibvirtDriver
14. nova/virt/libvirt/driver.py:
14.1 其继承于ComputeDriver:定义在nova/virt/driver.py
14.2 生成xml,调用函数to_xml
14.3 创建image,调用函数_create_image
14.4 创建domain和网络,调用函数_create_domain_and_network
14.5 等待启动,最终调用eventlet.spawn