From 29dffc084164c29b4726dc08bb986f7961e9fa9f Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Fri, 15 Jan 2016 15:22:03 +0000 Subject: [PATCH] Revert "Change function call order in ovs_neutron_agent." This reverts commit 9c72bac0ea37971b2d5430246295c5e8b859b4ed. Change-Id: I9b6b588b68f63f6688749d011dc8b20ef80edadc Closes-Bug: #1534322 --- .../openvswitch/agent/ovs_neutron_agent.py | 4 +-- .../agent/test_ovs_neutron_agent.py | 31 ------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 230fbb20d..4ff2d2367 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -1509,9 +1509,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, "from server"), self.iter_num) resync_a = True - # Ports are bound before calling the sg_agent setup. This function - # fulfill the information needed by the sg_agent setup. - self._bind_devices(need_binding_devices) # TODO(salv-orlando): Optimize avoiding applying filters # unnecessarily, (eg: when there are no IP address changes) added_ports = port_info.get('added', set()) @@ -1519,6 +1516,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, added_ports -= set(security_disabled_ports) self.sg_agent.setup_port_filters(added_ports, port_info.get('updated', set())) + self._bind_devices(need_binding_devices) if 'removed' in port_info and port_info['removed']: start = time.time() diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 322e4b921..7838be8a8 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -425,7 +425,6 @@ class TestOvsNeutronAgent(object): devices_up = ['tap1'] devices_down = ['tap2'] self.agent.local_vlan_map["net1"] = mock.Mock() - self.agent.local_vlan_map["net1"].vlan = "1" ovs_db_list = [{'name': 'tap1', 'tag': []}, {'name': 'tap2', 'tag': []}] vif_port1 = mock.Mock() @@ -452,10 +451,6 @@ class TestOvsNeutronAgent(object): update_devices.assert_called_once_with(mock.ANY, devices_up, devices_down, mock.ANY, mock.ANY) - set_db_attribute_calls = \ - [mock.call.set_db_attribute("Port", "tap1", "tag", "1"), - mock.call.set_db_attribute("Port", "tap2", "tag", "1")] - int_br.assert_has_calls(set_db_attribute_calls, any_order=True) def _test_arp_spoofing(self, enable_prevent_arp_spoofing): self.agent.prevent_arp_spoofing = enable_prevent_arp_spoofing @@ -706,32 +701,6 @@ class TestOvsNeutronAgent(object): setup_port_filters.assert_called_once_with( set(), port_info.get('updated', set())) - def test_process_network_ports_call_order(self): - port_info = {'current': set(['tap0', 'tap1']), - 'updated': set(['tap1']), - 'removed': set([]), - 'added': set(['eth1'])} - with mock.patch.object(self.agent, "treat_devices_added_or_updated", - return_value=([], ['tap1'], ['eth1'])) \ - as treat_devices_added_or_updated, \ - mock.patch.object(self.agent, "_bind_devices") \ - as _bind_devices, \ - mock.patch.object(self.agent.sg_agent, "setup_port_filters") \ - as setup_port_filters: - parent = mock.MagicMock() - parent.attach_mock(treat_devices_added_or_updated, - 'treat_devices_added_or_updated') - parent.attach_mock(_bind_devices, '_bind_devices') - parent.attach_mock(setup_port_filters, 'setup_port_filters') - self.assertFalse(self.agent.process_network_ports(port_info, - False)) - expected_calls = [ - mock.call.treat_devices_added_or_updated( - set(['tap1', 'eth1']), False), - mock.call._bind_devices(['tap1']), - mock.call.setup_port_filters(set([]), set(['tap1']))] - parent.assert_has_calls(expected_calls, any_order=False) - def test_report_state(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: -- 2.45.2