From 7d704db18ec7635328bfce7dc6e936151f264f1f Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 16 Jun 2015 23:16:24 -0700 Subject: [PATCH] Refactor rpc_loop() in ovs neutron agent This patch segregates the port_info recieved by scan_ports and scan_ancillary_ports. This refactoring is basically required for this patch set: https://review.openstack.org/#/c/165023/ Co-Authored-By: Romil Gupta Change-Id: I9b43c230cda9d2659ad0e806bebe8a3dc12826ec Partial-Bug: #1329223 --- .../openvswitch/agent/ovs_neutron_agent.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 0e2b7eb24..e3c240cfe 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -1531,6 +1531,16 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, "Elapsed:%(elapsed).3f", {'iter_num': self.iter_num, 'elapsed': time.time() - start}) + + # Treat ancillary devices if they exist + if self.ancillary_brs: + ancillary_port_info = self.scan_ancillary_ports( + ancillary_ports) + LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - " + "ancillary port info retrieved. " + "Elapsed:%(elapsed).3f", + {'iter_num': self.iter_num, + 'elapsed': time.time() - start}) # Secure and wire/unwire VIFs and update their status # on Neutron server if (self._port_info_has_changes(port_info) or @@ -1552,29 +1562,20 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, port_stats['regular']['removed'] = ( len(port_info.get('removed', []))) ports = port_info['current'] - # Treat ancillary devices if they exist - if self.ancillary_brs: - port_info = self.scan_ancillary_ports( - ancillary_ports) - LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - " - "ancillary port info retrieved. " - "Elapsed:%(elapsed).3f", - {'iter_num': self.iter_num, - 'elapsed': time.time() - start}) - rc = self.process_ancillary_network_ports( - port_info) + if self.ancillary_brs: + sync |= self.process_ancillary_network_ports( + ancillary_port_info) LOG.debug("Agent rpc_loop - iteration: " "%(iter_num)d - ancillary ports " "processed. Elapsed:%(elapsed).3f", {'iter_num': self.iter_num, 'elapsed': time.time() - start}) - ancillary_ports = port_info['current'] + ancillary_ports = ancillary_port_info['current'] port_stats['ancillary']['added'] = ( - len(port_info.get('added', []))) + len(ancillary_port_info.get('added', []))) port_stats['ancillary']['removed'] = ( - len(port_info.get('removed', []))) - sync = sync | rc + len(ancillary_port_info.get('removed', []))) polling_manager.polling_completed() # Keep this flag in the last line of "try" block, -- 2.45.2