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


Python _i18n._LE函数代码示例

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


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

示例1: get_vlan_from_reply1

 def get_vlan_from_reply1(self, reply):
     '''Parse the reply from VDP daemon to get the VLAN value'''
     try:
         mode_str = reply.partition("mode = ")[2].split()[0]
         if mode_str != "assoc":
             return constants.INVALID_VLAN
     except Exception:
         LOG.error(_LE("Incorrect Reply,no mode information found: %s"),
                   reply)
         return constants.INVALID_VLAN
     try:
         f_ind = reply.index("filter = ")
     except Exception:
         LOG.error(_LE("Incorrect Reply,no filter information found: %s"),
                   reply)
         return constants.INVALID_VLAN
     try:
         l_ind = reply.rindex("filter = ")
     except Exception:
         LOG.error(_LE("Incorrect Reply,no filter information found: %s"),
                   reply)
         return constants.INVALID_VLAN
     if f_ind != l_ind:
         # Currently not supported if reply contains a filter keyword
         LOG.error(_LE("Err: not supported currently"))
         return constants.INVALID_VLAN
     try:
         vlan_val = reply.partition("filter = ")[2].split('-')[0]
         vlan = int(vlan_val)
     except ValueError:
         LOG.error(_LE("Reply not formatted correctly:"), reply)
         return constants.INVALID_VLAN
     return vlan
开发者ID:abattye,项目名称:networking-cisco,代码行数:33,代码来源:lldpad.py

示例2: _get_profile_id

 def _get_profile_id(cls, p_type, resource, name):
     try:
         tenant_id = manager.NeutronManager.get_service_plugins()[
             cisco_constants.DEVICE_MANAGER].l3_tenant_id()
     except AttributeError:
         return
     if tenant_id is None:
         return
     if p_type == 'net_profile':
         plugin = manager.NeutronManager.\
             get_service_plugins().get(constants.CISCO_N1KV_NET_PROFILE)
         profiles = plugin.get_network_profiles(
             n_context.get_admin_context(),
             {'tenant_id': [tenant_id], 'name': [name]},
             ['id'])
     else:
         plugin = manager.NeutronManager.get_service_plugins().get(
             constants.CISCO_N1KV)
         profiles = 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:JoelCapitao,项目名称:networking-cisco,代码行数:34,代码来源:n1kv_ml2_trunking_driver.py

示例3: get_routertype_db_by_id_name

 def get_routertype_db_by_id_name(self, context, id_or_name):
     query = context.session.query(l3_models.RouterType)
     query = query.filter(l3_models.RouterType.id == id_or_name)
     try:
         return query.one()
     except exc.MultipleResultsFound:
         with excutils.save_and_reraise_exception():
             LOG.error(_LE('Database inconsistency: Multiple router types '
                           'with same id %s'), id_or_name)
             raise routertype.RouterTypeNotFound(router_type=id_or_name)
     except exc.NoResultFound:
         query = context.session.query(l3_models.RouterType)
         query = query.filter(l3_models.RouterType.name == id_or_name)
         try:
             return query.one()
         except exc.MultipleResultsFound:
             with excutils.save_and_reraise_exception():
                 LOG.debug('Multiple router types with name %s found. '
                           'Id must be specified to allow arbitration.',
                           id_or_name)
                 raise routertype.MultipleRouterTypes(name=id_or_name)
         except exc.NoResultFound:
             with excutils.save_and_reraise_exception():
                 LOG.error(_LE('No router type with name %s found.'),
                           id_or_name)
                 raise routertype.RouterTypeNotFound(id=id_or_name)
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:26,代码来源:routertype_db.py

示例4: remove_rtr_nwk_next_hop

    def remove_rtr_nwk_next_hop(self, rout_id, next_hop, subnet_lst,
                                excl_list):
        """Remove the next hop for all networks of a tenant. """
        namespace = self.find_rtr_namespace(rout_id)
        if namespace is None:
            LOG.error(_LE("Unable to find namespace for router %s"), rout_id)
            return False

        args = ['ip', 'route']
        ret = self.program_rtr_return(args, rout_id, namespace=namespace)
        if ret is None:
            LOG.error(_LE("Get routes return None %s"), rout_id)
            return False
        routes = ret.split('\n')
        concat_lst = subnet_lst + excl_list
        for rout in routes:
            if len(rout) == 0:
                continue
            nwk = rout.split()[0]
            if nwk == 'default':
                continue
            nwk_no_mask = nwk.split('/')[0]
            if nwk_no_mask not in concat_lst and nwk not in concat_lst:
                args = ['route', 'del', '-net', nwk, 'gw', next_hop]
                ret = self.program_rtr(args, rout_id, namespace=namespace)
                if not ret:
                    LOG.error(_LE("Program router returned error for %s"),
                              rout_id)
                    return False
        return True
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:30,代码来源:dfa_openstack_helper.py

示例5: mgmt_nw_id

 def mgmt_nw_id(cls):
     """Returns id of the management network."""
     if cls._mgmt_nw_uuid is None:
         tenant_id = cls.l3_tenant_id()
         if not tenant_id:
             return
         net = manager.NeutronManager.get_plugin().get_networks(
             neutron_context.get_admin_context(),
             {'tenant_id': [tenant_id],
              'name': [cfg.CONF.general.management_network]},
             ['id', 'subnets'])
         if len(net) == 1:
             num_subnets = len(net[0]['subnets'])
             if num_subnets == 0:
                 LOG.error(_LE('The management network has no subnet. '
                               'Please assign one.'))
                 return
             elif num_subnets > 1:
                 LOG.info(_LI('The management network has %d subnets. The '
                              'first one will be used.'), num_subnets)
             cls._mgmt_nw_uuid = net[0].get('id')
             cls._mgmt_subnet_uuid = net[0]['subnets'][0]
         elif len(net) > 1:
             # Management network must have a unique name.
             LOG.error(_LE('The management network for does not have '
                           'unique name. Please ensure that it is.'))
         else:
             # Management network has not been created.
             LOG.error(_LE('There is no virtual management network. Please '
                           'create one.'))
     return cls._mgmt_nw_uuid
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:31,代码来源:hosting_device_manager_db.py

示例6: _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 range(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:nh0556,项目名称:networking-cisco,代码行数:32,代码来源:cfg_agent.py

示例7: _delete_fw_fab_dev

    def _delete_fw_fab_dev(self, tenant_id, drvr_name, fw_dict):
        """Deletes the Firewall.

        This routine calls the fabric class to delete the fabric when
        a firewall is deleted. It also calls the device manager to
        unconfigure the device. It updates the database with the final
        result.
        """
        is_fw_virt = self.is_device_virtual()
        if self.fwid_attr[tenant_id].is_fw_drvr_created():
            ret = self.delete_fw_device(tenant_id, fw_dict.get('fw_id'),
                                        fw_dict)
            if not ret:
                LOG.error(_LE("Error in delete_fabric_fw device for tenant "
                          "%s"), tenant_id)
                return False
            else:
                self.fwid_attr[tenant_id].fw_drvr_created(False)
                self.update_fw_db_dev_status(fw_dict.get('fw_id'), '')
        ret = self.fabric.delete_fabric_fw(tenant_id, fw_dict, is_fw_virt,
                                           fw_constants.RESULT_FW_DELETE_INIT)
        if not ret:
            LOG.error(_LE("Error in delete_fabric_fw for tenant %s"),
                      tenant_id)
            return False
        self.update_fw_db_final_result(fw_dict.get('fw_id'), (
            fw_constants.RESULT_FW_DELETE_DONE))
        self.delete_fw(fw_dict.get('fw_id'))
        return True
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:29,代码来源:fw_mgr.py

示例8: create_project

    def create_project(self, org_name, part_name, dci_id, desc=None):
        """Create project on the DCNM.

        :param org_name: name of organization.
        :param part_name: name of partition.
        :param dci_id: Data Center interconnect id.
        :param desc: description of project.
        """
        desc = desc or org_name
        res = self._create_org(org_name, desc)
        if res and res.status_code in self._resp_ok:
            LOG.debug("Created %s organization in DCNM.", org_name)
        else:
            LOG.error(_LE("Failed to create %(org)s organization in DCNM."
                      "Response: %(res)s"), {'org': org_name, 'res': res})
            raise dexc.DfaClientRequestFailed(reason=res)

        res = self._create_or_update_partition(org_name, part_name,
                                               dci_id, desc)
        if res and res.status_code in self._resp_ok:
            LOG.debug("Created %s partition in DCNM.", part_name)
        else:
            LOG.error(_LE("Failed to create %(part)s partition in DCNM."
                      "Response: %(res)s"), {'part': part_name, 'res': res})
            raise dexc.DfaClientRequestFailed(reason=res)
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:25,代码来源:cisco_dfa_rest.py

示例9: _server_network_relay

    def _server_network_relay(self):

        # Open a socket in the global namespace for DHCP
        try:
            self.ext_sock, self.ext_addr = self._open_dhcp_ext_socket()
        except Exception:
            LOG.exception(_LE("Failed to open dhcp external socket in "
                              "global ns"))
            return
        recvbuf = bytearray(RECV_BUFFER_SIZE)

        # Forward DHCP responses from external to internal networks
        while True:
            try:
                size = self.ext_sock.recv_into(recvbuf)
                pkt = DhcpPacket.parse(recvbuf)
                vpnid = pkt.get_relay_option(151)
                ciaddr = pkt.get_ciaddr()
                if vpnid not in self.int_sockets_by_vpn:
                    continue
                int_sock = self.int_sockets_by_vpn[vpnid]
                self.debug_stats.increment_pkts_from_server(vpnid)
                if ciaddr == "0.0.0.0":
                    ciaddr = "255.255.255.255"
                LOG.debug('Forwarding DHCP response for vpn %s', vpnid)
                int_sock.sendto(recvbuf[:size], (ciaddr, DHCP_CLIENT_PORT))
                self.debug_stats.increment_pkts_to_client(vpnid)
            except Exception:
                LOG.exception(_LE('Failed to forward dhcp response'))
开发者ID:abattye,项目名称:networking-cisco,代码行数:29,代码来源:dhcp_relay.py

示例10: _create_fw_fab_dev_te

    def _create_fw_fab_dev_te(self, tenant_id, drvr_name, fw_dict):
        """Prepares the Fabric and configures the device.

        This routine calls the fabric class to prepare the fabric when
        a firewall is created. It also calls the device manager to
        configure the device. It updates the database with the final
        result.
        """
        is_fw_virt = self.is_device_virtual()
        ret = self.fabric.prepare_fabric_fw(tenant_id, fw_dict, is_fw_virt,
                                            fw_constants.RESULT_FW_CREATE_INIT)

        if not ret:
            LOG.error(_LE("Prepare Fabric failed"))
            return
        else:
            self.update_fw_db_final_result(fw_dict.get('fw_id'), (
                fw_constants.RESULT_FW_CREATE_DONE))
        ret = self.create_fw_device(tenant_id, fw_dict.get('fw_id'),
                                    fw_dict)
        if ret:
            self.fwid_attr[tenant_id].fw_drvr_created(True)
            self.update_fw_db_dev_status(fw_dict.get('fw_id'), 'SUCCESS')
            LOG.info(_LI("FW device create returned success for tenant %s"),
                     tenant_id)
        else:
            LOG.error(_LE("FW device create returned failure for tenant %s"),
                      tenant_id)
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:28,代码来源:fw_mgr.py

示例11: send_vdp_port_event

    def send_vdp_port_event(self, port_uuid, mac, net_uuid,
                            segmentation_id, status, oui):
        '''Send vNIC UP/Down event to VDP

        :param port_uuid: a ovslib.VifPort object.
        :mac: MAC address of the VNIC
        :param net_uuid: the net_uuid this port is to be associated with.
        :param segmentation_id: the VID for 'vlan' or tunnel ID for 'tunnel'
        :param status: Type of port event. 'up' or 'down'
        :oui: OUI Parameters
        '''
        lldpad_port = self.lldpad_info
        if not lldpad_port:
            LOG.error(_LE("There is no LLDPad port available."))
            return False

        ret = False
        if status == 'up':
            if self.vdp_mode == constants.VDP_SEGMENT_MODE:
                port_name = self.ext_br_obj.get_ofport_name(port_uuid)
                if port_name is None:
                    LOG.error(_LE("Unknown portname for uuid %s"), port_uuid)
                    return False
                LOG.info(_LI('portname for uuid %s is '), port_name)
                ret = self.port_up_segment_mode(lldpad_port, port_name,
                                                port_uuid, mac, net_uuid,
                                                segmentation_id, oui)
        else:
            if self.vdp_mode == constants.VDP_SEGMENT_MODE:
                ret = self.port_down_segment_mode(lldpad_port, port_uuid,
                                                  mac, net_uuid,
                                                  segmentation_id, oui)
        return ret
开发者ID:abattye,项目名称:networking-cisco,代码行数:33,代码来源:ovs_vdp.py

示例12: port_up_segment_mode

 def port_up_segment_mode(self, lldpad_port, port_name, port_uuid, mac,
                          net_uuid, segmentation_id, oui):
     lvm = self.local_vlan_map.get(net_uuid)
     if lvm and lvm.late_binding_vlan:
         vdp_vlan = lvm.late_binding_vlan
         ovs_cb_data = {'obj': self, 'mac': mac,
                        'port_uuid': port_uuid, 'net_uuid': net_uuid}
         lldpad_port.send_vdp_vnic_up(port_uuid=port_uuid,
                                      vsiid=port_uuid, gid=segmentation_id,
                                      mac=mac, vlan=vdp_vlan, oui=oui,
                                      vsw_cb_fn=self.vdp_vlan_change,
                                      vsw_cb_data=ovs_cb_data)
         lvm.port_uuid_list[port_uuid] = port_uuid
         return True
     else:
         int_br = self.integ_br_obj
         lvid = int_br.get_port_vlan_tag(port_name)
         if lvid != cconstants.INVALID_VLAN:
             ret, vdp_vlan = self.provision_vdp_overlay_networks(
                 port_uuid, mac, net_uuid, segmentation_id, lvid, oui)
             if not lvm:
                 lvm = LocalVlan(lvid, segmentation_id)
                 self.local_vlan_map[net_uuid] = lvm
             lvm.lvid = lvid
             lvm.port_uuid_list[port_uuid] = port_uuid
             if vdp_vlan != cconstants.INVALID_VLAN:
                 lvm.late_binding_vlan = vdp_vlan
             else:
                 LOG.error(_LE("Cannot provision VDP overlay"))
             return ret
         else:
             LOG.error(_LE("Invalid VLAN"))
             return False
开发者ID:abattye,项目名称:networking-cisco,代码行数:33,代码来源:ovs_vdp.py

示例13: process_vm_event

 def process_vm_event(self, msg, phy_uplink):
     LOG.info(
         _LI("In processing VM Event status %(status)s for MAC " "%(mac)s UUID %(uuid)s oui %(oui)s"),
         {"status": msg.get_status(), "mac": msg.get_mac(), "uuid": msg.get_port_uuid(), "oui": msg.get_oui()},
     )
     time.sleep(10)
     if msg.get_status() == "up":
         res_fail = constants.CREATE_FAIL
     else:
         res_fail = constants.DELETE_FAIL
     if not self.uplink_det_compl or phy_uplink not in self.ovs_vdp_obj_dict:
         LOG.error(_LE("Uplink Port Event not received yet"))
         self.update_vm_result(msg.get_port_uuid(), res_fail)
         return
     ovs_vdp_obj = self.ovs_vdp_obj_dict[phy_uplink]
     ret = ovs_vdp_obj.send_vdp_port_event(
         msg.get_port_uuid(),
         msg.get_mac(),
         msg.get_net_uuid(),
         msg.get_segmentation_id(),
         msg.get_status(),
         msg.get_oui(),
     )
     if not ret:
         LOG.error(_LE("Error in VDP port event, Err Queue enq"))
         self.update_vm_result(msg.get_port_uuid(), res_fail)
     else:
         self.update_vm_result(msg.get_port_uuid(), constants.RESULT_SUCCESS)
开发者ID:noironetworks,项目名称:networking-cisco,代码行数:28,代码来源:dfa_vdp_mgr.py

示例14: _server_network_relay

    def _server_network_relay(self):

        # Open a socket in the global namespace for DNS
        try:
            self.ext_sock, self.ext_addr, ext_port = (
                self._open_dns_ext_socket())
        except Exception:
            LOG.exception(_LE('Failed to open dns external '
                              'socket in global ns'))
            return
        recvbuf = bytearray(RECV_BUFFER_SIZE)
        LOG.debug("Opened dns external server socket on addr:%s:%i",
                  self.ext_addr, ext_port)

        # Forward DNS responses from external to internal networks
        while True:
            try:
                size = self.ext_sock.recv_into(recvbuf)
                pkt = DnsPacket.parse(recvbuf, size)
                msgid = pkt.get_msgid()
                LOG.debug("got dns response pkt, msgid =  %i", msgid)
                if msgid not in self.request_info_by_msgid:
                    LOG.debug('Could not find request by msgid %i', msgid)
                    continue
                int_sock, int_addr, int_port, createtime, viewid = (
                    self.request_info_by_msgid[msgid])
                self.debug_stats.increment_pkts_from_server(viewid)
                LOG.debug("forwarding response to internal namespace "
                          "at %s:%i", int_addr, int_port)
                int_sock.sendto(recvbuf[:size], (int_addr, int_port))
                del self.request_info_by_msgid[msgid]
                self.debug_stats.increment_pkts_to_client(viewid)
            except Exception:
                LOG.exception(_LE('Failed to forward dns response'))
开发者ID:abattye,项目名称:networking-cisco,代码行数:34,代码来源:dns_relay.py

示例15: _validate_multicast_ip_range

    def _validate_multicast_ip_range(self, network_profile):
        """
        Validate multicast ip range values.

        :param network_profile: network profile object
        """
        try:
            min_ip, max_ip = (network_profile
                              ['multicast_ip_range'].split('-', 1))
        except ValueError:
            msg = _LE("Invalid multicast ip address range. "
                      "example range: 224.1.1.1-224.1.1.10")
            LOG.error(msg)
            raise n_exc.InvalidInput(error_message=msg)
        for ip in [min_ip, max_ip]:
            try:
                if not netaddr.IPAddress(ip).is_multicast():
                    msg = _LE("%s is not a valid multicast ip address") % ip
                    LOG.error(msg)
                    raise n_exc.InvalidInput(error_message=msg)
                if netaddr.IPAddress(ip) <= netaddr.IPAddress('224.0.0.255'):
                    msg = _LE("%s is reserved multicast ip address") % ip
                    LOG.error(msg)
                    raise n_exc.InvalidInput(error_message=msg)
            except netaddr.AddrFormatError:
                msg = _LE("%s is not a valid ip address") % ip
                LOG.error(msg)
                raise n_exc.InvalidInput(error_message=msg)
        if netaddr.IPAddress(min_ip) > netaddr.IPAddress(max_ip):
            msg = (_LE("Invalid multicast IP range '%(min_ip)s-%(max_ip)s':"
                       " Range should be from low address to high address")
                   % {'min_ip': min_ip, 'max_ip': max_ip})
            LOG.error(msg)
            raise n_exc.InvalidInput(error_message=msg)
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:34,代码来源:network_profile_service.py


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