本文整理汇总了Python中neutron_lib.callbacks.events.AFTER_DELETE属性的典型用法代码示例。如果您正苦于以下问题:Python events.AFTER_DELETE属性的具体用法?Python events.AFTER_DELETE怎么用?Python events.AFTER_DELETE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类neutron_lib.callbacks.events
的用法示例。
在下文中一共展示了events.AFTER_DELETE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例2: router_gateway_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例3: test__register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例4: _register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例5: subscribe_registries
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_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)
示例6: test_decorated_inst_method_receives
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例7: router_interface_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例8: l2gw_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例9: subscribe
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
def subscribe():
interested_events = (events.AFTER_UPDATE,
events.AFTER_DELETE)
for x in interested_events:
registry.subscribe(
l2gw_callback, resources.PORT, x)
示例10: test_l2gw_callback_delete_port
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例11: trunk_subports_set_status
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例12: register
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例13: test_trunk_subports_set_status_delete
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)
示例14: test_callback_postcommit_sg_delete
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
def test_callback_postcommit_sg_delete(self):
self._test_callback_postcommit_for_sg(
events.AFTER_DELETE, odl_const.ODL_DELETE, None, FAKE_ID)
示例15: test_callback_postcommit_sg_rules_delete
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_DELETE [as 别名]
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)