Neutron中的Service类

Service是OpenStack中非常重要的一个概念,各个服务的组件都以Service类的方式来进行交互。


Neutron中的Service类继承自rpc中的Service,总体的继承关系为

neutron.openstack.common.service.Service-->neutron.common.rpc.Service-->neutron.service.Service类。


当中neutron.openstack.common.service.Service类定义了简单的reset()start()stop()wait()方法。该类初始化后会维护一个线程组。


neutron.common.rpc.Service类中进一步丰富了start()stop()方法,并在初始化中引入了hosttopicmanagerserializer參数。

start()添加�创建了Connection对象,之后创建了三个consumer,分别监听主题为參数传入的topicfanout分别为TrueFalse),以及主题为topic.host。然后调用manager的初始化。最后作为server启动全部的consumer


neutron.service.Service类的初始化中更进一步的添加�了binaryreport_intervalperiodic_intervalperiodic_fuzzy_delay等參数。除丰富了start()stop()wait()方法外,还添加�了create()类方法、kill()periodic_tasks()report_state()

start()添加�了周期性运行report_state()periodic_tasks(),而且调用managerinit_host()after_start()方法。

create()方法是类方法,它依据传入的參数binary參数获取真实的程序名,并在未给定參数的情况下尝试从配置文件里解析managerreport_intervalperiodic_intervalperiodic_fuzzy_delay等參数。最后是返回生成的Service类对象。

report_state()方法仅定义了接口。

periodic_tasks()则首先获取admin的上下文,然后调用managerperiodic_tasks()方法运行。


很多其它详细内容请參考https://github.com/yeasy/tech_writing/blob/master/OpenStack/OpenStack%20Neutron%E4%BB%A3%E7%A0%81%E5%88%86%E6%9E%90.pdf

posted @ 2014-07-26 14:40  yxwkaifa  阅读(367)  评论(0编辑  收藏  举报