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


Python _i18n._LE函数代码示例

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


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

示例1: _notify_agent

 def _notify_agent(self, network_info):
     host = None
     cluster_id = network_info['cluster_id']
     if 'host' in network_info:
         host = network_info['host']
     else:
         agent = self._get_ovsvapp_agent_from_cluster(self.context,
                                                      cluster_id)
         LOG.debug("Agent chosen for notification: %s.", agent)
         if agent and 'host' in agent:
             host = agent['host']
         else:
             LOG.error(_LE("Failed to find OVSvApp Agent with host "
                           "%(host)s while releasing network allocations "
                           "for %(cluster)s in vCenter %(vcenter)s."),
                       {'host': host,
                        'vcenter': network_info['vcenter_id'],
                        'cluster': cluster_id})
             return
     try:
         LOG.info(_LI("Initiating device_delete RPC for network "
                      "%(network)s to OVSvApp agent on host %(host)s."),
                  {'host': host, 'network': network_info})
         self.notifier.device_delete(self.context, network_info, host,
                                     cluster_id)
     except Exception:
         LOG.exception(_LE("Failed to notify agent to delete port group."))
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:27,代码来源:ovsvapp_mech_driver.py

示例2: _parse_mapping

    def _parse_mapping(self, entry):
        """Parse an entry of cluster_dvs_mapping.

        :param entry: String value which is an entry in conf file
                      for cluster_dvs_mapping.
                      Could be a simple mapping in the form
                      clusterpath:dvsname or a comma separated one like
                      clusterpath1:dvsname1,clusterpath2:dvsname2
        :returns: A list of (cluster, dvs) tuples
        """
        try:
            cluster_dvs_list = []
            LOG.debug("Parsing cluster_dvs_mapping %s.", entry)
            mappings = entry.split(",")
            for mapping in mappings:
                cluster = None
                vds = None
                if ":" in mapping:
                    cluster, vds = mapping.split(":", 1)
                    cluster = cluster.strip()
                    vds = vds.strip()
                if not cluster or not vds:
                    LOG.error(_LE("Invalid value %s for opt "
                                  "cluster_dvs_mapping."), mapping)
                else:
                    cluster_dvs_list.append((cluster, vds))
        except Exception:
            LOG.exception(_LE("Invalid value %s for opt cluster_dvs_mapping."),
                          entry)
        return cluster_dvs_list
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:30,代码来源:manager.py

示例3: is_valid_dvswitch

def is_valid_dvswitch(session, cluster_mor, dvs_name):
    """Validate a DVS.

    Check if DVS exists for a cluster specified in conf.
    Also validate if DVS is attached to all hosts in a cluster.
    """
    dvs_mor = get_dvs_mor_by_name(session, dvs_name)
    if dvs_mor:
        dvs_config = session._call_method(
            vim_util, "get_dynamic_property", dvs_mor,
            "DistributedVirtualSwitch", "config.host")
        # Get all the host attached to given VDS
        dvs_host_members = dvs_config[0]
        dvs_attached_host_ids = []
        for dvs_host_member in dvs_host_members:
            dvs_attached_host_ids.append(dvs_host_member.config.host.value)

        # Get all the hosts present in the cluster
        hosts_in_cluster = resource_util.get_host_mors_for_cluster(
            session, cluster_mor)

        # Check if the host on which OVSvApp VM is hosted is a part of DVSwitch
        if hosts_in_cluster:
            for host in hosts_in_cluster:
                hostname = resource_util.get_hostname_for_host_mor(
                    session, host)
                if hostname == cfg.CONF.VMWARE.esx_hostname:
                    if host.value not in dvs_attached_host_ids:
                        LOG.error(_LE("DVS not present on"
                                      "host %s"), host.value)
                        return False
            return hosts_in_cluster
    else:
        LOG.error(_LE("DVS not present %s"), dvs_name)
        return False
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:35,代码来源:network_util.py

示例4: update_device_binding

    def update_device_binding(self, rpc_context, **kwargs):
        agent_id = kwargs.get('agent_id')
        device_id = kwargs.get('device')
        host = kwargs.get('host')
        updated_ports = set()
        ports = None
        ports = self.plugin.get_ports(rpc_context,
                                      filters={'device_id': [device_id]})
        for port in ports:
            network = self.plugin.get_network(rpc_context, port['network_id'])
            port['network_type'] = network['provider:network_type']
            if network['provider:network_type'] == common_const.TYPE_VXLAN:
                retry_count = 3
                while retry_count > 0:
                    sleep = False
                    for pport in ports:
                        if pport['status'] != common_const.PORT_STATUS_ACTIVE:
                            sleep = True
                            break
                    if sleep:
                        time.sleep(retry_count * 3)
                        retry_count -= 1
                        ports = self.plugin.get_ports(rpc_context,
                                                      filters={'device_id':
                                                               [device_id]})
                    else:
                        port['status'] = common_const.PORT_STATUS_ACTIVE
                        break
                if retry_count == 0:
                    LOG.error(_LE("Failed to update binding for device %s, "
                                  "as the device has one of more ports "
                                  "in BUILD state."), device_id)
                    return

            port_id = port['id']
            LOG.debug("Port %(port_id)s update_port invoked by agent "
                      "%(agent_id)s for host %(host)s.",
                      {'port_id': port_id, 'agent_id': agent_id,
                       'host': host})
            new_port = {'port': {portbindings.HOST_ID: host}}
            try:
                updated_port = self.plugin.update_port(rpc_context, port_id,
                                                       new_port)
                updated_ports.add(updated_port['id'])
                if port['network_type'] == common_const.TYPE_VXLAN:
                    time.sleep(1)
                    new_status = (common_const.PORT_STATUS_BUILD
                                  if port['admin_state_up'] else
                                  common_const.PORT_STATUS_DOWN)
                    if port['status'] != new_status:
                        self.plugin.update_port_status(rpc_context, port['id'],
                                                       new_status, host)
                        time.sleep(1)
                        kwargs['device'] = port_id
                        self.update_device_up(rpc_context, **kwargs)
            except Exception:
                LOG.exception(_LE("Failed to update binding for port "
                                  "%s."), port_id)
        return updated_ports
开发者ID:openstack,项目名称:networking-vsphere,代码行数:59,代码来源:ovsvapp_rpc.py

示例5: initialize_driver

 def initialize_driver(self):
     self.stop()
     self.driver = None
     self.vcenter_ip = cfg.CONF.VMWARE.vcenter_ip
     self.vcenter_username = cfg.CONF.VMWARE.vcenter_username
     self.vcenter_password = cfg.CONF.VMWARE.vcenter_password
     self.vcenter_api_retry_count = cfg.CONF.VMWARE.vcenter_api_retry_count
     self.wsdl_location = cfg.CONF.VMWARE.wsdl_location
     self.https_port = cfg.CONF.VMWARE.https_port
     self.ca_path = None
     self.connection_timeout = cfg.CONF.VMWARE.connection_timeout
     if cfg.CONF.VMWARE.cert_check:
         if not cfg.CONF.VMWARE.cert_path:
             LOG.error(_LE("SSL certificate path is not defined to "
                           "establish secure vCenter connection. "
                           "Aborting agent!"))
             raise SystemExit(1)
         elif not os.path.isfile(cfg.CONF.VMWARE.cert_path):
             LOG.error(_LE("SSL certificate does not exist at "
                           "the specified path %s. Aborting agent!"),
                       cfg.CONF.VMWARE.cert_path)
             raise SystemExit(1)
         else:
             self.ca_path = cfg.CONF.VMWARE.cert_path
     if (self.vcenter_ip and self.vcenter_username and
             self.vcenter_password and self.wsdl_location):
         vim_session.ConnectionHandler.set_vc_details(
             self.vcenter_ip,
             self.vcenter_username,
             self.vcenter_password,
             self.vcenter_api_retry_count,
             self.wsdl_location,
             self.ca_path,
             self.connection_timeout,
             self.https_port)
         vim_session.ConnectionHandler.start()
         if self.connection_thread:
             self.connection_thread.kill()
         self.connection_thread = eventlet.spawn(
             vim_session.ConnectionHandler.try_connection)
         try:
             self.connection_thread.wait()
         except greenlet.GreenletExit:
             LOG.warning(_LW("Thread waiting on vCenter connection "
                             "exited."))
             return
     else:
         LOG.error(_LE("Must specify vcenter_ip, vcenter_username, "
                       "vcenter_password and wsdl_location."))
         return
     self.driver = dvs_driver.DvsNetworkDriver()
     self.driver.set_callback(self.netcallback)
     for mapping in cfg.CONF.VMWARE.cluster_dvs_mapping:
         cluster_dvs_list = self._parse_mapping(mapping)
         for cluster, vds in cluster_dvs_list:
             self._add_cluster(cluster, vds)
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:56,代码来源:manager.py

示例6: try_connection

 def try_connection(cls):
     while not cls.stopped:
         try:
             return cls.get_connection(create=True)
         except Exception as e:
             LOG.error(_LE("Connection to vCenter %(host_ip)s failed -"
                           "%(exception)s"), {"host_ip": cls.host_ip,
                                              "exception": e})
             LOG.error(_LE("Will retry after 60 secs"))
             time.sleep(60)
             LOG.error(_LE("Retrying VMWare Connection after 60 secs"))
             continue
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:12,代码来源:vim_session.py

示例7: monitor_events

 def monitor_events(self):
     try:
         LOG.info(_LI("Starting monitoring for vCenter updates"))
         version = ""
         self.state = constants.DRIVER_RUNNING
         while self.state in (constants.DRIVER_RUNNING):
             try:
                 LOG.debug("Waiting for vCenter updates...")
                 try:
                     updateSet = self.session._call_method(
                         vim_util,
                         "wait_for_updates_ex",
                         version)
                     if self.state != constants.DRIVER_RUNNING:
                         LOG.error(_LE("Driver is not in running state."))
                         break
                 except error_util.SocketTimeoutException:
                     # Ignore timeout.
                     LOG.warning(_LW("Ignoring socket timeouts while "
                                     "monitoring for vCenter updates."))
                     continue
                 if updateSet:
                     version = updateSet.version
                     events = self._process_update_set(updateSet)
                     LOG.debug("Sending events : %s.", events)
                     self.dispatch_events(events)
             except exceptions.VimFaultException as e:
                 # InvalidCollectorVersionFault happens
                 # on session re-connect.
                 # Re-initialize WaitForUpdatesEx.
                 if "InvalidCollectorVersion" in e.fault_list:
                     LOG.debug("InvalidCollectorVersion - "
                               "Re-initializing vCenter updates "
                               "monitoring.")
                     version = ""
                     for cluster_mor in self.clusters_by_id.values():
                         pfo = self._register_cluster_for_updates(
                             cluster_mor)
                         clu_id = cluster_mor.value
                         self.cluster_id_to_filter[clu_id] = pfo
                     continue
                 LOG.exception(_LE("VimFaultException while processing "
                                   "update set %s."), e)
             except Exception:
                 LOG.exception(_LE("Exception while processing update"
                                   " set."))
             time.sleep(0)
         LOG.info(_LI("Stopped monitoring for vCenter updates."))
     except Exception:
         LOG.exception(_LE("Monitoring for vCenter updates failed."))
开发者ID:VTabolin,项目名称:networking-vsphere,代码行数:50,代码来源:vc_driver.py

示例8: _remove_all_flows

 def _remove_all_flows(self, sec_br, port_id, del_provider_rules=False):
     """Remove all flows for a port."""
     LOG.debug("OVSF Removing flows start for port: %s.", port_id)
     try:
         sec_br.delete_flows(cookie="%s/-1" %
                             self.get_cookie(port_id))
         if del_provider_rules:
             sec_br.delete_flows(cookie="%s/-1" %
                                 self.get_cookie('pr' + port_id))
         port = self.filtered_ports.get(port_id)
         vlan = self._get_port_vlan(port_id)
         if 'mac_address' not in port or not vlan:
             LOG.debug("Invalid mac address or vlan for port "
                       "%s. Returning from _remove_all_flows.", port_id)
             return
         sec_br.delete_flows(table=ovsvapp_const.SG_LEARN_TABLE_ID,
                             dl_src=port['mac_address'],
                             vlan_tci="0x%04x/0x0fff" % vlan)
         sec_br.delete_flows(table=ovsvapp_const.SG_LEARN_TABLE_ID,
                             dl_dst=port['mac_address'],
                             vlan_tci="0x%04x/0x0fff" % vlan)
         sec_br.delete_flows(table=ovsvapp_const.SG_DEFAULT_TABLE_ID,
                             dl_src=port['mac_address'],
                             vlan_tci="0x%04x/0x0fff" % vlan)
         if del_provider_rules:
             sec_br.delete_flows(table=ovsvapp_const.SG_DEFAULT_TABLE_ID,
                                 dl_dst=port['mac_address'],
                                 vlan_tci="0x%04x/0x0fff" % vlan)
             sec_br.delete_flows(table=ovsvapp_const.SG_EGRESS_TABLE_ID,
                                 dl_src=port['mac_address'],
                                 vlan_tci="0x%04x/0x0fff" % vlan)
     except Exception:
         LOG.exception(_LE("Unable to remove flows %s."), port['id'])
开发者ID:openstack,项目名称:networking-vsphere,代码行数:33,代码来源:ovs_firewall.py

示例9: delete_network_postcommit

 def delete_network_postcommit(self, context):
     network = context.current
     segments = context.network_segments
     vxlan_segments = []
     if segments:
         for segment in segments:
             if segment[api.NETWORK_TYPE] in self.supported_network_types:
                 vxlan_segments.append(segment)
     if not vxlan_segments:
         return
     try:
         stale_entries = ovsvapp_db.get_stale_local_vlans_for_network(
             network['id'])
         if stale_entries:
             for (vcenter, cluster, lvid) in stale_entries:
                 network_info = {'vcenter_id': vcenter,
                                 'cluster_id': cluster,
                                 'lvid': lvid,
                                 'network_id': network['id']}
                 if len(vxlan_segments) == 1:
                     seg_id = vxlan_segments[0][api.SEGMENTATION_ID]
                     net_type = vxlan_segments[0][api.NETWORK_TYPE]
                     network_info.update({'segmentation_id': seg_id,
                                          'network_type': net_type})
                 LOG.debug("Spawning thread for releasing network "
                           "VNI allocations for %s.", network_info)
                 self.threadpool.spawn_n(self._notify_agent, network_info)
                 LOG.info(_LI("Spawned a thread for releasing network "
                              "vni allocations for network: %s."),
                          network_info)
     except Exception:
         LOG.exception(_LE("Failed checking stale local vlan allocations."))
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:32,代码来源:ovsvapp_mech_driver.py

示例10: clean_port_filters

 def clean_port_filters(self, ports, remove_port=False):
     """Method to remove OVS rules for an existing VM port."""
     LOG.debug("OVSF Cleaning filters for  %s ports.", len(ports))
     if not ports:
         return
     with self.sg_br.deferred() as deferred_sec_br:
         for port_id in ports:
             try:
                 if not self.filtered_ports.get(port_id):
                     LOG.debug("Attempted to remove port filter "
                               "which is not in filtered %s.", port_id)
                     continue
                 if not remove_port:
                     self._remove_all_flows(deferred_sec_br, port_id)
                 else:
                     self._remove_all_flows(deferred_sec_br, port_id, True)
                     if self.provider_port_cache.__contains__(port_id):
                         self.provider_port_cache.remove(port_id)
                     else:
                         LOG.info(_LI("KeyError:Remove requested for "
                                      "port_id not present: %s"),
                                  self.provider_port_cache)
                     self.filtered_ports.pop(port_id, None)
             except Exception:
                 LOG.exception(_LE("Unable to delete flows for"
                                   " %s."), port_id)
开发者ID:openstack,项目名称:networking-vsphere,代码行数:26,代码来源:ovs_firewall.py

示例11: update_port_filter

    def update_port_filter(self, port):
        """Method to update OVS rules for an existing VM port."""
        LOG.debug("OVSF Updating port: %s filter.", port['id'])
        if port['id'] not in self.filtered_ports:
            LOG.warning(_LW("Attempted to update port filter which is not "
                            "filtered %s."), port['id'])
            return
        port_cookie = self.get_cookie(port['id'])
        port_provider_cookie = self.get_cookie('pr' + port['id'])
        try:
            with self.sg_br.deferred(full_ordered=True, order=(
                'del', 'mod', 'add')) as deferred_br:
                if port['id'] not in self.provider_port_cache:
                    self._remove_all_flows(deferred_br, port['id'], True)
                    self._add_flows(deferred_br, port,
                                    port_provider_cookie, True)
                    self.provider_port_cache.add(port['id'])
#                else:
#                    self._remove_all_flows(deferred_br, port['id'])
                self._setup_aap_flows(deferred_br, port)
                self._add_flows(deferred_br, port, port_cookie)
                if 'security_group_rules_deleted' in port:
                    self._remove_flows(deferred_br, port, port_cookie)

            self.filtered_ports[port['id']] = self._get_compact_port(port)
        except Exception:
            LOG.exception(_LE("Unable to update flows for %s."), port['id'])
开发者ID:openstack,项目名称:networking-vsphere,代码行数:27,代码来源:ovs_firewall.py

示例12: update_ovsvapp_mitigated_cluster

 def update_ovsvapp_mitigated_cluster(self, context, id,
                                      ovsvapp_mitigated_cluster):
     _admin_check(context, 'UPDATE')
     res_dict = ovsvapp_mitigated_cluster['ovsvapp_mitigated_cluster']
     vcenter_id = res_dict['vcenter_id']
     cluster_id = res_dict['cluster_id']
     update_flags = dict()
     if 'being_mitigated' in res_dict:
         update_flags['being_mitigated'] = res_dict['being_mitigated']
     if 'threshold_reached' in res_dict:
         update_flags['threshold_reached'] = res_dict['threshold_reached']
     LOG.error(_LE("Updating the mitigation properties with "
                   "vCenter id %s."),
               vcenter_id)
     with context.session.begin(subtransactions=True):
         try:
             query = context.session.query(models.OVSvAppClusters)
             cluster_row = (query.filter(
                 models.OVSvAppClusters.vcenter_id == vcenter_id,
                 models.OVSvAppClusters.cluster_id == cluster_id
             ).with_lockmode('update').one())
             cluster_row.update(update_flags)
         except sa_exc.NoResultFound:
             _msg = ("No entry found for specified vCenter %(vcenter_id)s"
                     " cluster %(cluster_id)s") % {'vcenter_id': vcenter_id,
                                                   'cluster_id': cluster_id}
             raise exc.InvalidInput(error_message=_msg)
     return res_dict
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:28,代码来源:ovsvapp_db.py

示例13: remove_stale_port_flows

    def remove_stale_port_flows(self, port_id, mac_address, vlan):
        """Remove all flows for a port."""

        LOG.debug("OVSF Removing flows for stale port: %s.", port_id)
        with self.sg_br.deferred() as deferred_sec_br:
            try:
                deferred_sec_br.delete_flows(cookie="%s/-1" %
                                             self.get_cookie(port_id))
                deferred_sec_br.delete_flows(cookie="%s/-1" %
                                             self.get_cookie('pr' + port_id))
                deferred_sec_br.delete_flows(
                    table=ovsvapp_const.SG_LEARN_TABLE_ID,
                    dl_src=mac_address,
                    dl_vlan=vlan)
                deferred_sec_br.delete_flows(
                    table=ovsvapp_const.SG_LEARN_TABLE_ID,
                    dl_dst=mac_address,
                    dl_vlan=vlan)
                deferred_sec_br.delete_flows(
                    table=ovsvapp_const.SG_LEARN_TABLE_ID,
                    dl_src=mac_address,
                    dl_vlan=vlan)
                deferred_sec_br.delete_flows(
                    table=ovsvapp_const.SG_LEARN_TABLE_ID,
                    dl_dst=mac_address,
                    dl_vlan=vlan)
                deferred_sec_br.delete_flows(
                    table=ovsvapp_const.SG_LEARN_TABLE_ID,
                    dl_src=mac_address,
                    dl_vlan=vlan)
            except Exception:
                LOG.exception(_LE("OVSF unable to remove flows for port: "
                                  "%s."), port_id)
开发者ID:openstack,项目名称:networking-vsphere,代码行数:33,代码来源:ovs_firewall.py

示例14: release_local_vlan

def release_local_vlan(net_info):
    session = db_api.get_session()
    with session.begin(subtransactions=True):
        res_keys = ['vcenter_id', 'cluster_id', 'network_id']
        res = dict((k, net_info[k]) for k in res_keys)
        try:
            query = session.query(models.ClusterVNIAllocations)
            allocation = (query.filter(
                models.ClusterVNIAllocations.vcenter_id == res['vcenter_id'],
                models.ClusterVNIAllocations.cluster_id == res['cluster_id'],
                models.ClusterVNIAllocations.network_id == res['network_id']
            ).with_lockmode('update').one())
            if allocation.network_port_count == 0:
                allocation.update({'network_id': None,
                                   'allocated': False,
                                   'network_port_count': 0})
                LOG.info(_LI("Released lvid for network: %s."), res)
            else:
                LOG.info(_LI("Unable to release local vlan for network_id %s "
                             "because ports are available on network."),
                         res['network_id'])
        except sa_exc.NoResultFound:
            # Nothing to do, may be another controller cleared the record
            # We will just log and return.
            LOG.error(_LE("Network %(network)s is already de-allocated for "
                          "cluster %(cluster)s."),
                      {'network': net_info['network_id'],
                       'cluster': net_info['cluster_id']})
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:28,代码来源:ovsvapp_db.py

示例15: create_network_map_from_config

def create_network_map_from_config(config, pg_cache=False):
    """Creates physical network to dvs map from config"""
    connection = None
    while not connection:
        try:
            connection = api.VMwareAPISession(
                host=config.vsphere_hostname,
                port=config.host_port,
                server_username=config.vsphere_login,
                server_password=config.vsphere_password,
                api_retry_count=config.api_retry_count,
                task_poll_interval=config.task_poll_interval,
                scheme='https',
                create_session=True,
                cacert=config.ca_file,
                insecure=config.insecure,
                pool_size=config.connections_pool_size)
        except ConnectionError:
            LOG.error(_LE("No connection to vSphere. Retry in 10 sec..."))
            sleep(10)
    network_map = {}
    controller_class = DVSControllerWithCache if pg_cache else DVSController
    for pair in config.network_maps:
        network, dvs = pair.split(':')
        network_map[network] = controller_class(dvs, config.cluster_name,
                                                connection)
    return network_map
开发者ID:Mirantis,项目名称:vmware-dvs,代码行数:27,代码来源:dvs_util.py


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