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


Python gettextutils._LE函数代码示例

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


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

示例1: 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(cfg.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:
            self.schedule_resync(e)
            LOG.exception(_LE('Unable to sync network state.'))
开发者ID:asadoughi,项目名称:neutron,代码行数:31,代码来源:dhcp_agent.py

示例2: _get_profile_id

 def _get_profile_id(cls, p_type, resource, name):
     try:
         tenant_id = manager.NeutronManager.get_service_plugins()[
             constants.L3_ROUTER_NAT].l3_tenant_id()
     except AttributeError:
         return
     if tenant_id is None:
         return
     core_plugin = manager.NeutronManager.get_plugin()
     if p_type == 'net_profile':
         profiles = core_plugin.get_network_profiles(
             n_context.get_admin_context(),
             {'tenant_id': [tenant_id], 'name': [name]},
             ['id'])
     else:
         profiles = core_plugin.get_policy_profiles(
             n_context.get_admin_context(),
             {'tenant_id': [tenant_id], 'name': [name]},
             ['id'])
     if len(profiles) == 1:
         return profiles[0]['id']
     elif len(profiles) > 1:
         # Profile must have a unique name.
         LOG.error(_LE('The %(resource)s %(name)s does not have unique '
                       'name. Please refer to admin guide and create one.'),
                   {'resource': resource, 'name': name})
     else:
         # Profile has not been created.
         LOG.error(_LE('There is no %(resource)s %(name)s. Please refer to '
                     'admin guide and create one.'),
                   {'resource': resource, 'name': name})
开发者ID:leesurezen,项目名称:neutron,代码行数:31,代码来源:n1kv_trunking_driver.py

示例3: get_active_routers_for_host

def get_active_routers_for_host(context, host):
    '''Get list of routers from INI file that use host requested.'''
    routers = []
    configured_routers = get_available_csrs_from_config(cfg.CONF.config_file)
    if not configured_routers:
        LOG.error(_LE("No routers found in INI file!"))
        return routers
    for router_ip, info in configured_routers.items():
        if host == info['host']:
            router_id = _get_router_id_via_external_ip(context, router_ip)
            if router_id:
                LOG.debug("Found router %(router)s on host %(host)s",
                          {'router': router_id, 'host': host})
                routers.append({
                    'id': router_id,
                    'hosting_device': {
                        'management_ip_address': info['rest_mgmt_ip'],
                        'credentials': {'username': info['username'],
                                        'password': info['password']}
                    },
                    'tunnel_if': info['tunnel_if'],
                    'tunnel_ip': info['tunnel_ip']
                })
            else:
                LOG.error(_LE("Unable to lookup router ID based on router's "
                              "public IP (%s) in INI file"), router_ip)
    if not routers:
        LOG.error(_LE("No matching routers on host %s"), host)
    return routers
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:29,代码来源:cisco_cfg_loader.py

示例4: create_router

    def create_router(self, host, username, password, rbridge_id, router_id):
        """create vrf and associate vrf."""
        router_id = router_id[0:11]
        vrf_name = template.OS_VRF_NAME.format(id=router_id)
        rd = router_id + ":" + router_id
        try:
            mgr = self.connect(host, username, password)
            self.create_vrf(mgr, rbridge_id, vrf_name)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.exception(_LE("NETCONF error"))
                self.close_session()
        try:
            # For Nos5.0.0
            self.configure_rd_for_vrf(mgr, rbridge_id, vrf_name, rd)
            self.configure_address_family_for_vrf(mgr, rbridge_id, vrf_name)
        except Exception:
            with excutils.save_and_reraise_exception() as ctxt:
                try:
                    # This is done because on 4.0.0 rd doesnt accept alpha
                    # character nor hyphen
                    rd = "".join(i for i in router_id if i in "0123456789")
                    rd = rd[:4] + ":" + rd[:4]
                    self.configure_rd_for_vrf(mgr, rbridge_id, vrf_name, rd)
                    self.configure_address_family_for_vrf_v1(mgr,
                                                             rbridge_id,
                                                             vrf_name)
                except Exception:
                    with excutils.save_and_reraise_exception():
                        LOG.exception(_LE("NETCONF error"))
                        self.close_session()

                ctxt.reraise = False
开发者ID:leesurezen,项目名称:neutron,代码行数:33,代码来源:nosdriver.py

示例5: _agent_registration

    def _agent_registration(self):
        """Register this agent with the server.

        This method registers the cfg agent with the neutron server so hosting
        devices can be assigned to it. In case the server is not ready to
        accept registration (it sends a False) then we retry registration
        for `MAX_REGISTRATION_ATTEMPTS` with a delay of
        `REGISTRATION_RETRY_DELAY`. If there is no server response or a
        failure to register after the required number of attempts,
        the agent stops itself.
        """
        for attempts in xrange(MAX_REGISTRATION_ATTEMPTS):
            context = n_context.get_admin_context_without_session()
            self.send_agent_report(self.agent_state, context)
            res = self.devmgr_rpc.register_for_duty(context)
            if res is True:
                LOG.info(_LI("[Agent registration] Agent successfully "
                           "registered"))
                return
            elif res is False:
                LOG.warning(_LW("[Agent registration] Neutron server said "
                                "that device manager was not ready. Retrying "
                                "in %0.2f seconds "), REGISTRATION_RETRY_DELAY)
                time.sleep(REGISTRATION_RETRY_DELAY)
            elif res is None:
                LOG.error(_LE("[Agent registration] Neutron server said that "
                              "no device manager was found. Cannot continue. "
                              "Exiting!"))
                raise SystemExit("Cfg Agent exiting")
        LOG.error(_LE("[Agent registration] %d unsuccessful registration "
                    "attempts. Exiting!"), MAX_REGISTRATION_ATTEMPTS)
        raise SystemExit("Cfg Agent exiting")
开发者ID:leesurezen,项目名称:neutron,代码行数:32,代码来源:cfg_agent.py

示例6: consume_in_thread

    def consume_in_thread(self):
        """Runs the ZmqProxy service."""
        ipc_dir = CONF.rpc_zmq_ipc_dir
        consume_in = "tcp://%s:%s" % \
            (CONF.rpc_zmq_bind_address,
             CONF.rpc_zmq_port)
        consumption_proxy = InternalContext(None)

        try:
            os.makedirs(ipc_dir)
        except os.error:
            if not os.path.isdir(ipc_dir):
                with excutils.save_and_reraise_exception():
                    LOG.error(_LE("Required IPC directory does not exist at"
                                  " %s") % (ipc_dir, ))
        try:
            self.register(consumption_proxy,
                          consume_in,
                          zmq.PULL)
        except zmq.ZMQError:
            if os.access(ipc_dir, os.X_OK):
                with excutils.save_and_reraise_exception():
                    LOG.error(_LE("Permission denied to IPC directory at"
                                  " %s") % (ipc_dir, ))
            with excutils.save_and_reraise_exception():
                LOG.error(_LE("Could not create ZeroMQ receiver daemon. "
                              "Socket may already be in use."))

        super(ZmqProxy, self).consume_in_thread()
开发者ID:ArifovicH,项目名称:neutron,代码行数:29,代码来源:impl_zmq.py

示例7: reschedule_routers_from_down_agents

    def reschedule_routers_from_down_agents(self):
        """Reschedule routers from down l3 agents if admin state is up."""

        # give agents extra time to handle transient failures
        agent_dead_limit = cfg.CONF.agent_down_time * 2

        # check for an abrupt clock change since last check. if a change is
        # detected, sleep for a while to let the agents check in.
        tdelta = timeutils.utcnow() - getattr(self, "_clock_jump_canary", timeutils.utcnow())
        if timeutils.total_seconds(tdelta) > cfg.CONF.agent_down_time:
            LOG.warn(
                _LW(
                    "Time since last L3 agent reschedule check has "
                    "exceeded the interval between checks. Waiting "
                    "before check to allow agents to send a heartbeat "
                    "in case there was a clock adjustment."
                )
            )
            time.sleep(agent_dead_limit)
        self._clock_jump_canary = timeutils.utcnow()

        context = n_ctx.get_admin_context()
        cutoff = timeutils.utcnow() - datetime.timedelta(seconds=agent_dead_limit)
        down_bindings = (
            context.session.query(RouterL3AgentBinding)
            .join(agents_db.Agent)
            .filter(agents_db.Agent.heartbeat_timestamp < cutoff, agents_db.Agent.admin_state_up)
            .outerjoin(
                l3_attrs_db.RouterExtraAttributes,
                l3_attrs_db.RouterExtraAttributes.router_id == RouterL3AgentBinding.router_id,
            )
            .filter(
                sa.or_(
                    l3_attrs_db.RouterExtraAttributes.ha == sql.false(),
                    l3_attrs_db.RouterExtraAttributes.ha == sql.null(),
                )
            )
        )
        try:
            for binding in down_bindings:
                LOG.warn(
                    _LW(
                        "Rescheduling router %(router)s from agent %(agent)s "
                        "because the agent did not report to the server in "
                        "the last %(dead_time)s seconds."
                    ),
                    {"router": binding.router_id, "agent": binding.l3_agent_id, "dead_time": agent_dead_limit},
                )
                try:
                    self.reschedule_router(context, binding.router_id)
                except (l3agentscheduler.RouterReschedulingFailed, n_rpc.RemoteError):
                    # Catch individual router rescheduling errors here
                    # so one broken one doesn't stop the iteration.
                    LOG.exception(_LE("Failed to reschedule router %s"), binding.router_id)
        except db_exc.DBError:
            # Catch DB errors here so a transient DB connectivity issue
            # doesn't stop the loopingcall.
            LOG.exception(_LE("Exception encountered during router " "rescheduling."))
开发者ID:nash-x,项目名称:hws,代码行数:58,代码来源:l3_agentschedulers_db.py

示例8: _invoke_driver

 def _invoke_driver(self, context, meterings, func_name):
     try:
         return getattr(self.metering_driver, func_name)(context, meterings)
     except AttributeError:
         LOG.exception(_LE("Driver %(driver)s does not implement %(func)s"),
                       {'driver': self.conf.driver,
                        'func': func_name})
     except RuntimeError:
         LOG.exception(_LE("Driver %(driver)s:%(func)s runtime error"),
                       {'driver': self.conf.driver,
                        'func': func_name})
开发者ID:leesurezen,项目名称:neutron,代码行数:11,代码来源:metering_agent.py

示例9: _bind_centralized_snat_port_on_dvr_subnet

    def _bind_centralized_snat_port_on_dvr_subnet(self, port, fixed_ips,
                                                  device_owner, local_vlan):
        if port.vif_id in self.local_ports:
            # throw an error if CSNAT port is already on a different
            # dvr routed subnet
            ovsport = self.local_ports[port.vif_id]
            subs = list(ovsport.get_subnets())
            LOG.error(_LE("Centralized-SNAT port %s already seen on "),
                      port.vif_id)
            LOG.error(_LE("a different subnet %s"), subs[0])
            return
        # since centralized-SNAT (CSNAT) port must have only one fixed
        # IP, directly use fixed_ips[0]
        subnet_uuid = fixed_ips[0]['subnet_id']
        ldm = None
        subnet_info = None
        if subnet_uuid not in self.local_dvr_map:
            # no csnat ports seen on this subnet - create csnat state
            # for this subnet
            subnet_info = self.plugin_rpc.get_subnet_for_dvr(self.context,
                                                             subnet_uuid)
            ldm = LocalDVRSubnetMapping(subnet_info, port.ofport)
            self.local_dvr_map[subnet_uuid] = ldm
        else:
            ldm = self.local_dvr_map[subnet_uuid]
            subnet_info = ldm.get_subnet_info()
            # Store csnat OF Port in the existing DVRSubnetMap
            ldm.set_csnat_ofport(port.ofport)

        # create ovsPort footprint for csnat port
        ovsport = OVSPort(port.vif_id, port.ofport,
                          port.vif_mac, device_owner)
        ovsport.add_subnet(subnet_uuid)
        self.local_ports[port.vif_id] = ovsport

        self.int_br.add_flow(table=constants.DVR_TO_SRC_MAC,
                             priority=4,
                             dl_vlan=local_vlan,
                             dl_dst=ovsport.get_mac(),
                             actions="strip_vlan,mod_dl_src:%s,"
                             " output:%s" %
                             (subnet_info['gateway_mac'],
                              ovsport.get_ofport()))
        ofports = ','.join(map(str, ldm.get_compute_ofports().values()))
        ofports = str(ldm.get_csnat_ofport()) + ',' + ofports
        ip_subnet = subnet_info['cidr']
        self.int_br.add_flow(table=constants.DVR_TO_SRC_MAC,
                             priority=2,
                             proto='ip',
                             dl_vlan=local_vlan,
                             nw_dst=ip_subnet,
                             actions="strip_vlan,mod_dl_src:%s,"
                             " output:%s" %
                             (subnet_info['gateway_mac'], ofports))
开发者ID:leesurezen,项目名称:neutron,代码行数:54,代码来源:ovs_dvr_neutron_agent.py

示例10: provision_local_vlan

    def provision_local_vlan(self, net_uuid, network_type, physical_network,
                             segmentation_id):
        """Provisions a local VLAN.

        :param net_uuid: the uuid of the network associated with this vlan.
        :param network_type: the network type ('gre', 'vxlan', 'vlan', 'flat',
                                               'local')
        :param physical_network: the physical network for 'vlan' or 'flat'
        :param segmentation_id: the VID for 'vlan' or tunnel ID for 'tunnel'
        """

        if not self.available_local_vlans:
            LOG.error(_LE("No local VLAN available for net-id=%s"), net_uuid)
            return
        lvid = self.available_local_vlans.pop()
        LOG.info(_LI("Assigning %(vlan_id)s as local vlan for "
                     "net-id=%(net_uuid)s"),
                 {'vlan_id': lvid, 'net_uuid': net_uuid})
        self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid, network_type,
                                                         physical_network,
                                                         segmentation_id)

        if network_type in constants.TUNNEL_NETWORK_TYPES:
            if self.enable_tunneling:
                self.int_br.provision_tenant_tunnel(network_type, lvid,
                                                    segmentation_id)
            else:
                LOG.error(_LE("Cannot provision %(network_type)s network for "
                              "net-id=%(net_uuid)s - tunneling disabled"),
                          {'network_type': network_type,
                           'net_uuid': net_uuid})
        elif network_type in [p_const.TYPE_VLAN, p_const.TYPE_FLAT]:
            if physical_network in self.int_ofports:
                phys_port = self.int_ofports[physical_network]
                self.int_br.provision_tenant_physnet(network_type, lvid,
                                                     segmentation_id,
                                                     phys_port)
            else:
                LOG.error(_LE("Cannot provision %(network_type)s network for "
                              "net-id=%(net_uuid)s - no bridge for "
                              "physical_network %(physical_network)s"),
                          {'network_type': network_type,
                           'net_uuid': net_uuid,
                           'physical_network': physical_network})
        elif network_type == p_const.TYPE_LOCAL:
            # no flows needed for local networks
            pass
        else:
            LOG.error(_LE("Cannot provision unknown network type "
                          "%(network_type)s for net-id=%(net_uuid)s"),
                      {'network_type': network_type,
                       'net_uuid': net_uuid})
开发者ID:kongseokhwan,项目名称:kulcloud-neutron,代码行数:52,代码来源:ofa_neutron_agent.py

示例11: extend_resources

    def extend_resources(self, version, attr_map):
        """Extend resources with additional resources or attributes.

        :param: attr_map, the existing mapping from resource name to
        attrs definition.

        After this function, we will extend the attr_map if an extension
        wants to extend this map.
        """
        update_exts = []
        processed_exts = set()
        exts_to_process = self.extensions.copy()
        # Iterate until there are unprocessed extensions or if no progress
        # is made in a whole iteration
        while exts_to_process:
            processed_ext_count = len(processed_exts)
            for ext_name, ext in exts_to_process.items():
                if not hasattr(ext, 'get_extended_resources'):
                    del exts_to_process[ext_name]
                    continue
                if hasattr(ext, 'update_attributes_map'):
                    update_exts.append(ext)
                if hasattr(ext, 'get_required_extensions'):
                    # Process extension only if all required extensions
                    # have been processed already
                    required_exts_set = set(ext.get_required_extensions())
                    if required_exts_set - processed_exts:
                        continue
                try:
                    extended_attrs = ext.get_extended_resources(version)
                    for resource, resource_attrs in extended_attrs.iteritems():
                        if attr_map.get(resource, None):
                            attr_map[resource].update(resource_attrs)
                        else:
                            attr_map[resource] = resource_attrs
                except AttributeError:
                    LOG.exception(_LE("Error fetching extended attributes for "
                                      "extension '%s'"), ext.get_name())
                processed_exts.add(ext_name)
                del exts_to_process[ext_name]
            if len(processed_exts) == processed_ext_count:
                # Exit loop as no progress was made
                break
        if exts_to_process:
            # NOTE(salv-orlando): Consider whether this error should be fatal
            LOG.error(_LE("It was impossible to process the following "
                          "extensions: %s because of missing requirements."),
                      ','.join(exts_to_process.keys()))

        # Extending extensions' attributes map.
        for ext in update_exts:
            ext.update_attributes_map(attr_map)
开发者ID:asadoughi,项目名称:neutron,代码行数:52,代码来源:extensions.py

示例12: _call

    def _call(self, action, resource, data, headers, binary=False):
        if resource.startswith('http'):
            uri = resource
        else:
            uri = self.base_uri + resource
        if binary:
            body = data
        else:
            body = jsonutils.dumps(data)

        debug_data = 'binary' if binary else body
        debug_data = debug_data if debug_data else 'EMPTY'
        if not headers:
            headers = {'Authorization': 'Basic %s' % self.auth}
        else:
            headers['Authorization'] = 'Basic %s' % self.auth
        conn = None
        if self.ssl:
            conn = httplib.HTTPSConnection(
                self.server, self.port, timeout=self.timeout)
            if conn is None:
                LOG.error(_LE('vdirectRESTClient: Could not establish HTTPS '
                          'connection'))
                return 0, None, None, None
        else:
            conn = httplib.HTTPConnection(
                self.server, self.port, timeout=self.timeout)
            if conn is None:
                LOG.error(_LE('vdirectRESTClient: Could not establish HTTP '
                          'connection'))
                return 0, None, None, None

        try:
            conn.request(action, uri, body, headers)
            response = conn.getresponse()
            respstr = response.read()
            respdata = respstr
            try:
                respdata = jsonutils.loads(respstr)
            except ValueError:
                # response was not JSON, ignore the exception
                pass
            ret = (response.status, response.reason, respstr, respdata)
        except Exception as e:
            log_dict = {'action': action, 'e': e}
            LOG.error(_LE('vdirectRESTClient: %(action)s failure, %(e)r'),
                      log_dict)
            ret = -1, None, None, None
        conn.close()
        return ret
开发者ID:leesurezen,项目名称:neutron,代码行数:50,代码来源:driver.py

示例13: _invoke_driver_for_plugin_api

 def _invoke_driver_for_plugin_api(self, context, fw, func_name):
     """Invoke driver method for plugin API and provide status back."""
     LOG.debug("%(func_name)s from agent for fw: %(fwid)s",
               {'func_name': func_name, 'fwid': fw['id']})
     try:
         routers = self.plugin_rpc.get_routers(context)
         router_info_list = self._get_router_info_list_for_tenant(
             routers,
             fw['tenant_id'])
         if not router_info_list:
             LOG.debug('No Routers on tenant: %s', fw['tenant_id'])
             # fw was created before any routers were added, and if a
             # delete is sent then we need to ack so that plugin can
             # cleanup.
             if func_name == 'delete_firewall':
                 self.fwplugin_rpc.firewall_deleted(context, fw['id'])
             return
         LOG.debug("Apply fw on Router List: '%s'",
                   [ri.router['id'] for ri in router_info_list])
         # call into the driver
         try:
             self.fwaas_driver.__getattribute__(func_name)(
                 self.conf.agent_mode,
                 router_info_list,
                 fw)
             if fw['admin_state_up']:
                 status = constants.ACTIVE
             else:
                 status = constants.DOWN
         except fw_ext.FirewallInternalDriverError:
             LOG.error(_LE("Firewall Driver Error for %(func_name)s "
                           "for fw: %(fwid)s"),
                       {'func_name': func_name, 'fwid': fw['id']})
             status = constants.ERROR
         # delete needs different handling
         if func_name == 'delete_firewall':
             if status in [constants.ACTIVE, constants.DOWN]:
                 self.fwplugin_rpc.firewall_deleted(context, fw['id'])
         else:
             self.fwplugin_rpc.set_firewall_status(
                 context,
                 fw['id'],
                 status)
     except Exception:
         LOG.exception(
             _LE("FWaaS RPC failure in %(func_name)s for fw: %(fwid)s"),
             {'func_name': func_name, 'fwid': fw['id']})
         self.services_sync = True
     return
开发者ID:fortara,项目名称:neutron,代码行数:49,代码来源:firewall_l3_agent.py

示例14: check_nova_notify

def check_nova_notify():
    result = checks.nova_notify_supported()
    if not result:
        LOG.error(_LE('Nova notifications are enabled, but novaclient is not '
                      'installed. Either disable nova notifications or '
                      'install python-novaclient.'))
    return result
开发者ID:AsherBond,项目名称:quantum,代码行数:7,代码来源:sanity_check.py

示例15: _get_enabled_agents

 def _get_enabled_agents(self, context, network, agents, method, payload):
     """Get the list of agents whose admin_state is UP."""
     network_id = network['id']
     enabled_agents = [x for x in agents if x.admin_state_up]
     active_agents = [x for x in agents if x.is_active]
     len_enabled_agents = len(enabled_agents)
     len_active_agents = len(active_agents)
     if len_active_agents < len_enabled_agents:
         LOG.warn(_LW("Only %(active)d of %(total)d DHCP agents associated "
                      "with network '%(net_id)s' are marked as active, so "
                      "notifications may be sent to inactive agents."),
                  {'active': len_active_agents,
                   'total': len_enabled_agents,
                   'net_id': network_id})
     if not enabled_agents:
         num_ports = self.plugin.get_ports_count(
             context, {'network_id': [network_id]})
         notification_required = (
             num_ports > 0 and len(network['subnets']) >= 1)
         if notification_required:
             LOG.error(_LE("Will not send event %(method)s for network "
                           "%(net_id)s: no agent available. Payload: "
                           "%(payload)s"),
                       {'method': method,
                        'net_id': network_id,
                        'payload': payload})
     return enabled_agents
开发者ID:asadoughi,项目名称:neutron,代码行数:27,代码来源:dhcp_rpc_agent_api.py


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