1. Code Flow Analysis
Neutron/plugins/openvswitch/agent/ovs_neutron_agent.py:main () plugin = ovsneutronagent (**agent_config) self. SETUP_INTEGRATION_BR () #创建br-int Integrated bridge and initialize the Flow table Self.setup_rpc () #建立一些agent与server侧常用的rpc通道 Self.plugin_rpc = Ovspluginapi (Topics. PLUGIN) #如get_device_details/update_device_down/update_device_up/tunnel_sync
Self.sg_plugin_rpc = Sg_rpc. Securitygroupserverrpcapi (Topics. PLUGIN) #查询安全组信息 Self.state_rpc = Agent_rpc. Pluginreportstateapi (Topics. PLUGIN) #处理report_state self.connection = Agent_rpc.create_consumers (...)
#创建以下消费者们: Port Update/delete, tunnel update/delete, security_group Update, DVR update, l2population update host Hea Rtbeat = Loopingcall. Fixedintervalloopingcall (self._report_state) #周期任务上报agent状态, such as how many device,agent current time on Br-int Self.setup_physical_ Bridges (Bridge_mappings)
#处理物理网桥与br-int Association (with Veth pair/path), exit the agent directly if the physical bridge does not exist, and initialize the Flow table Self.setup_tunnel_br ()/SELF.RESET_TUNNEL_BR (TUN_BR)
#创建br-tun, associating with br-int (with patch pairs), and initializing the flow table
#为啥要分开处理? Self.setup_ancillary_bridges (Integ_br, TUN_BR) # identifies bridges on this host other than Br-int, Br-tun, and physical bridges, such as br-ex self.sg_agent = Ovssecur Itygroupagent (...) # for working with security groups
Self.connection.consume_in_threads () # on the above consume turn on each thread to listen and process Plugin.daemon_loop () self.rpc_loop () Tu Nnel_sync () #在agent首次启动或有异常发生时, tunnel synchronization is performed.
#上报本agent的tunnel IP to Neutron server DB, neutron server sends a message about the tunnel IP (tunnel_update) to other agents
#如果没有开启l2pop, tunnel port will be created on Br-tun on this agent, and the other agents will create the corresponding remote tunnel port and create the corresponding flow table
Port_info = Self.scan_ports () #周期检测br port changes on the-int
Sync = self.process_network_ports (port_info) #处理增加或删除的port
The message queues for Neutron-server and Neutron-openvswitch-agent are as follows:
Neutron-server may occur in several of the above messages broadcast to Neutron-openvswitch-agent. The Openvswitch agent will first see if the port is local, and if it is local, the corresponding action is performed.
2. Nova's interaction with Neutron-openvswitch-agent
First boot virtual machine, Nova-compute send a message to Neutron-server request to create port. Then, after establishing the port on the br-int in the driver, the Neutron-openvswitch-port Loop detection Br-int will find the new port, set the appropriate OpenFlow rules and Localvlan, Finally, the port status is set to active.
Attached: OvS start Flowchart (http://bingotree.cn/wp-content/uploads/2015/05/ovs-agent%E5%90%AF%E5%8A%A8%E6%B5%81%E7%A8%8B1.png)
Http://www.cnblogs.com/xingyun/p/5024400.html
Ovs-agent process