本文整理汇总了Python中neutron.i18n._LW函数的典型用法代码示例。如果您正苦于以下问题:Python _LW函数的具体用法?Python _LW怎么用?Python _LW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_LW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sync_ports
def _sync_ports(self, ctx):
LOG.debug("OVN-NB Sync ports started")
lports = self.ovn_api.get_all_logical_ports_ids()
for port in self.core_plugin.get_ports(ctx):
try:
if self.mode == SYNC_MODE_REPAIR:
self.core_plugin.create_port_in_ovn(port)
res = lports.pop(port['id'], None)
if self.mode == SYNC_MODE_LOG:
if res is None:
LOG.warn(_LW("Port found in Neutron but not in OVN"
"DB, port_id=%s"),
port['id'])
except RuntimeError:
LOG.warn(_LW("Create port failed for"
" port %s"), port['id'])
# Only delete logical port if it was previously created by neutron
with self.ovn_api.transaction() as txn:
for lport, ext_ids in lports.items():
if ovn_const.OVN_PORT_NAME_EXT_ID_KEY in ext_ids:
if self.mode == SYNC_MODE_REPAIR:
txn.add(self.ovn_api.delete_lport(lport))
if self.mode == SYNC_MODE_LOG:
LOG.warn(_LW("Port found in OVN but not in Neutron,"
" port_name=%s"),
ext_ids[ovn_const.OVN_PORT_NAME_EXT_ID_KEY])
LOG.debug("OVN-NB Sync ports finished")
示例2: _execute
def _execute(cls, *args):
"""Run received command and return the output."""
command = [CONF.virtualbox.vboxmanage_cmd, "--nologo"]
command.extend(args)
LOG.debug("Execute: %s", command)
stdout, stderr = None, None
for _ in range(CONF.virtualbox.retry_count):
try:
process = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True)
except subprocess.CalledProcessError as exc:
stderr = exc.output
else:
stdout, stderr = process.communicate()
if stderr and constants.VBOX_E_ACCESSDENIED in stderr:
LOG.warning(_LW("Something went wrong, trying again."))
time.sleep(CONF.virtualbox.retry_interval)
continue
break
else:
LOG.warning(_LW("Failed to process command."))
return (stdout, stderr)
示例3: get_ml2_port_bond_data
def get_ml2_port_bond_data(self, ctx, port_id, device_id):
core_plugin = manager.NeutronManager.get_plugin()
port_context = core_plugin.get_bound_port_context(
ctx, port_id, device_id)
if not port_context:
LOG.warning(_LW("Device %(device)s requested by agent "
"%(agent_id)s not found in database"),
{'device': device_id, 'agent_id': port_id})
return None
port = port_context.current
try:
segment = port_context.network.network_segments[0]
except KeyError:
if not segment:
LOG.warning(_LW("Device %(device)s requested by agent "
" on network %(network_id)s not "
"bound, vif_type: "),
{'device': device_id,
'network_id': port['network_id']})
return {}
entry = {'device': device_id,
'network_id': port['network_id'],
'port_id': port_id,
'mac_address': port['mac_address'],
'admin_state_up': port['admin_state_up'],
'network_type': segment[api.NETWORK_TYPE],
'segmentation_id': segment[api.SEGMENTATION_ID],
'physical_network': segment[api.PHYSICAL_NETWORK],
'fixed_ips': port['fixed_ips'],
'device_owner': port['device_owner']}
LOG.debug(("Returning: %s"), entry)
return entry
示例4: call_driver
def call_driver(self, action, network, **action_kwargs):
"""Invoke an action on a DHCP driver instance."""
LOG.debug('Calling driver for network: %(net)s action: %(action)s',
{'net': network.id, 'action': action})
try:
# the Driver expects something that is duck typed similar to
# the base models.
driver = self.dhcp_driver_cls(self.conf,
network,
self._process_monitor,
self.dhcp_version,
self.plugin_rpc)
getattr(driver, action)(**action_kwargs)
return True
except exceptions.Conflict:
# No need to resync here, the agent will receive the event related
# to a status update for the network
LOG.warning(_LW('Unable to %(action)s dhcp for %(net_id)s: there '
'is a conflict with its current state; please '
'check that the network and/or its subnet(s) '
'still exist.'),
{'net_id': network.id, 'action': action})
except Exception as e:
self.schedule_resync(e, network.id)
if (isinstance(e, oslo_messaging.RemoteError)
and e.exc_type == 'NetworkNotFound'
or isinstance(e, exceptions.NetworkNotFound)):
LOG.warning(_LW("Network %s has been deleted."), network.id)
else:
LOG.exception(_LE('Unable to %(action)s dhcp for %(net_id)s.'),
{'net_id': network.id, 'action': action})
示例5: _router_removed
def _router_removed(self, router_id, deconfigure=True):
"""Operations when a router is removed.
Get the RouterInfo object corresponding to the router in the service
helpers's router_info dict. If deconfigure is set to True,
remove this router's configuration from the hosting device.
:param router_id: id of the router
:param deconfigure: if True, the router's configuration is deleted from
the hosting device.
:return: None
"""
ri = self.router_info.get(router_id)
if ri is None:
LOG.warning(_LW("Info for router %s was not found. "
"Skipping router removal"), router_id)
return
ri.router['gw_port'] = None
ri.router[l3_constants.INTERFACE_KEY] = []
ri.router[l3_constants.FLOATINGIP_KEY] = []
try:
if deconfigure:
self._process_router(ri)
driver = self._drivermgr.get_driver(router_id)
driver.router_removed(ri, deconfigure)
self._drivermgr.remove_driver(router_id)
del self.router_info[router_id]
self.removed_routers.discard(router_id)
except cfg_exceptions.DriverException:
LOG.warning(_LW("Router remove for router_id: %s was incomplete. "
"Adding the router to removed_routers list"), router_id)
self.removed_routers.add(router_id)
# remove this router from updated_routers if it is there. It might
# end up there too if exception was thrown earlier inside
# `_process_router()`
self.updated_routers.discard(router_id)
示例6: _get_candidates
def _get_candidates(self, plugin, context, sync_router):
"""Return L3 agents where a router could be scheduled."""
with context.session.begin(subtransactions=True):
# allow one router is hosted by just
# one enabled l3 agent hosting since active is just a
# timing problem. Non-active l3 agent can return to
# active any time
current_l3_agents = plugin.get_l3_agents_hosting_routers(
context, [sync_router['id']], admin_state_up=True)
is_router_distributed = sync_router.get('distributed', False)
if current_l3_agents and not is_router_distributed:
LOG.debug('Router %(router_id)s has already been hosted'
' by L3 agent %(agent_id)s',
{'router_id': sync_router['id'],
'agent_id': current_l3_agents[0]['id']})
return []
active_l3_agents = plugin.get_l3_agents(context, active=True)
if not active_l3_agents:
LOG.warn(_LW('No active L3 agents'))
return []
potential_candidates = list(
set(active_l3_agents) - set(current_l3_agents))
new_l3agents = []
if potential_candidates:
new_l3agents = plugin.get_l3_agent_candidates(
context, sync_router, potential_candidates)
if not new_l3agents:
LOG.warn(_LW('No L3 agents can host the router %s'),
sync_router['id'])
return new_l3agents
示例7: _sync_networks
def _sync_networks(self, ctx):
LOG.debug("OVN-NB Sync networks started")
lswitches = self.ovn_api.get_all_logical_switches_ids()
for network in self.core_plugin.get_networks(ctx):
net_context = driver_context.NetworkContext(self.core_plugin, ctx, network)
try:
if self.mode == SYNC_MODE_REPAIR:
self.driver.create_network_postcommit(net_context)
res = lswitches.pop(utils.ovn_name(net_context.current["id"]), None)
if self.mode == SYNC_MODE_LOG:
if res is None:
LOG.warn(
_LW("Network found in Neutron but not in OVN" "DB, network_id=%s"),
net_context.current["id"],
)
except RuntimeError:
LOG.warn(_LW("Create network postcommit failed for " "network %s"), network["id"])
# Only delete logical switch if it was previously created by neutron
with self.ovn_api.transaction() as txn:
for lswitch, ext_ids in lswitches.items():
if ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY in ext_ids:
if self.mode == SYNC_MODE_REPAIR:
txn.add(self.ovn_api.delete_lswitch(lswitch))
if self.mode == SYNC_MODE_LOG:
LOG.warn(
_LW("Network found in OVN but not in Neutron," " network_name=%s"),
(ext_ids[ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY]),
)
LOG.debug("OVN-NB Sync networks finished")
示例8: _sync_base
def _sync_base(self):
ctx = context.get_admin_context()
# Sync Networks
for network in self.core_plugin.get_networks(ctx):
mech_context = driver_context.NetworkContext(self.core_plugin, ctx,
network)
try:
self.driver.create_network_postcommit(mech_context)
except Exception:
LOG.warn(_LW("Create network postcommit failed for "
"network %s"), network['id'])
# Sync Subnets
for subnet in self.core_plugin.get_subnets(ctx):
mech_context = driver_context.SubnetContext(self.core_plugin, ctx,
subnet)
try:
self.driver.create_subnet_postcommit(mech_context)
except Exception:
LOG.warn(_LW("Create subnet postcommit failed for"
" subnet %s"), subnet['id'])
# Sync Ports (compute/gateway/dhcp)
for port in self.core_plugin.get_ports(ctx):
_, binding = l2_db.get_locked_port_and_binding(ctx.session,
port['id'])
network = self.core_plugin.get_network(ctx, port['network_id'])
mech_context = driver_context.PortContext(self.core_plugin, ctx,
port, network, binding,
[])
try:
self.driver.create_port_postcommit(mech_context)
except Exception:
LOG.warn(_LW("Create port postcommit failed for"
" port %s"), port['id'])
示例9: get_nsx_security_group_id
def get_nsx_security_group_id(session, cluster, neutron_id):
"""Return the NSX sec profile uuid for a given neutron sec group.
First, look up the Neutron database. If not found, execute
a query on NSX platform as the mapping might be missing.
NOTE: Security groups are called 'security profiles' on the NSX backend.
"""
nsx_id = nsx_db.get_nsx_security_group_id(session, neutron_id)
if not nsx_id:
# Find security profile on backend.
# This is a rather expensive query, but it won't be executed
# more than once for each security group in Neutron's lifetime
nsx_sec_profiles = secgrouplib.query_security_profiles(
cluster, '*',
filters={'tag': neutron_id,
'tag_scope': 'q_sec_group_id'})
# Only one result expected
# NOTE(salv-orlando): Not handling the case where more than one
# security profile is found with the same neutron port tag
if not nsx_sec_profiles:
LOG.warn(_LW("Unable to find NSX security profile for Neutron "
"security group %s"), neutron_id)
return
elif len(nsx_sec_profiles) > 1:
LOG.warn(_LW("Multiple NSX security profiles found for Neutron "
"security group %s"), neutron_id)
nsx_sec_profile = nsx_sec_profiles[0]
nsx_id = nsx_sec_profile['uuid']
with session.begin(subtransactions=True):
# Create DB mapping
nsx_db.add_neutron_nsx_security_group_mapping(
session, neutron_id, nsx_id)
return nsx_id
示例10: treat_device
def treat_device(self, device, pci_slot, admin_state_up, spoofcheck=True):
if self.eswitch_mgr.device_exists(device, pci_slot):
try:
self.eswitch_mgr.set_device_spoofcheck(device, pci_slot,
spoofcheck)
except Exception:
LOG.warning(_LW("Failed to set spoofcheck for device %s"),
device)
LOG.info(_LI("Device %(device)s spoofcheck %(spoofcheck)s"),
{"device": device, "spoofcheck": spoofcheck})
try:
self.eswitch_mgr.set_device_state(device, pci_slot,
admin_state_up)
except exc.IpCommandOperationNotSupportedError:
LOG.warning(_LW("Device %s does not support state change"),
device)
except exc.SriovNicError:
LOG.warning(_LW("Failed to set device %s state"), device)
return
if admin_state_up:
# update plugin about port status
self.plugin_rpc.update_device_up(self.context,
device,
self.agent_id,
cfg.CONF.host)
else:
self.plugin_rpc.update_device_down(self.context,
device,
self.agent_id,
cfg.CONF.host)
else:
LOG.info(_LI("No device with MAC %s defined on agent."), device)
示例11: _get_portpair_detail_info
def _get_portpair_detail_info(self, portpair_id):
"""Get port detail.
@param: portpair_id: uuid
@return: (host_id, local_ip, network_type, segment_id,
service_insert_type): tuple
"""
core_plugin = manager.NeutronManager.get_plugin()
port_detail = core_plugin.get_port(self.admin_context, portpair_id)
host_id, local_ip, network_type, segment_id, mac_address = (
(None, ) * 5)
if port_detail:
host_id = port_detail['binding:host_id']
network_id = port_detail['network_id']
mac_address = port_detail['mac_address']
network_info = core_plugin.get_network(
self.admin_context, network_id)
network_type = network_info['provider:network_type']
segment_id = network_info['provider:segmentation_id']
if network_type != np_const.TYPE_VXLAN:
LOG.warn(_LW("Currently only support vxlan network"))
return ((None, ) * 5)
elif not host_id:
LOG.warn(_LW("This port has not been binding"))
return ((None, ) * 5)
else:
driver = core_plugin.type_manager.drivers.get(network_type)
host_endpoint = driver.obj.get_endpoint_by_host(host_id)
local_ip = host_endpoint['ip_address']
return host_id, local_ip, network_type, segment_id, mac_address
示例12: _inspect_instance
def _inspect_instance(self, instance_name):
"""Get the network information from an instance."""
network = {}
try:
instace_info = self._vbox.show_vm_info(instance_name)
except exception.InstanceNotFound:
LOG.warning(_LW("Failed to get specification for `%(instance)s`"),
{"instance": instance_name})
return
description = instace_info.get(constants.VM_DESCRIPTION)
if not self._process_description(description):
LOG.warning(_LW("Invalid description for `%(instance)s`: "
"%(description)s"),
{"instance": instance_name,
"description": description})
return
for field, value in instace_info.items():
if field[:-1] in constants.NETWORK_FIELDS:
network.setdefault(field[-1], {})[field[:-1]] = value
for nic_index in network:
mac_address = network[nic_index].get(constants.MAC_ADDRESS)
device_id = self._device_map.get(mac_address)
nic_mode = network[nic_index].get(constants.NIC_MODE)
if device_id and nic_mode != constants.NIC_MODE_NONE:
self._nic[device_id] = network[nic_index]
self._nic[device_id]["index"] = nic_index
self._nic[device_id]["instance"] = instance_name
self._nic[device_id]["state"] = instace_info.get(
constants.VM_STATE)
示例13: _load_all_extensions_from_path
def _load_all_extensions_from_path(self, path):
# Sorting the extension list makes the order in which they
# are loaded predictable across a cluster of load-balanced
# Neutron Servers
for f in sorted(os.listdir(path)):
try:
LOG.debug('Loading extension file: %s', f)
mod_name, file_ext = os.path.splitext(os.path.split(f)[-1])
ext_path = os.path.join(path, f)
if file_ext.lower() == '.py' and not mod_name.startswith('_'):
mod = imp.load_source(mod_name, ext_path)
ext_name = mod_name[0].upper() + mod_name[1:]
new_ext_class = getattr(mod, ext_name, None)
if not new_ext_class:
LOG.warn(_LW('Did not find expected name '
'"%(ext_name)s" in %(file)s'),
{'ext_name': ext_name,
'file': ext_path})
continue
new_ext = new_ext_class()
self.add_extension(new_ext)
except Exception as exception:
LOG.warn(_LW("Extension file %(f)s wasn't loaded due to "
"%(exception)s"),
{'f': f, 'exception': exception})
示例14: update_status
def update_status(self, context, obj_type, obj_id,
provisioning_status=None, operating_status=None):
if not provisioning_status and not operating_status:
LOG.warning(_LW('update_status for %(obj_type)s %(obj_id)s called '
'without specifying provisioning_status or '
'operating_status') % {'obj_type': obj_type,
'obj_id': obj_id})
return
model_mapping = {
'loadbalancer': db_models.LoadBalancer,
'pool': db_models.PoolV2,
'listener': db_models.Listener,
'member': db_models.MemberV2,
'healthmonitor': db_models.HealthMonitorV2
}
if obj_type not in model_mapping:
raise n_exc.Invalid(_('Unknown object type: %s') % obj_type)
try:
self.plugin.db.update_status(
context, model_mapping[obj_type], obj_id,
provisioning_status=provisioning_status,
operating_status=operating_status)
except n_exc.NotFound:
# update_status may come from agent on an object which was
# already deleted from db with other request
LOG.warning(_LW('Cannot update status: %(obj_type)s %(obj_id)s '
'not found in the DB, it was probably deleted '
'concurrently'),
{'obj_type': obj_type, 'obj_id': obj_id})
示例15: _get_port_infos
def _get_port_infos(self, context, port, agent_host):
if not agent_host:
return
session = db_api.get_session()
agent = self.get_agent_by_host(session, agent_host)
if not agent:
return
agent_ip = self.get_agent_ip(agent)
if not agent_ip:
LOG.warning(_LW("Unable to retrieve the agent ip, check the agent "
"configuration."))
return
segment = context.bottom_bound_segment
if not segment:
LOG.warning(_LW("Port %(port)s updated by agent %(agent)s "
"isn't bound to any segment"),
{'port': port['id'], 'agent': agent})
return
network_types = self.get_agent_l2pop_network_types(agent)
if network_types is None:
network_types = self.get_agent_tunnel_types(agent)
if segment['network_type'] not in network_types:
return
fdb_entries = self._get_port_fdb_entries(port)
return agent, agent_host, agent_ip, segment, fdb_entries