Python neutron_lib.callbacks.events.AFTER_DELETE Examples
The following are 19
code examples of neutron_lib.callbacks.events.AFTER_DELETE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
neutron_lib.callbacks.events
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: bgp_plugin.py From neutron-dynamic-routing with Apache License 2.0 | 6 votes |
def router_gateway_callback(self, resource, event, trigger, payload=None): if event == events.AFTER_CREATE: self._handle_router_gateway_after_create(payload) if event == events.AFTER_DELETE: gw_network = payload.metadata.get('network_id') router_id = payload.resource_id next_hops = self._next_hops_from_gateway_ips( payload.metadata.get('gateway_ips')) ctx = context.get_admin_context() speakers = self._bgp_speakers_for_gateway_network(ctx, gw_network) for speaker in speakers: if speaker.ip_version in next_hops: next_hop = next_hops[speaker.ip_version] prefixes = self._tenant_prefixes_by_router(ctx, router_id, speaker.id) routes = self._route_list_from_prefixes_and_next_hop( prefixes, next_hop) self._handle_router_interface_after_delete(gw_network, routes)
Example #2
Source File: test_bgp_plugin.py From neutron-dynamic-routing with Apache License 2.0 | 6 votes |
def test__register_callbacks(self): with mock.patch.object(registry, 'subscribe') as subscribe: plugin = bgp_plugin.BgpPlugin() expected_calls = [ mock.call(plugin.bgp_drscheduler.schedule_bgp_speaker_callback, dr_resources.BGP_SPEAKER, events.AFTER_CREATE), mock.call(plugin.floatingip_update_callback, resources.FLOATING_IP, events.AFTER_UPDATE), mock.call(plugin.router_interface_callback, resources.ROUTER_INTERFACE, events.AFTER_CREATE), mock.call(plugin.router_interface_callback, resources.ROUTER_INTERFACE, events.BEFORE_CREATE), mock.call(plugin.router_interface_callback, resources.ROUTER_INTERFACE, events.AFTER_DELETE), mock.call(plugin.router_gateway_callback, resources.ROUTER_GATEWAY, events.AFTER_CREATE), mock.call(plugin.router_gateway_callback, resources.ROUTER_GATEWAY, events.AFTER_DELETE), mock.call(plugin.port_callback, resources.PORT, events.AFTER_UPDATE), ] self.assertEqual(subscribe.call_args_list, expected_calls)
Example #3
Source File: test_registry.py From neutron-lib with Apache License 2.0 | 6 votes |
def test_decorated_inst_method_receives(self): i1 = ObjectWithDecoratedCallback() registry.notify(resources.PORT, events.BEFORE_CREATE, self) self.assertEqual(0, i1.counter) registry.notify(resources.PORT, events.AFTER_CREATE, self) self.assertEqual(1, i1.counter) registry.notify(resources.PORT, events.AFTER_UPDATE, self) self.assertEqual(2, i1.counter) registry.notify(resources.NETWORK, events.AFTER_UPDATE, self) self.assertEqual(2, i1.counter) registry.notify(resources.NETWORK, events.AFTER_DELETE, self) self.assertEqual(3, i1.counter) i2 = ObjectWithDecoratedCallback() self.assertEqual(0, i2.counter) registry.notify(resources.NETWORK, events.AFTER_DELETE, self) self.assertEqual(4, i1.counter) self.assertEqual(1, i2.counter)
Example #4
Source File: mech_driver.py From dragonflow with Apache License 2.0 | 6 votes |
def subscribe_registries(self): registry.subscribe(self.post_fork_initialize, resources.PROCESS, events.AFTER_INIT) registry.subscribe(self.update_security_group, resources.SECURITY_GROUP, events.AFTER_CREATE) registry.subscribe(self.update_security_group, resources.SECURITY_GROUP, events.AFTER_UPDATE) registry.subscribe(self.delete_security_group, resources.SECURITY_GROUP, events.BEFORE_DELETE) registry.subscribe(self.create_security_group_rule, resources.SECURITY_GROUP_RULE, events.AFTER_CREATE) registry.subscribe(self.delete_security_group_rule, resources.SECURITY_GROUP_RULE, events.AFTER_DELETE)
Example #5
Source File: bgp_plugin.py From dragonflow with Apache License 2.0 | 6 votes |
def _register_callbacks(self): registry.subscribe(self.floatingip_update_callback, resources.FLOATING_IP, events.AFTER_UPDATE) registry.subscribe(self.router_port_callback, resources.ROUTER_INTERFACE, events.AFTER_CREATE) registry.subscribe(self.router_port_callback, resources.ROUTER_INTERFACE, events.AFTER_DELETE) registry.subscribe(self.router_port_callback, resources.ROUTER_GATEWAY, events.AFTER_CREATE) registry.subscribe(self.router_port_callback, resources.ROUTER_GATEWAY, events.AFTER_DELETE)
Example #6
Source File: bgp_plugin.py From neutron-dynamic-routing with Apache License 2.0 | 6 votes |
def _register_callbacks(self): registry.subscribe(self.floatingip_update_callback, resources.FLOATING_IP, events.AFTER_UPDATE) registry.subscribe(self.router_interface_callback, resources.ROUTER_INTERFACE, events.AFTER_CREATE) registry.subscribe(self.router_interface_callback, resources.ROUTER_INTERFACE, events.BEFORE_CREATE) registry.subscribe(self.router_interface_callback, resources.ROUTER_INTERFACE, events.AFTER_DELETE) registry.subscribe(self.router_gateway_callback, resources.ROUTER_GATEWAY, events.AFTER_CREATE) registry.subscribe(self.router_gateway_callback, resources.ROUTER_GATEWAY, events.AFTER_DELETE) registry.subscribe(self.port_callback, resources.PORT, events.AFTER_UPDATE)
Example #7
Source File: test_trunk_driver_v2.py From networking-odl with Apache License 2.0 | 5 votes |
def test_trunk_subports_set_status_delete(self, mock_set_subport_status): resource = resources.SUBPORTS event_type = events.AFTER_DELETE fake_payload = self._fake_trunk_payload() fake_payload.subports = [models.SubPort(port_id='fake_port_id', segmentation_id=101, segmentation_type='vlan', trunk_id='fake_id')] self.handler.trunk_subports_set_status(resource, event_type, mock.ANY, fake_payload) mock_set_subport_status.assert_called_once_with( mock.ANY, mock.ANY, 'fake_port_id', n_const.PORT_STATUS_DOWN)
Example #8
Source File: test_registry.py From neutron-lib with Apache License 2.0 | 5 votes |
def test_object_inheriting_others_no_double_subscribe(self): with mock.patch.object(registry, 'subscribe') as sub: callback = AnotherObjectWithDecoratedCallback() # there are 3 methods (2 in parent and one in child) and 1 # subscribes to 2 events, so we expect 4 subscribes priority_call = [mock.call( callback.callback2, resources.NETWORK, events.AFTER_DELETE, PRI_CALLBACK)] self.assertEqual(4, len(sub.mock_calls)) sub.assert_has_calls(priority_call)
Example #9
Source File: test_manager.py From neutron-lib with Apache License 2.0 | 5 votes |
def test_publish_invalid_payload(self): self.assertRaises(exceptions.Invalid, self.manager.publish, resources.PORT, events.AFTER_DELETE, self, payload=object())
Example #10
Source File: dhcp_module.py From dragonflow with Apache License 2.0 | 5 votes |
def _register_subnet_events(self): # REVISIT(leyal): check if need to handle the events inside # neutron-db transaction function_by_action = { events.AFTER_CREATE: self._subnet_create_handler, events.AFTER_UPDATE: self._subnet_update_handler, events.AFTER_DELETE: self._subnet_delete_handler } for action, func in function_by_action.items(): registry.subscribe(func, resources.SUBNET, action)
Example #11
Source File: driver.py From dragonflow with Apache License 2.0 | 5 votes |
def _register_subport_events(self): registry.subscribe(self._add_subports_handler, resources.SUBPORTS, events.AFTER_CREATE) registry.subscribe(self._delete_subports_handler, resources.SUBPORTS, events.AFTER_DELETE) registry.subscribe(self._update_port_handler, resources.PORT, events.AFTER_UPDATE)
Example #12
Source File: test_callback.py From networking-odl with Apache License 2.0 | 5 votes |
def test_callback_postcommit_sg_rules_delete(self): self._test_callback_postcommit_for_sg_rules( events.AFTER_DELETE, odl_const.ODL_DELETE, None, FAKE_ID)
Example #13
Source File: test_callback.py From networking-odl with Apache License 2.0 | 5 votes |
def test_callback_postcommit_sg_delete(self): self._test_callback_postcommit_for_sg( events.AFTER_DELETE, odl_const.ODL_DELETE, None, FAKE_ID)
Example #14
Source File: trunk_driver_v2.py From networking-odl with Apache License 2.0 | 5 votes |
def register(self, resource, event, trigger, payload=None): super(OpenDaylightTrunkDriverV2, self).register( resource, event, trigger, payload=payload) self._handler = OpenDaylightTrunkHandlerV2() registry.subscribe(self._handler.trunk_create_precommit, resources.TRUNK, events.PRECOMMIT_CREATE) registry.subscribe(self._handler.trunk_create_postcommit, resources.TRUNK, events.AFTER_CREATE) registry.subscribe(self._handler.trunk_update_precommit, resources.TRUNK, events.PRECOMMIT_UPDATE) registry.subscribe(self._handler.trunk_update_postcommit, resources.TRUNK, events.AFTER_UPDATE) registry.subscribe(self._handler.trunk_delete_precommit, resources.TRUNK, events.PRECOMMIT_DELETE) registry.subscribe(self._handler.trunk_delete_postcommit, resources.TRUNK, events.AFTER_DELETE) for event_ in (events.PRECOMMIT_CREATE, events.PRECOMMIT_DELETE): registry.subscribe(self._handler.trunk_update_precommit, resources.SUBPORTS, event_) for event_ in (events.AFTER_CREATE, events.AFTER_DELETE): registry.subscribe(self._handler.trunk_update_postcommit, resources.SUBPORTS, event_) # Upon subport creation/deletion we need to set the right port # status: # 1. Set it to parent status when it is attached to the trunk # 2. Set it to down when is removed from the trunk registry.subscribe(self._handler.trunk_subports_set_status, resources.SUBPORTS, event_) # NOTE(ltomasbo): if the status of the parent port changes, the # subports need to update their status too registry.subscribe(self._handler.trunk_subports_update_status, resources.PORT, events.AFTER_UPDATE)
Example #15
Source File: trunk_driver_v2.py From networking-odl with Apache License 2.0 | 5 votes |
def trunk_subports_set_status(self, resource, event, trunk_plugin, payload): core_plugin = directory.get_plugin() admin_context = context.get_admin_context() if event == events.AFTER_DELETE: status = n_const.PORT_STATUS_DOWN else: parent_id = payload.current_trunk.port_id parent_port = core_plugin._get_port(admin_context, parent_id) status = parent_port['status'] for subport in payload.subports: self._set_subport_status(core_plugin, admin_context, subport.port_id, status)
Example #16
Source File: test_l2gw_db.py From networking-l2gw with Apache License 2.0 | 5 votes |
def test_l2gw_callback_delete_port(self): service_plugin = mock.Mock() directory.add_plugin(constants.L2GW, service_plugin) fake_context = mock.Mock() fake_port = mock.Mock() fake_kwargs = {'context': fake_context, 'port': fake_port} l2gateway_db.l2gw_callback(resources.PORT, events.AFTER_DELETE, mock.Mock(), **fake_kwargs) self.assertTrue(service_plugin.delete_port_mac.called)
Example #17
Source File: l2gateway_db.py From networking-l2gw with Apache License 2.0 | 5 votes |
def subscribe(): interested_events = (events.AFTER_UPDATE, events.AFTER_DELETE) for x in interested_events: registry.subscribe( l2gw_callback, resources.PORT, x)
Example #18
Source File: l2gateway_db.py From networking-l2gw with Apache License 2.0 | 5 votes |
def l2gw_callback(resource, event, trigger, **kwargs): l2gwservice = directory.get_plugin(constants.L2GW) context = kwargs.get('context') port_dict = kwargs.get('port') if l2gwservice: if event == events.AFTER_UPDATE: l2gwservice.add_port_mac(context, port_dict) elif event == events.AFTER_DELETE: l2gwservice.delete_port_mac(context, port_dict)
Example #19
Source File: bgp_plugin.py From neutron-dynamic-routing with Apache License 2.0 | 5 votes |
def router_interface_callback(self, resource, event, trigger, **kwargs): if event == events.AFTER_CREATE: self._handle_router_interface_after_create(**kwargs) if event == events.AFTER_DELETE: gw_network = kwargs['network_id'] next_hops = self._next_hops_from_gateway_ips( kwargs['gateway_ips']) ctx = context.get_admin_context() speakers = self._bgp_speakers_for_gateway_network(ctx, gw_network) for speaker in speakers: routes = self._route_list_from_prefixes_and_next_hop( kwargs['cidrs'], next_hops[speaker.ip_version]) self._handle_router_interface_after_delete(gw_network, routes)