本文整理匯總了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
示例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
示例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
示例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
示例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()