当前位置: 首页>>代码示例>>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;未经允许,请勿转载。