本文整理汇总了Python中neutron_lib.callbacks.events.AFTER_UPDATE属性的典型用法代码示例。如果您正苦于以下问题:Python events.AFTER_UPDATE属性的具体用法?Python events.AFTER_UPDATE怎么用?Python events.AFTER_UPDATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类neutron_lib.callbacks.events
的用法示例。
在下文中一共展示了events.AFTER_UPDATE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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: test__register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)
示例3: test_trunk_subports_update_status_parent_down_to_active
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def test_trunk_subports_update_status_parent_down_to_active(
self, mock_set_subport_status, mock_get_subports_ids):
resource = resources.PORT
event_type = events.AFTER_UPDATE
core_plugin = directory.get_plugin()
port = FAKE_PARENT.copy()
original_port = FAKE_PARENT.copy()
original_port['status'] = n_const.PORT_STATUS_DOWN
port_kwargs = {'port': port, 'original_port': original_port}
mock_get_subports_ids.return_value = ['fake_port_id']
self.handler.trunk_subports_update_status(resource, event_type,
mock.ANY, **port_kwargs)
mock_set_subport_status.assert_called_once_with(
core_plugin, mock.ANY, 'fake_port_id', n_const.PORT_STATUS_ACTIVE)
示例4: test_trunk_subports_update_status_parent_active_to_down
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def test_trunk_subports_update_status_parent_active_to_down(
self, mock_set_subport_status, mock_get_subports_ids):
resource = resources.PORT
event_type = events.AFTER_UPDATE
core_plugin = directory.get_plugin()
port = FAKE_PARENT.copy()
original_port = FAKE_PARENT.copy()
port['status'] = n_const.PORT_STATUS_DOWN
port_kwargs = {'port': port, 'original_port': original_port}
mock_get_subports_ids.return_value = ['fake_port_id']
self.handler.trunk_subports_update_status(resource, event_type,
mock.ANY, **port_kwargs)
mock_set_subport_status.assert_called_once_with(
core_plugin, mock.ANY, 'fake_port_id', n_const.PORT_STATUS_DOWN)
示例5: _subscribe
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def _subscribe(self):
if self._precommit is not None:
for event in (events.PRECOMMIT_CREATE, events.PRECOMMIT_DELETE):
registry.subscribe(self.sg_callback_precommit,
resources.SECURITY_GROUP, event)
registry.subscribe(self.sg_callback_precommit,
resources.SECURITY_GROUP_RULE, event)
registry.subscribe(
self.sg_callback_precommit, resources.SECURITY_GROUP,
events.PRECOMMIT_UPDATE)
for event in (events.AFTER_CREATE, events.AFTER_DELETE):
registry.subscribe(self.sg_callback_postcommit,
resources.SECURITY_GROUP, event)
registry.subscribe(self.sg_callback_postcommit,
resources.SECURITY_GROUP_RULE, event)
registry.subscribe(self.sg_callback_postcommit,
resources.SECURITY_GROUP, events.AFTER_UPDATE)
示例6: _register_callbacks
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)
示例7: subscribe_registries
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)
示例8: update_security_group
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def update_security_group(self, resource, event, trigger, **kwargs):
sg = kwargs['security_group']
sg_name = sg.get('name')
rules = sg.get('security_group_rules', [])
for rule in rules:
try:
rule['topic'] = rule.pop('project_id')
except KeyError:
rule['topic'] = rule.pop('tenant_id', None)
sg_obj = neutron_secgroups.security_group_from_neutron_obj(sg)
if event == events.AFTER_CREATE:
self.nb_api.create(sg_obj)
LOG.info("DFMechDriver: create security group %s", sg_name)
elif event == events.AFTER_UPDATE:
self.nb_api.update(sg_obj)
LOG.info("DFMechDriver: update security group %s", sg_name)
return sg_obj
示例9: test_decorated_inst_method_receives
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)
示例10: floatingip_update_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def floatingip_update_callback(self, resource, event, trigger, **kwargs):
if event != events.AFTER_UPDATE:
return
ctx = context.get_admin_context()
new_router_id = kwargs['router_id']
last_router_id = kwargs.get('last_known_router_id')
floating_ip_address = kwargs['floating_ip_address']
dest = floating_ip_address + '/32'
bgp_speakers = self._bgp_speakers_for_gw_network_by_family(
ctx,
kwargs['floating_network_id'],
n_const.IP_VERSION_4)
if last_router_id and new_router_id != last_router_id:
# Here gives the old route next_hop a `None` value, then
# the DR agent side will withdraw it.
old_host_route = {'destination': dest, 'next_hop': None}
for bgp_speaker in bgp_speakers:
self.stop_route_advertisements(ctx, self._bgp_rpc,
bgp_speaker.id,
[old_host_route])
if new_router_id and new_router_id != last_router_id:
next_hop = self._get_fip_next_hop(
ctx, new_router_id, floating_ip_address)
new_host_route = {'destination': dest, 'next_hop': next_hop}
for bgp_speaker in bgp_speakers:
self.start_route_advertisements(ctx, self._bgp_rpc,
bgp_speaker.id,
[new_host_route])
示例11: port_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def port_callback(self, resource, event, trigger, **kwargs):
if event != events.AFTER_UPDATE:
return
original_port = kwargs['original_port']
updated_port = kwargs['port']
if not updated_port.get('fixed_ips'):
return
original_host = original_port.get(portbindings.HOST_ID)
updated_host = updated_port.get(portbindings.HOST_ID)
device_owner = updated_port.get('device_owner')
# if host in the port binding has changed, update next-hops
if original_host != updated_host and bool('compute:' in device_owner):
ctx = context.get_admin_context()
with ctx.session.begin(subtransactions=True):
ext_nets = self.get_external_networks_for_port(ctx,
updated_port)
for ext_net in ext_nets:
bgp_speakers = (
self._get_bgp_speaker_ids_by_binding_network(
ctx, ext_nets))
# Refresh any affected BGP speakers
for bgp_speaker in bgp_speakers:
routes = self.get_advertised_routes(ctx, bgp_speaker)
self.start_route_advertisements(ctx, self._bgp_rpc,
bgp_speaker, routes)
示例12: l2gw_callback
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)
示例13: subscribe
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def subscribe():
interested_events = (events.AFTER_UPDATE,
events.AFTER_DELETE)
for x in interested_events:
registry.subscribe(
l2gw_callback, resources.PORT, x)
示例14: test_l2gw_callback_update_port
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [as 别名]
def test_l2gw_callback_update_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_UPDATE,
mock.Mock(),
**fake_kwargs)
self.assertTrue(service_plugin.add_port_mac.called)
示例15: register
# 需要导入模块: from neutron_lib.callbacks import events [as 别名]
# 或者: from neutron_lib.callbacks.events import AFTER_UPDATE [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)