当前位置: 首页>>代码示例>>Python>>正文


Python _i18n._LE函数代码示例

本文整理汇总了Python中neutron._i18n._LE函数的典型用法代码示例。如果您正苦于以下问题:Python _LE函数的具体用法?Python _LE怎么用?Python _LE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_LE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unwire_subports_for_trunk

    def unwire_subports_for_trunk(self, trunk_id, subport_ids):
        """Destroy OVS ports associated to the logical subports."""
        ids = []
        for subport_id in subport_ids:
            try:
                self.trunk_manager.remove_sub_port(trunk_id, subport_id)
                ids.append(subport_id)
            except tman.TrunkManagerError as te:
                LOG.error(_LE("Removing subport %(subport_id)s from trunk "
                              "%(trunk_id)s failed: %(err)s"),
                          {'subport_id': subport_id,
                           'trunk_id': trunk_id,
                           'err': te})
        try:
            # OVS bridge and port to be determined by _update_trunk_metadata
            bridge = None
            port = None
            self._update_trunk_metadata(
                bridge, port, trunk_id, subport_ids, wire=False)
        except RuntimeError as e:
            # NOTE(status_police): Trunk bridge has stale metadata now, it
            # might cause troubles during deletion. Signal a DEGRADED status;
            # if the user undo/redo the operation things may go back to
            # normal.
            LOG.error(_LE("Failed to store metadata for trunk %(trunk_id)s: "
                          "%(reason)s"), {'trunk_id': trunk_id, 'reason': e})
            return constants.DEGRADED_STATUS
        except exceptions.ParentPortNotFound as e:
            # If a user deletes/migrates a VM and remove subports from a trunk
            # in short sequence, there is a chance that we hit this spot in
            # that the trunk may still be momentarily bound to the agent. We
            # should not mark the status as DEGRADED in this case.
            LOG.debug(e)

        return self._get_current_status(subport_ids, ids)
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:35,代码来源:ovsdb_handler.py

示例2: create_dvr_fip_interfaces

    def create_dvr_fip_interfaces(self, ex_gw_port):
        floating_ips = self.get_floating_ips()
        fip_agent_port = self.get_floating_agent_gw_interface(
            ex_gw_port['network_id'])
        if fip_agent_port:
            LOG.debug("FloatingIP agent gateway port received from the "
                "plugin: %s", fip_agent_port)
        is_first = False
        if floating_ips:
            is_first = self.fip_ns.subscribe(ex_gw_port['network_id'])
            if is_first and not fip_agent_port:
                LOG.debug("No FloatingIP agent gateway port possibly due to "
                          "late binding of the private port to the host, "
                          "requesting agent gateway port for 'network-id' :"
                          "%s", ex_gw_port['network_id'])
                fip_agent_port = self.agent.plugin_rpc.get_agent_gateway_port(
                    self.agent.context, ex_gw_port['network_id'])
                if not fip_agent_port:
                    LOG.error(_LE("No FloatingIP agent gateway port "
                                  "returned from server for 'network-id': "
                                  "%s"), ex_gw_port['network_id'])
            if fip_agent_port:
                if 'subnets' not in fip_agent_port:
                    LOG.error(_LE('Missing subnet/agent_gateway_port'))
                else:
                    if is_first:
                        self.fip_ns.create_gateway_port(fip_agent_port)
                    else:
                        self.fip_ns.update_gateway_port(fip_agent_port)

            if (self.fip_ns.agent_gateway_port and
                (self.dist_fip_count == 0)):
                self.fip_ns.create_rtr_2_fip_link(self)
开发者ID:cloudbase,项目名称:neutron,代码行数:33,代码来源:dvr_local_router.py

示例3: load_drivers

def load_drivers(service_type, plugin):
    """Loads drivers for specific service.

    Passes plugin instance to driver's constructor
    """
    service_type_manager = sdb.ServiceTypeManager.get_instance()
    providers = service_type_manager.get_service_providers(None, filters={"service_type": [service_type]})
    if not providers:
        msg = _LE("No providers specified for '%s' service, exiting") % service_type
        LOG.error(msg)
        raise SystemExit(1)

    drivers = {}
    for provider in providers:
        try:
            drivers[provider["name"]] = importutils.import_object(provider["driver"], plugin)
            LOG.debug(
                "Loaded '%(provider)s' provider for service " "%(service_type)s",
                {"provider": provider["driver"], "service_type": service_type},
            )
        except ImportError:
            with excutils.save_and_reraise_exception():
                LOG.exception(
                    _LE("Error loading provider '%(provider)s' for " "service %(service_type)s"),
                    {"provider": provider["driver"], "service_type": service_type},
                )

    default_provider = None
    try:
        provider = service_type_manager.get_default_service_provider(None, service_type)
        default_provider = provider["name"]
    except pconf.DefaultServiceProviderNotFound:
        LOG.info(_LI("Default provider is not specified for service type %s"), service_type)

    return drivers, default_provider
开发者ID:electrocucaracha,项目名称:neutron,代码行数:35,代码来源:service_base.py

示例4: _get_default_external_network

    def _get_default_external_network(self, context):
        """Get the default external network for the deployment."""
        with context.session.begin(subtransactions=True):
            default_external_networks = (
                context.session.query(ext_net_models.ExternalNetwork)
                .filter_by(is_default=sql.true())
                .join(models_v2.Network)
                .join(standard_attr.StandardAttribute)
                .order_by(standard_attr.StandardAttribute.id)
                .all()
            )

        if not default_external_networks:
            LOG.error(
                _LE(
                    "Unable to find default external network "
                    "for deployment, please create/assign one to "
                    "allow auto-allocation to work correctly."
                )
            )
            raise exceptions.AutoAllocationFailure(reason=_("No default router:external network"))
        if len(default_external_networks) > 1:
            LOG.error(
                _LE("Multiple external default networks detected. " "Network %s is true 'default'."),
                default_external_networks[0]["network_id"],
            )
        return default_external_networks[0].network_id
开发者ID:openstack,项目名称:neutron,代码行数:27,代码来源:db.py

示例5: sync_state

    def sync_state(self, networks=None):
        """Sync the local DHCP state with Neutron. If no networks are passed,
        or 'None' is one of the networks, sync all of the networks.
        """
        only_nets = set([] if (not networks or None in networks) else networks)
        LOG.info(_LI('Synchronizing state'))
        pool = eventlet.GreenPool(self.conf.num_sync_threads)
        known_network_ids = set(self.cache.get_network_ids())

        try:
            active_networks = self.plugin_rpc.get_active_networks_info()
            active_network_ids = set(network.id for network in active_networks)
            for deleted_id in known_network_ids - active_network_ids:
                try:
                    self.disable_dhcp_helper(deleted_id)
                except Exception as e:
                    self.schedule_resync(e, deleted_id)
                    LOG.exception(_LE('Unable to sync network state on '
                                      'deleted network %s'), deleted_id)

            for network in active_networks:
                if (not only_nets or  # specifically resync all
                        network.id not in known_network_ids or  # missing net
                        network.id in only_nets):  # specific network to sync
                    pool.spawn(self.safe_configure_dhcp_for_network, network)
            pool.waitall()
            LOG.info(_LI('Synchronizing state complete'))

        except Exception as e:
            if only_nets:
                for network_id in only_nets:
                    self.schedule_resync(e, network_id)
            else:
                self.schedule_resync(e)
            LOG.exception(_LE('Unable to sync network state.'))
开发者ID:punithks,项目名称:neutron,代码行数:35,代码来源:agent.py

示例6: _snat_redirect_modify

 def _snat_redirect_modify(self, gateway, sn_port, sn_int, is_add):
     """Adds or removes rules and routes for SNAT redirection."""
     try:
         ns_ipr = ip_lib.IPRule(namespace=self.ns_name)
         ns_ipd = ip_lib.IPDevice(sn_int, namespace=self.ns_name)
         if is_add:
             ns_ipwrapr = ip_lib.IPWrapper(namespace=self.ns_name)
         for port_fixed_ip in sn_port["fixed_ips"]:
             # Iterate and find the gateway IP address matching
             # the IP version
             port_ip_addr = port_fixed_ip["ip_address"]
             port_ip_vers = netaddr.IPAddress(port_ip_addr).version
             for gw_fixed_ip in gateway["fixed_ips"]:
                 gw_ip_addr = gw_fixed_ip["ip_address"]
                 if netaddr.IPAddress(gw_ip_addr).version == port_ip_vers:
                     sn_port_cidr = common_utils.ip_to_cidr(port_ip_addr, port_fixed_ip["prefixlen"])
                     snat_idx = self._get_snat_idx(sn_port_cidr)
                     if is_add:
                         ns_ipd.route.add_gateway(gw_ip_addr, table=snat_idx)
                         ns_ipr.rule.add(ip=sn_port_cidr, table=snat_idx, priority=snat_idx)
                         ns_ipwrapr.netns.execute(["sysctl", "-w", "net.ipv4.conf.%s.send_redirects=0" % sn_int])
                     else:
                         self._delete_gateway_device_if_exists(ns_ipd, gw_ip_addr, snat_idx)
                         ns_ipr.rule.delete(ip=sn_port_cidr, table=snat_idx, priority=snat_idx)
     except Exception:
         if is_add:
             exc = _LE("DVR: error adding redirection logic")
         else:
             exc = _LE("DVR: snat remove failed to clear the rule " "and device")
         LOG.exception(exc)
开发者ID:kimcharli,项目名称:neutron,代码行数:30,代码来源:dvr_local_router.py

示例7: _create_port

 def _create_port(self, port):
     switchports = port['port']['switchports']
     LOG.debug(_LE("_create_port switch: %s"), port)
     network_id = port['port']['network_id']
     db_context = neutron_context.get_admin_context()
     subnets = db.get_subnets_by_network(db_context, network_id)
     if not subnets:
         LOG.error("Subnet not found for the network")
         self._raise_ml2_error(wexc.HTTPNotFound, 'create_port')
     for switchport in switchports:
         switch_mac_id = switchport['switch_id']
         port_id = switchport['port_id']
         bnp_switch = db.get_bnp_phys_switch_by_mac(db_context,
                                                    switch_mac_id)
         # check for port and switch level existence
         if not bnp_switch:
             LOG.error(_LE("No physical switch found '%s' "), switch_mac_id)
             self._raise_ml2_error(wexc.HTTPNotFound, 'create_port')
         phys_port = db.get_bnp_phys_port(db_context,
                                          bnp_switch.id,
                                          port_id)
         if not phys_port:
             LOG.error(_LE("No physical port found for '%s' "), phys_port)
             self._raise_ml2_error(wexc.HTTPNotFound, 'create_port')
         if bnp_switch.port_prov != hp_const.SWITCH_STATUS['enable']:
             LOG.error(_LE("Physical switch is not Enabled '%s' "),
                       bnp_switch.port_prov)
             self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port')
开发者ID:Mouli-HPE,项目名称:baremetal-network-provisioning,代码行数:28,代码来源:mechanism_hpe.py

示例8: destroy_namespace

def destroy_namespace(conf, namespace, force=False):
    """Destroy a given namespace.

    If force is True, then dhcp (if it exists) will be disabled and all
    devices will be forcibly removed.
    """

    try:
        ip = ip_lib.IPWrapper(namespace=namespace)

        if force:
            kill_dhcp(conf, namespace)
            # NOTE: The dhcp driver will remove the namespace if is it empty,
            # so a second check is required here.
            if ip.netns.exists(namespace):
                try:
                    kill_listen_processes(namespace)
                except PidsInNamespaceException:
                    # This is unlikely since, at this point, we have SIGKILLed
                    # all remaining processes but if there are still some, log
                    # the error and continue with the cleanup
                    LOG.error(_LE('Not all processes were killed in %s'),
                              namespace)
                for device in ip.get_devices():
                    unplug_device(conf, device)

        ip.garbage_collect_namespace()
    except Exception:
        LOG.exception(_LE('Error unable to destroy namespace: %s'), namespace)
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:29,代码来源:netns_cleanup.py

示例9: _invoke_driver_for_sync_from_plugin

    def _invoke_driver_for_sync_from_plugin(self, ctx, router_info_list, fw):
        """Invoke the delete driver method for status of PENDING_DELETE and
        update method for all other status to (re)apply on driver which is
        Idempotent.
        """
        if fw["status"] == constants.PENDING_DELETE:
            try:
                self.fwaas_driver.delete_firewall(self.conf.agent_mode, router_info_list, fw)
                self.fwplugin_rpc.firewall_deleted(ctx, fw["id"])
            except nexception.FirewallInternalDriverError:
                LOG.error(
                    _LE("Firewall Driver Error on fw state %(fwmsg)s " "for fw: %(fwid)s"),
                    {"fwmsg": fw["status"], "fwid": fw["id"]},
                )
                self.fwplugin_rpc.set_firewall_status(ctx, fw["id"], constants.ERROR)
        else:
            # PENDING_UPDATE, PENDING_CREATE, ...
            try:
                self.fwaas_driver.update_firewall(self.conf.agent_mode, router_info_list, fw)
                if fw["admin_state_up"]:
                    status = constants.ACTIVE
                else:
                    status = constants.DOWN
            except nexception.FirewallInternalDriverError:
                LOG.error(
                    _LE("Firewall Driver Error on fw state %(fwmsg)s " "for fw: %(fwid)s"),
                    {"fwmsg": fw["status"], "fwid": fw["id"]},
                )
                status = constants.ERROR

            self.fwplugin_rpc.set_firewall_status(ctx, fw["id"], status)
开发者ID:punithks,项目名称:neutron,代码行数:31,代码来源:firewall_l3_agent.py

示例10: remove_empty_bridges

def remove_empty_bridges():
    try:
        interface_mappings = n_utils.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error(_LE("Parsing physical_interface_mappings failed: %s."), e)
        sys.exit(1)
    LOG.info(_LI("Interface mappings: %s."), interface_mappings)

    try:
        bridge_mappings = n_utils.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error(_LE("Parsing bridge_mappings failed: %s."), e)
        sys.exit(1)
    LOG.info(_LI("Bridge mappings: %s."), bridge_mappings)

    lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager(
        bridge_mappings, interface_mappings)

    bridge_names = lb_manager.get_deletable_bridges()
    for bridge_name in bridge_names:
        if lb_manager.get_tap_devices_count(bridge_name):
            continue

        try:
            lb_manager.delete_bridge(bridge_name)
            LOG.info(_LI("Linux bridge %s deleted"), bridge_name)
        except RuntimeError:
            LOG.exception(_LE("Linux bridge %s delete failed"), bridge_name)
    LOG.info(_LI("Linux bridge cleanup completed successfully"))
开发者ID:21atlas,项目名称:neutron,代码行数:31,代码来源:linuxbridge_cleanup.py

示例11: _dhcp_ready_ports_loop

 def _dhcp_ready_ports_loop(self):
     """Notifies the server of any ports that had reservations setup."""
     while True:
         # this is just watching a set so we can do it really frequently
         eventlet.sleep(0.1)
         if self.dhcp_ready_ports:
             ports_to_send = self.dhcp_ready_ports
             self.dhcp_ready_ports = set()
             try:
                 self.plugin_rpc.dhcp_ready_on_ports(ports_to_send)
                 continue
             except oslo_messaging.MessagingTimeout:
                 LOG.error(_LE("Timeout notifying server of ports ready. "
                               "Retrying..."))
             except Exception as e:
                 if (isinstance(e, oslo_messaging.RemoteError)
                         and e.exc_type == 'NoSuchMethod'):
                     LOG.info(_LI("Server does not support port ready "
                                  "notifications. Waiting for 5 minutes "
                                  "before retrying."))
                     eventlet.sleep(300)
                     continue
                 LOG.exception(_LE("Failure notifying DHCP server of "
                                   "ready DHCP ports. Will retry on next "
                                   "iteration."))
             self.dhcp_ready_ports |= ports_to_send
开发者ID:gotostack,项目名称:neutron,代码行数:26,代码来源:agent.py

示例12: _bind_port_level

    def _bind_port_level(self, context, level, segments_to_bind):
        binding = context._binding
        port_id = context.current['id']
        LOG.debug("Attempting to bind port %(port)s on host %(host)s "
                  "at level %(level)s using segments %(segments)s",
                  {'port': port_id,
                   'host': context.host,
                   'level': level,
                   'segments': segments_to_bind})

        if level == MAX_BINDING_LEVELS:
            LOG.error(_LE("Exceeded maximum binding levels attempting to bind "
                        "port %(port)s on host %(host)s"),
                      {'port': context.current['id'],
                       'host': context.host})
            return False

        for driver in self.ordered_mech_drivers:
            if not self._check_driver_to_bind(driver, segments_to_bind,
                                              context._binding_levels):
                continue
            try:
                context._prepare_to_bind(segments_to_bind)
                driver.obj.bind_port(context)
                segment = context._new_bound_segment
                if segment:
                    context._push_binding_level(
                        models.PortBindingLevel(port_id=port_id,
                                                host=context.host,
                                                level=level,
                                                driver=driver.name,
                                                segment_id=segment))
                    next_segments = context._next_segments_to_bind
                    if next_segments:
                        # Continue binding another level.
                        if self._bind_port_level(context, level + 1,
                                                 next_segments):
                            return True
                        else:
                            context._pop_binding_level()
                    else:
                        # Binding complete.
                        LOG.debug("Bound port: %(port)s, "
                                  "host: %(host)s, "
                                  "vif_type: %(vif_type)s, "
                                  "vif_details: %(vif_details)s, "
                                  "binding_levels: %(binding_levels)s",
                                  {'port': port_id,
                                   'host': context.host,
                                   'vif_type': binding.vif_type,
                                   'vif_details': binding.vif_details,
                                   'binding_levels': context.binding_levels})
                        return True
            except Exception:
                LOG.exception(_LE("Mechanism driver %s failed in "
                                  "bind_port"),
                              driver.name)
        LOG.error(_LE("Failed to bind port %(port)s on host %(host)s"),
                  {'port': context.current['id'],
                   'host': binding.host})
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:60,代码来源:managers.py

示例13: _notify_loop

 def _notify_loop(self, resource, event, trigger, **kwargs):
     """The notification loop."""
     errors = []
     callbacks = list(self._callbacks[resource].get(event, {}).items())
     LOG.debug("Notify callbacks %s for %s, %s",
               callbacks, resource, event)
     # TODO(armax): consider using a GreenPile
     for callback_id, callback in callbacks:
         try:
             callback(resource, event, trigger, **kwargs)
         except Exception as e:
             abortable_event = (
                 event.startswith(events.BEFORE) or
                 event.startswith(events.PRECOMMIT)
             )
             if not abortable_event:
                 LOG.exception(_LE("Error during notification for "
                                   "%(callback)s %(resource)s, %(event)s"),
                               {'callback': callback_id,
                                'resource': resource, 'event': event})
             else:
                 LOG.error(_LE("Callback %(callback)s raised %(error)s"),
                           {'callback': callback_id, 'error': e})
             errors.append(exceptions.NotificationError(callback_id, e))
     return errors
开发者ID:2020human,项目名称:neutron,代码行数:25,代码来源:manager.py

示例14: send_events

 def send_events(self, batched_events):
     LOG.debug("Sending events: %s", batched_events)
     try:
         response = self.nclient.server_external_events.create(
             batched_events)
     except nova_exceptions.NotFound:
         LOG.warning(_LW("Nova returned NotFound for event: %s"),
                     batched_events)
     except Exception:
         LOG.exception(_LE("Failed to notify nova on events: %s"),
                       batched_events)
     else:
         if not isinstance(response, list):
             LOG.error(_LE("Error response returned from nova: %s"),
                       response)
             return
         response_error = False
         for event in response:
             try:
                 code = event['code']
             except KeyError:
                 response_error = True
                 continue
             if code != 200:
                 LOG.warning(_LW("Nova event: %s returned with failed "
                                 "status"), event)
             else:
                 LOG.info(_LI("Nova event response: %s"), event)
         if response_error:
             LOG.error(_LE("Error response returned from nova: %s"),
                       response)
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:31,代码来源:nova.py

示例15: delete_addr_and_conntrack_state

    def delete_addr_and_conntrack_state(self, cidr):
        """Delete an address along with its conntrack state

        This terminates any active connections through an IP.

        :param cidr: the IP address for which state should be removed.
            This can be passed as a string with or without /NN.
            A netaddr.IPAddress or netaddr.Network representing the IP address
            can also be passed.
        """
        self.addr.delete(cidr)

        ip_str = str(netaddr.IPNetwork(cidr).ip)
        ip_wrapper = IPWrapper(namespace=self.namespace)

        # Delete conntrack state for ingress traffic
        # If 0 flow entries have been deleted
        # conntrack -D will return 1
        try:
            ip_wrapper.netns.execute(["conntrack", "-D", "-d", ip_str],
                                     check_exit_code=True,
                                     extra_ok_codes=[1])

        except RuntimeError:
            LOG.exception(_LE("Failed deleting ingress connection state of"
                              " floatingip %s"), ip_str)

        # Delete conntrack state for egress traffic
        try:
            ip_wrapper.netns.execute(["conntrack", "-D", "-q", ip_str],
                                     check_exit_code=True,
                                     extra_ok_codes=[1])
        except RuntimeError:
            LOG.exception(_LE("Failed deleting egress connection state of"
                              " floatingip %s"), ip_str)
开发者ID:Snergster,项目名称:virl-salt,代码行数:35,代码来源:neutron+agent+linux+ip_lib.py


注:本文中的neutron._i18n._LE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。