當前位置: 首頁>>代碼示例>>Python>>正文


Python pyroute2.IPDB屬性代碼示例

本文整理匯總了Python中pyroute2.IPDB屬性的典型用法代碼示例。如果您正苦於以下問題:Python pyroute2.IPDB屬性的具體用法?Python pyroute2.IPDB怎麽用?Python pyroute2.IPDB使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pyroute2的用法示例。


在下文中一共展示了pyroute2.IPDB屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_ipdb

# 需要導入模塊: import pyroute2 [as 別名]
# 或者: from pyroute2 import IPDB [as 別名]
def get_ipdb(netns=None):
    if netns:
        ipdb = pyroute2.IPDB(nl=pyroute2.NetNS(netns))
    else:
        ipdb = pyroute2.IPDB()
    return ipdb 
開發者ID:openstack,項目名稱:zun,代碼行數:8,代碼來源:base.py

示例2: get_ipdb

# 需要導入模塊: import pyroute2 [as 別名]
# 或者: from pyroute2 import IPDB [as 別名]
def get_ipdb(netns=None):
    if netns:
        netns = utils.convert_netns(netns)
        ipdb = pyroute2.IPDB(nl=pyroute2.NetNS(netns))
    else:
        ipdb = pyroute2.IPDB()
    return ipdb 
開發者ID:openstack,項目名稱:kuryr-kubernetes,代碼行數:9,代碼來源:base.py

示例3: liveness_status

# 需要導入模塊: import pyroute2 [as 別名]
# 或者: from pyroute2 import IPDB [as 別名]
def liveness_status(self):
        data = 'ok'
        no_limit = -1
        try:
            with IPDB():
                pass
        except Exception:
            error_message = 'IPDB not in working order.'
            LOG.error(error_message)
            return error_message, httplib.INTERNAL_SERVER_ERROR, self.headers

        if CONF.cni_health_server.max_memory_usage != no_limit:
            mem_usage = _get_memsw_usage(_get_cni_cgroup_path())

            if mem_usage > CONF.cni_health_server.max_memory_usage:
                err_message = 'CNI daemon exceeded maximum memory usage.'
                LOG.error(err_message)
                return err_message, httplib.INTERNAL_SERVER_ERROR, self.headers

        with self._components_healthy.get_lock():
            if not self._components_healthy.value:
                err_message = 'Kuryr CNI components not healthy.'
                LOG.error(err_message)
                return err_message, httplib.INTERNAL_SERVER_ERROR, self.headers

        LOG.debug('Kuryr CNI Liveness verified.')
        return data, httplib.OK, self.headers 
開發者ID:openstack,項目名稱:kuryr-kubernetes,代碼行數:29,代碼來源:health.py

示例4: get_ipdb

# 需要導入模塊: import pyroute2 [as 別名]
# 或者: from pyroute2 import IPDB [as 別名]
def get_ipdb():
    """Returns the already cached or a newly created IPDB instance.

    IPDB reads the Linux specific file when it's instantiated. This behaviour
    prevents Mac OSX users from running unit tests. This function makes the
    loading IPDB lazyily and therefore it can be mocked after the import of
    modules that import this module.

    :returns: The already cached or newly created ``pyroute2.IPDB`` instance
    """
    global _IPDB_CACHE
    if not _IPDB_CACHE:
        _IPDB_CACHE = pyroute2.IPDB()
    return _IPDB_CACHE 
開發者ID:openstack,項目名稱:kuryr,代碼行數:16,代碼來源:utils.py

示例5: _configure_container_iface

# 需要導入模塊: import pyroute2 [as 別名]
# 或者: from pyroute2 import IPDB [as 別名]
def _configure_container_iface(iface, subnets, fixed_ips, mtu=None,
                               hwaddr=None):
    """Configures the interface that is placed in the container net ns

    :param iface:       the pyroute IPDB interface object to configure
    :param subnets:     an iterable of all the Neutron subnets which the
                        endpoint is trying to join
    :param fixed_ips:   an iterable of fixed IPs to be set for the iface
    :param mtu:         Maximum Transfer Unit to set for the iface
    :param hwaddr:      Hardware address to set for the iface
    """
    subnets_dict = {subnet['id']: subnet for subnet in subnets}
    # We assume containers always work with fixed ips, dhcp does not really
    # make a lot of sense
    for fixed_ip in fixed_ips:
        if IP_ADDRESS_KEY in fixed_ip and (SUBNET_ID_KEY in fixed_ip):
            subnet_id = fixed_ip[SUBNET_ID_KEY]
            subnet = subnets_dict[subnet_id]
            cidr = ipaddress.ip_network(six.text_type(subnet['cidr']))
            iface.add_ip(fixed_ip[IP_ADDRESS_KEY], cidr.prefixlen)
    if mtu is not None:
        iface.set_mtu(mtu)
    if hwaddr is not None:
        iface.set_address(hwaddr)
    if not is_up(iface):
        iface.up() 
開發者ID:openstack,項目名稱:kuryr,代碼行數:28,代碼來源:utils.py


注:本文中的pyroute2.IPDB屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。