本文整理匯總了Python中neutron_lib.callbacks.events.BEFORE_DELETE屬性的典型用法代碼示例。如果您正苦於以下問題:Python events.BEFORE_DELETE屬性的具體用法?Python events.BEFORE_DELETE怎麽用?Python events.BEFORE_DELETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類neutron_lib.callbacks.events
的用法示例。
在下文中一共展示了events.BEFORE_DELETE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: subscribe
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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.
示例2: subscribe_registries
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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)
示例3: test_unsubscribe_by_resource
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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)
示例4: _check_router_not_in_use
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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)
示例5: test_unsubscribe_all
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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)
示例6: test__notify_loop_multiple_events
# 需要導入模塊: from neutron_lib.callbacks import events [as 別名]
# 或者: from neutron_lib.callbacks.events import BEFORE_DELETE [as 別名]
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)