Python neutron_lib.callbacks.events.BEFORE_DELETE Examples
The following are 6
code examples of neutron_lib.callbacks.events.BEFORE_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: vpn_db.py From neutron-vpnaas with Apache License 2.0 | 6 votes |
def subscribe(): registry.subscribe( vpn_router_gateway_callback, resources.ROUTER_GATEWAY, events.BEFORE_DELETE) registry.subscribe( vpn_router_gateway_callback, resources.ROUTER_INTERFACE, events.BEFORE_DELETE) registry.subscribe( migration_callback, resources.ROUTER, events.BEFORE_UPDATE) registry.subscribe( subnet_callback, resources.SUBNET, events.BEFORE_DELETE) # NOTE(armax): multiple VPN service plugins (potentially out of tree) may # inherit from vpn_db and may need the callbacks to be processed. Having an # implicit subscription (through the module import) preserves the existing # behavior, and at the same time it avoids fixing it manually in each and # every vpn plugin outta there. That said, The subscription is also made # explicitly in the reference vpn plugin. The subscription operation is # idempotent so there is no harm in registering the same callback multiple # times.
Example #2
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 #3
Source File: test_manager.py From neutron-lib with Apache License 2.0 | 6 votes |
def test_unsubscribe_by_resource(self): self.manager.subscribe( callback_1, resources.PORT, events.BEFORE_CREATE) self.manager.subscribe( callback_1, resources.PORT, events.BEFORE_DELETE) self.manager.subscribe( callback_2, resources.PORT, events.BEFORE_DELETE) self.manager.unsubscribe_by_resource(callback_1, resources.PORT) self.assertEqual( 0, len(self.manager._callbacks [resources.PORT][events.BEFORE_CREATE])) self.assertEqual( 1, len(self.manager._callbacks[resources.PORT][events.BEFORE_DELETE])) self.assertIn( callback_id_2, self.manager._callbacks [resources.PORT][events.BEFORE_DELETE][0][1]) self.assertNotIn(callback_id_1, self.manager._index)
Example #4
Source File: l3_db_midonet.py From networking-midonet with Apache License 2.0 | 5 votes |
def _check_router_not_in_use(self, context, router_id): try: registry.publish( resources.ROUTER, events.BEFORE_DELETE, self, payload=events.DBEventPayload(context, resource_id=router_id)) except exceptions.CallbackFailure as e: with excutils.save_and_reraise_exception(): if len(e.errors) == 1: raise e.errors[0].error raise l3_exc.RouterInUse(router_id=router_id, reason=e)
Example #5
Source File: test_manager.py From neutron-lib with Apache License 2.0 | 5 votes |
def test_unsubscribe_all(self): self.manager.subscribe( callback_1, resources.PORT, events.BEFORE_CREATE) self.manager.subscribe( callback_1, resources.PORT, events.BEFORE_DELETE) self.manager.subscribe( callback_1, resources.ROUTER, events.BEFORE_CREATE) self.manager.unsubscribe_all(callback_1) self.assertNotIn( callback_id_1, self.manager._callbacks[resources.PORT][events.BEFORE_CREATE]) self.assertNotIn(callback_id_1, self.manager._index)
Example #6
Source File: test_manager.py From neutron-lib with Apache License 2.0 | 5 votes |
def test__notify_loop_multiple_events(self): self.manager.subscribe( callback_1, resources.PORT, events.BEFORE_CREATE) self.manager.subscribe( callback_1, resources.ROUTER, events.BEFORE_DELETE) self.manager.subscribe( callback_2, resources.PORT, events.BEFORE_CREATE) self.manager._notify_loop( resources.PORT, events.BEFORE_CREATE, mock.ANY) self.manager._notify_loop( resources.ROUTER, events.BEFORE_DELETE, mock.ANY) self.assertEqual(2, callback_1.counter) self.assertEqual(1, callback_2.counter)