本文整理汇总了Python中neutron_lib.callbacks.registry.publish函数的典型用法代码示例。如果您正苦于以下问题:Python publish函数的具体用法?Python publish怎么用?Python publish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了publish函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delete_segment
def delete_segment(self, context, uuid, for_net_delete=False):
"""Delete an existing segment."""
segment_dict = self.get_segment(context, uuid)
# Do some preliminary operations before deleting the segment
registry.publish(resources.SEGMENT, events.BEFORE_DELETE,
self.delete_segment,
payload=events.DBEventPayload(
context, metadata={
'for_net_delete': for_net_delete},
states=(segment_dict,),
resource_id=uuid))
# Delete segment in DB
with db_api.CONTEXT_WRITER.using(context):
if not network.NetworkSegment.delete_objects(context, id=uuid):
raise exceptions.SegmentNotFound(segment_id=uuid)
# Do some preliminary operations before deleting segment in db
registry.notify(resources.SEGMENT, events.PRECOMMIT_DELETE,
self.delete_segment, context=context,
segment=segment_dict)
registry.publish(resources.SEGMENT, events.AFTER_DELETE,
self.delete_segment,
payload=events.DBEventPayload(
context, states=(segment_dict,),
resource_id=uuid))
开发者ID:igordcard,项目名称:neutron,代码行数:26,代码来源:db.py
示例2: test_create_default_l2_gateway
def test_create_default_l2_gateway(self):
def_bep_name = NSX_DEFAULT_BEP_NAME
cfg.CONF.set_override("default_bridge_endpoint_profile",
def_bep_name, "nsx_v3")
with mock.patch.object(nsx_v3_driver.NsxV3Driver,
'_get_bridge_vlan_tz_id',
return_value=['some_tz_id']) as mock_get_tz:
nsx_v3_driver.NsxV3Driver(mock.MagicMock())
def_bep_id = (
self.nsxlib.bridge_endpoint_profile.get_id_by_name_or_id(
def_bep_name))
# fake the callback invoked after init
registry.publish(resources.PROCESS, events.BEFORE_SPAWN,
mock.MagicMock())
l2gws = self.driver._get_l2_gateways(self.context)
def_l2gw = None
for l2gw in l2gws:
for device in l2gw['devices']:
if device['device_name'] == def_bep_id:
def_l2gw = l2gw
self.assertIsNotNone(def_l2gw)
self.assertTrue(def_l2gw.devices[0].device_name, def_bep_id)
self.assertTrue(def_l2gw.devices[0].interfaces[0].interface_name,
'some_tz_id')
mock_get_tz.assert_called_once_with({'id': def_bep_id,
'edge_cluster_id': 'meh'})
开发者ID:openstack,项目名称:vmware-nsx,代码行数:26,代码来源:test_nsxv3_driver.py
示例3: _update_segment_host_mapping_for_agent
def _update_segment_host_mapping_for_agent(resource, event, trigger,
payload=None):
plugin = payload.metadata.get('plugin')
agent = payload.desired_state
host = payload.metadata.get('host')
context = payload.context
check_segment_for_agent = getattr(plugin, 'check_segment_for_agent', None)
if (not check_user_configured_segment_plugin() or
not check_segment_for_agent):
return
phys_nets = _get_phys_nets(agent)
if not phys_nets:
return
start_flag = agent.get('start_flag', None)
if host in reported_hosts and not start_flag:
return
reported_hosts.add(host)
segments = get_segments_with_phys_nets(context, phys_nets)
current_segment_ids = {
segment['id'] for segment in segments
if check_segment_for_agent(segment, agent)}
update_segment_host_mapping(context, host, current_segment_ids)
registry.publish(resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE,
plugin, payload=events.DBEventPayload(
context,
metadata={
'host': host,
'current_segment_ids': current_segment_ids}))
开发者ID:openstack,项目名称:neutron,代码行数:29,代码来源:db.py
示例4: __init__
def __init__(self):
self._drivers = set()
self.rpc_required = False
registry.publish(log_const.LOGGING_PLUGIN, events.AFTER_INIT, self)
if self.rpc_required:
self._start_rpc_listeners()
self.logging_rpc = server_rpc.LoggingApiNotification()
开发者ID:igordcard,项目名称:neutron,代码行数:8,代码来源:manager.py
示例5: _ensure_vr_id
def _ensure_vr_id(self, context, router_db, ha_network):
router_id = router_db.id
network_id = ha_network.network_id
# TODO(kevinbenton): let decorator handle duplicate retry
# like in review.openstack.org/#/c/367179/1/neutron/db/l3_hamode_db.py
for count in range(MAX_ALLOCATION_TRIES):
try:
# NOTE(kevinbenton): we disallow subtransactions because the
# retry logic will bust any parent transactions
with context.session.begin():
if router_db.extra_attributes.ha_vr_id:
LOG.debug(
"Router %(router_id)s has already been "
"allocated a ha_vr_id %(ha_vr_id)d!",
{'router_id': router_id,
'ha_vr_id': router_db.extra_attributes.ha_vr_id})
return
old_router = self._make_router_dict(router_db)
allocated_vr_ids = self._get_allocated_vr_id(context,
network_id)
available_vr_ids = VR_ID_RANGE - allocated_vr_ids
if not available_vr_ids:
raise l3ha_exc.NoVRIDAvailable(router_id=router_id)
allocation = l3_hamode.L3HARouterVRIdAllocation(
context, network_id=network_id,
vr_id=available_vr_ids.pop())
allocation.create()
router_db.extra_attributes.ha_vr_id = allocation.vr_id
LOG.debug(
"Router %(router_id)s has been allocated a ha_vr_id "
"%(ha_vr_id)d.",
{'router_id': router_id, 'ha_vr_id': allocation.vr_id})
router_body = {l3_apidef.ROUTER:
{l3_ext_ha_apidef.HA_INFO: True,
'ha_vr_id': allocation.vr_id}}
registry.publish(resources.ROUTER, events.PRECOMMIT_UPDATE,
self, payload=events.DBEventPayload(
context, request_body=router_body,
states=(old_router,),
resource_id=router_id,
desired_state=router_db))
return allocation.vr_id
except obj_base.NeutronDbObjectDuplicateEntry:
LOG.info("Attempt %(count)s to allocate a VRID in the "
"network %(network)s for the router %(router)s",
{'count': count, 'network': network_id,
'router': router_id})
raise l3ha_exc.MaxVRIDAllocationTriesReached(
network_id=network_id, router_id=router_id,
max_tries=MAX_ALLOCATION_TRIES)
开发者ID:cubeek,项目名称:neutron,代码行数:58,代码来源:l3_hamode_db.py
示例6: delete_firewall_rule
def delete_firewall_rule(self, context, id):
firewall_rule = self.firewall_db.get_firewall_rule(context, id)
self.delete_firewall_rule_precommit(context, firewall_rule)
self.firewall_db.delete_firewall_rule(context, id)
self.delete_firewall_rule_postcommit(context, firewall_rule)
payload = events.DBEventPayload(context=context,
resource_id=id,
states=(firewall_rule,))
registry.publish(
const.FIREWALL_RULE, events.AFTER_DELETE, self, payload=payload)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:11,代码来源:driver_api.py
示例7: _set_bridge_name
def _set_bridge_name(port, vif_details):
# REVISIT(rawlin): add BridgeName as a nullable column to the Port
# model and simply check here if it's set and insert it into the
# vif_details.
def set_bridge_name_inner(bridge_name):
vif_details[portbindings.VIF_DETAILS_BRIDGE_NAME] = bridge_name
registry.publish(a_const.OVS_BRIDGE_NAME, events.BEFORE_READ,
set_bridge_name_inner, payload=events.EventPayload(
None, metadata={'port': port}))
开发者ID:cubeek,项目名称:neutron,代码行数:11,代码来源:mech_openvswitch.py
示例8: __init__
def __init__(self):
self._drivers = []
self.rpc_notifications_required = False
rpc_registry.provide(self._get_qos_policy_cb, resources.QOS_POLICY)
# notify any registered QoS driver that we're ready, those will
# call the driver manager back with register_driver if they
# are enabled
registry.publish(qos_consts.QOS_PLUGIN, events.AFTER_INIT, self)
if self.rpc_notifications_required:
self.push_api = resources_rpc.ResourcesPushRpcApi()
开发者ID:openstack,项目名称:neutron,代码行数:11,代码来源:manager.py
示例9: delete_firewall_policy
def delete_firewall_policy(self, context, id):
firewall_policy = self.firewall_db.get_firewall_policy(context, id)
self.delete_firewall_policy_precommit(context, firewall_policy)
self.firewall_db.delete_firewall_policy(context, id)
self.delete_firewall_policy_postcommit(context, firewall_policy)
payload = events.DBEventPayload(context=context,
resource_id=id,
states=(firewall_policy,))
registry.publish(
const.FIREWALL_POLICY, events.AFTER_UPDATE, self, payload=payload)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:11,代码来源:driver_api.py
示例10: serve_wsgi
def serve_wsgi(cls):
try:
service = cls.create()
service.start()
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception('Unrecoverable error: please check log '
'for details.')
registry.publish(resources.PROCESS, events.BEFORE_SPAWN, service)
return service
开发者ID:cubeek,项目名称:neutron,代码行数:12,代码来源:service.py
示例11: remove_rule
def remove_rule(self, context, policy_id, rule_info):
self.remove_rule_precommit(context, policy_id, rule_info)
firewall_policy = self.firewall_db.remove_rule(context, policy_id,
rule_info)
self.remove_rule_postcommit(context, policy_id, rule_info)
payload = events.DBEventPayload(context=context,
resource_id=policy_id,
states=(firewall_policy,))
registry.publish(
const.FIREWALL_POLICY, events.AFTER_UPDATE, self, payload=payload)
return firewall_policy
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:12,代码来源:driver_api.py
示例12: __init__
def __init__(self):
self._rpc_backend = None
self._drivers = []
self._segmentation_types = {}
self._interfaces = set()
self._agent_types = set()
drivers.register()
registry.subscribe(rules.enforce_port_deletion_rules,
resources.PORT, events.BEFORE_DELETE)
registry.publish(constants.TRUNK_PLUGIN, events.AFTER_INIT, self)
for driver in self._drivers:
LOG.debug('Trunk plugin loaded with driver %s', driver.name)
self.check_compatibility()
开发者ID:eayunstack,项目名称:neutron,代码行数:13,代码来源:plugin.py
示例13: after
def after(self, state):
resource_name = state.request.context.get('resource')
collection_name = state.request.context.get('collection')
neutron_context = state.request.context.get('neutron_context')
action = pecan_constants.ACTION_MAP.get(state.request.method)
if not action or action not in ('create', 'update', 'delete'):
return
if utils.is_member_action(utils.get_controller(state)):
return
if not resource_name:
LOG.debug("Skipping NotifierHook processing as there was no "
"resource associated with the request")
return
if state.response.status_int > 300:
LOG.debug("No notification will be sent due to unsuccessful "
"status code: %s", state.response.status_int)
return
original = {}
if (action in ('delete', 'update') and
state.request.context.get('original_resources', [])):
# We only need the original resource for updates and deletes
original = state.request.context.get('original_resources')[0]
if action == 'delete':
# The object has been deleted, so we must notify the agent with the
# data of the original object as the payload, but we do not need
# to pass it in as the original
result = {resource_name: original}
original = {}
else:
if not state.response.body:
result = {}
else:
result = state.response.json
notifier_method = '%s.%s.end' % (resource_name, action)
notifier_action = utils.get_controller(state).plugin_handlers[action]
registry.publish(resource_name, events.BEFORE_RESPONSE, self,
payload=events.APIEventPayload(
neutron_context, notifier_method, notifier_action,
request_body=state.request.body,
states=(original, result,),
collection_name=collection_name))
if action == 'delete':
resource_id = state.request.context.get('resource_id')
result[resource_name + '_id'] = resource_id
self._notifier.info(neutron_context, notifier_method, result)
开发者ID:cubeek,项目名称:neutron,代码行数:49,代码来源:notifier.py
示例14: delete_firewall_group
def delete_firewall_group(self, context, id):
firewall_group = self.firewall_db.get_firewall_group(context, id)
if firewall_group['status'] == nl_constants.PENDING_DELETE:
firewall_group['status'] = nl_constants.ERROR
self.delete_firewall_group_precommit(context, firewall_group)
if firewall_group['status'] != nl_constants.PENDING_DELETE:
# lets driver deleting firewall group later
self.firewall_db.delete_firewall_group(context, id)
self.delete_firewall_group_postcommit(context, firewall_group)
payload = events.DBEventPayload(context=context,
resource_id=id,
states=(firewall_group,))
registry.publish(
const.FIREWALL_GROUP, events.AFTER_DELETE, self, payload=payload)
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:15,代码来源:driver_api.py
示例15: test_create_duplicate_default_l2_gateway_noop
def test_create_duplicate_default_l2_gateway_noop(self):
def_bep_name = NSX_DEFAULT_BEP_NAME
cfg.CONF.set_override("default_bridge_endpoint_profile",
def_bep_name, "nsx_v3")
with mock.patch.object(nsx_v3_driver.NsxV3Driver,
'_get_bridge_vlan_tz_id',
return_value=['some_tz_id']):
for i in range(0, 2):
nsx_v3_driver.NsxV3Driver(mock.MagicMock())
# fake the callback invoked after init
registry.publish(resources.PROCESS, events.BEFORE_SPAWN,
mock.MagicMock())
l2gws = self.driver._get_l2_gateways(self.context)
# Verify whether only one default L2 gateway is created
self.assertEqual(1, len(l2gws))
开发者ID:openstack,项目名称:vmware-nsx,代码行数:15,代码来源:test_nsxv3_driver.py
示例16: _registry_notify
def _registry_notify(self, res, event, id=None, exc_cls=None, **kwargs):
# NOTE(armax): a callback exception here will prevent the request
# from being processed. This is a hook point for backend's validation;
# we raise to propagate the reason for the failure.
try:
if 'payload' in kwargs:
# TODO(boden): remove shim once all callbacks use payloads
registry.publish(res, event, self, payload=kwargs['payload'])
else:
registry.notify(res, event, self, **kwargs)
except exceptions.CallbackFailure as e:
if exc_cls:
reason = (_('cannot perform %(event)s due to %(reason)s') %
{'event': event, 'reason': e})
raise exc_cls(reason=reason, id=id)
开发者ID:openstack,项目名称:neutron,代码行数:15,代码来源:securitygroups_db.py
示例17: create_firewall_rule
def create_firewall_rule(self, context, firewall_rule):
request_body = firewall_rule
with context.session.begin(subtransactions=True):
firewall_rule = self.firewall_db.create_firewall_rule(
context, firewall_rule)
self.create_firewall_rule_precommit(context, firewall_rule)
self.create_firewall_rule_postcommit(context, firewall_rule)
payload = events.DBEventPayload(context=context,
resource_id=firewall_rule['id'],
request_body=request_body,
states=(firewall_rule,))
registry.publish(
const.FIREWALL_RULE, events.AFTER_CREATE, self, payload=payload)
return firewall_rule
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:15,代码来源:driver_api.py
示例18: _router_removed
def _router_removed(self, ri, router_id):
if ri is None:
LOG.warning("Info for router %s was not found. "
"Performing router cleanup", router_id)
self.namespaces_manager.ensure_router_cleanup(router_id)
return
registry.publish(resources.ROUTER, events.BEFORE_DELETE, self,
payload=events.DBEventPayload(
self.context, states=(ri,),
resource_id=router_id))
ri.delete()
del self.router_info[router_id]
registry.notify(resources.ROUTER, events.AFTER_DELETE, self, router=ri)
开发者ID:igordcard,项目名称:neutron,代码行数:16,代码来源:agent.py
示例19: update_rbac_policy
def update_rbac_policy(self, context, id, rbac_policy):
pol = rbac_policy['rbac_policy']
entry = self._get_rbac_policy(context, id)
object_type = entry.db_model.object_type
try:
registry.publish(resources.RBAC_POLICY, events.BEFORE_UPDATE, self,
payload=events.DBEventPayload(
context, request_body=pol,
states=(entry,), resource_id=id,
metadata={'object_type': object_type}))
except c_exc.CallbackFailure as ex:
raise ext_rbac.RbacPolicyInUse(object_id=entry.object_id,
details=ex)
entry.update_fields(pol)
entry.update()
return self._make_rbac_policy_dict(entry)
开发者ID:openstack,项目名称:neutron,代码行数:16,代码来源:rbac_db_mixin.py
示例20: create_firewall_group
def create_firewall_group(self, context, firewall_group):
request_body = firewall_group
with context.session.begin(subtransactions=True):
firewall_group = self.firewall_db.create_firewall_group(
context, firewall_group)
self.create_firewall_group_precommit(context, firewall_group)
self._update_resource_status(context, firewall_db_v2.FirewallGroup,
firewall_group)
self.create_firewall_group_postcommit(context, firewall_group)
payload = events.DBEventPayload(context=context,
resource_id=firewall_group['id'],
request_body=request_body,
states=(firewall_group,))
registry.publish(
const.FIREWALL_GROUP, events.AFTER_CREATE, self, payload=payload)
return firewall_group
开发者ID:openstack,项目名称:neutron-fwaas,代码行数:17,代码来源:driver_api.py
注:本文中的neutron_lib.callbacks.registry.publish函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论