- 在 /etc/neutron/neutron.conf 中我们可以看到这个配置选项:
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
正说明 neutron-server 加载了 router 这个 service plugin
class L3RouterPlugin(service_base.ServicePluginBase,
common_db_mixin.CommonDbMixin,
extraroute_db.ExtraRoute_db_mixin,
l3_hamode_db.L3_HA_NAT_db_mixin,
l3_gwmode_db.L3_NAT_db_mixin,
l3_dvr_ha_scheduler_db.L3_DVR_HA_scheduler_db_mixin,
dns_db.DNSDbMixin)
supported_extension_aliases = ["dvr", "router", "ext-gw-mode",
"extraroute", "l3_agent_scheduler",
"l3-ha", "router_availability_zone",
"l3-flavors"]
__native_pagination_support = True
__native_sorting_support = True
@resource_registry.tracked_resources(router=l3_db.Router,
floatingip=l3_db.FloatingIP)
def __init__(self):
self.router_scheduler = importutils.import_object(
cfg.CONF.router_scheduler_driver)
self.add_periodic_l3_agent_status_check()
super(L3RouterPlugin, self).__init__()
if 'dvr' in self.supported_extension_aliases:
l3_dvrscheduler_db.subscribe()
if 'l3-ha' in self.supported_extension_aliases:
l3_hascheduler_db.subscribe()
self.agent_notifiers.update(
{n_const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotifyAPI()})
rpc_worker = service.RpcWorker([self], worker_process_count=0)
self.add_worker(rpc_worker)
self.l3_driver_controller = driver_controller.DriverController(self)
router_scheduler_driver
: 默认为:neutron.scheduler.l3_agent_scheduler.LeastRoutersScheduler
- 调用
add_periodic_l3_agent_status_check
(在L3AgentSchedulerDbMixin
中定义) - 调用父类的
__init__
方法 - 若 router 支持
dvr
,则调用系统的回调方法(l3_dvrscheduler_db.subscribe
)来订阅如下资源事件: - resource :
PORT
;event :AFTER_UPDATE
;callback :_notify_l3_agent_port_update
- resource :
PORT
;event :AFTER_CREATE
;callback :_notify_l3_agent_new_port
- resource :
PORT
;event :AFTER_DELETE
;callback :_notify_port_delete
- 若 router 支持
l3-ha
,则调用系统的回调方法(l3_hascheduler_db.subscribe
)来订阅如下资源事件: - resource :
PORT
;event :AFTER_UPDATE
;callback :_notify_l3_agent_ha_port_update
- 增加一个
agent_notifiers
:L3AgentNotifyAPI
- 创建一个
RpcWorker
实例,并调用add_worker
将其加入到工作队列中 - 创建
DriverController
的实例
返回 router service plugin 的类型 L3_ROUTER_NAT
返回 router service plugin 的描述
创建一个 RPC Server
判断一个 router 是否支持调度
调用 L3_NAT_db_mixin.create_floatingip
实现