Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Cloud:OpenStack:Newton:Staging
openstack-neutron
0001-Notify-l2pop-driver-from-update-device-up-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Notify-l2pop-driver-from-update-device-up-down.patch of Package openstack-neutron
diff -crB --new-file neutron-9.4.2.dev21-backup/neutron/plugins/ml2/rpc.py neutron-9.4.2.dev21/neutron/plugins/ml2/rpc.py *** neutron-9.4.2.dev21-backup/neutron/plugins/ml2/rpc.py 2019-03-25 15:47:39.042789284 -0700 --- neutron-9.4.2.dev21/neutron/plugins/ml2/rpc.py 2019-03-25 15:59:37.124307465 -0700 *************** *** 229,236 **** "executed concurrently. Ignoring StaleDataError.") return {'device': device, 'exists': port_exists} ! self.notify_ha_port_status(port_id, rpc_context, ! n_const.PORT_STATUS_DOWN, host) return {'device': device, 'exists': port_exists} --- 229,236 ---- "executed concurrently. Ignoring StaleDataError.") return {'device': device, 'exists': port_exists} ! self.notify_l2pop_port_wiring(port_id, rpc_context, ! n_const.PORT_STATUS_DOWN, host) return {'device': device, 'exists': port_exists} *************** *** 264,271 **** return else: self.update_port_status_to_active(port, rpc_context, port_id, host) ! self.notify_ha_port_status(port_id, rpc_context, ! n_const.PORT_STATUS_ACTIVE, host, port=port) def update_port_status_to_active(self, port, rpc_context, port_id, host): plugin = manager.NeutronManager.get_plugin() --- 264,271 ---- return else: self.update_port_status_to_active(port, rpc_context, port_id, host) ! self.notify_l2pop_port_wiring(port_id, rpc_context, ! n_const.PORT_STATUS_ACTIVE, host) def update_port_status_to_active(self, port, rpc_context, port_id, host): plugin = manager.NeutronManager.get_plugin() *************** *** 288,315 **** rpc_context, port['id'], resources.PORT, provisioning_blocks.L2_AGENT_ENTITY) ! def notify_ha_port_status(self, port_id, rpc_context, ! status, host, port=None): plugin = manager.NeutronManager.get_plugin() l2pop_driver = plugin.mechanism_manager.mech_drivers.get( 'l2population') if not l2pop_driver: return ! if not port: ! port = ml2_db.get_port(rpc_context.session, port_id) ! if not port: return ! is_ha_port = l3_hamode_db.is_ha_router_port(port['device_owner'], ! port['device_id']) ! if is_ha_port: ! port_context = plugin.get_bound_port_context( ! rpc_context, port_id) ! port_context.current['status'] = status ! port_context.current[portbindings.HOST_ID] = host ! if status == n_const.PORT_STATUS_ACTIVE: ! l2pop_driver.obj.update_port_up(port_context) ! else: ! l2pop_driver.obj.update_port_down(port_context) def update_device_list(self, rpc_context, **kwargs): devices_up = [] --- 288,326 ---- rpc_context, port['id'], resources.PORT, provisioning_blocks.L2_AGENT_ENTITY) ! def notify_l2pop_port_wiring(self, port_id, rpc_context, ! status, host): ! """Notify the L2pop driver that a port has been wired/unwired. ! ! The L2pop driver uses this notification to broadcast forwarding ! entries to other agents on the same network as the port for port_id. ! """ plugin = manager.NeutronManager.get_plugin() l2pop_driver = plugin.mechanism_manager.mech_drivers.get( 'l2population') if not l2pop_driver: return ! port_context = plugin.get_bound_port_context( ! rpc_context, port_id) ! if not port_context: ! # port deleted ! return ! port = port_context.current ! if (status == n_const.PORT_STATUS_ACTIVE and ! port[portbindings.HOST_ID] != host and ! not l3_hamode_db.is_ha_router_port(rpc_context, ! port['device_owner'], ! port['device_id'])): ! # don't setup ACTIVE forwarding entries unless bound to this ! # host or if it's an HA port (which is special-cased in the ! # mech driver) return ! port_context.current['status'] = status ! port_context.current[portbindings.HOST_ID] = host ! if status == n_const.PORT_STATUS_ACTIVE: ! l2pop_driver.obj.update_port_up(port_context) ! else: ! l2pop_driver.obj.update_port_down(port_context) def update_device_list(self, rpc_context, **kwargs): devices_up = [] diff -crB --new-file neutron-9.4.2.dev21-backup/neutron/tests/unit/plugins/ml2/test_rpc.py neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/test_rpc.py *** neutron-9.4.2.dev21-backup/neutron/tests/unit/plugins/ml2/test_rpc.py 2019-03-25 15:30:35.788059194 -0700 --- neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/test_rpc.py 2019-03-25 16:02:52.088091037 -0700 *************** *** 60,66 **** } with mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin' '._device_to_port_id'),\ ! mock.patch.object(self.callbacks, 'notify_ha_port_status'): with mock.patch('neutron.db.provisioning_blocks.' 'provisioning_complete') as pc: self.callbacks.update_device_up(mock.Mock(), **kwargs) --- 60,66 ---- } with mock.patch('neutron.plugins.ml2.plugin.Ml2Plugin' '._device_to_port_id'),\ ! mock.patch.object(self.callbacks, 'notify_l2pop_port_wiring'): with mock.patch('neutron.db.provisioning_blocks.' 'provisioning_complete') as pc: self.callbacks.update_device_up(mock.Mock(), **kwargs) *************** *** 213,219 **** def _test_update_device_not_bound_to_host(self, func): self.plugin.port_bound_to_host.return_value = False ! self.callbacks.notify_ha_port_status = mock.Mock() self.plugin._device_to_port_id.return_value = 'fake_port_id' res = func(mock.Mock(), device='fake_device', host='fake_host') self.plugin.port_bound_to_host.assert_called_once_with(mock.ANY, --- 213,219 ---- def _test_update_device_not_bound_to_host(self, func): self.plugin.port_bound_to_host.return_value = False ! self.callbacks.notify_l2pop_port_wiring = mock.Mock() self.plugin._device_to_port_id.return_value = 'fake_port_id' res = func(mock.Mock(), device='fake_device', host='fake_host') self.plugin.port_bound_to_host.assert_called_once_with(mock.ANY, *************** *** 236,242 **** def test_update_device_down_call_update_port_status(self): self.plugin.update_port_status.return_value = False ! self.callbacks.notify_ha_port_status = mock.Mock() self.plugin._device_to_port_id.return_value = 'fake_port_id' self.assertEqual( {'device': 'fake_device', 'exists': False}, --- 236,242 ---- def test_update_device_down_call_update_port_status(self): self.plugin.update_port_status.return_value = False ! self.callbacks.notify_l2pop_port_wiring = mock.Mock() self.plugin._device_to_port_id.return_value = 'fake_port_id' self.assertEqual( {'device': 'fake_device', 'exists': False},
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor