Replace netifaces library
The natifaces library[1] was abandoned more than 3 years ago. Replace it by psutils which is already used by a few other projects. [1] https://github.com/al45tair/netifaces Closes-Bug: #2071596 Change-Id: I805321229e84a57312bbe160d330281e6c13ab97
This commit is contained in:
parent
c2470a21de
commit
7df9a721ef
@ -15,12 +15,14 @@
|
||||
import contextlib
|
||||
import fnmatch
|
||||
import inspect
|
||||
import ipaddress
|
||||
import re
|
||||
import socket
|
||||
import uuid
|
||||
|
||||
from decorator import decorator
|
||||
import jmespath
|
||||
import netifaces
|
||||
import psutil
|
||||
|
||||
from openstack import _log
|
||||
from openstack import exceptions
|
||||
@ -182,14 +184,18 @@ def _get_entity(cloud, resource, name_or_id, filters, **kwargs):
|
||||
def localhost_supports_ipv6():
|
||||
"""Determine whether the local host supports IPv6
|
||||
|
||||
We look for a default route that supports the IPv6 address family,
|
||||
and assume that if it is present, this host has globally routable
|
||||
IPv6 connectivity.
|
||||
We look for the all ip addresses configured to this node, and assume that
|
||||
if any of these is IPv6 address (but not loopback or link local), this host
|
||||
has IPv6 connectivity.
|
||||
"""
|
||||
|
||||
try:
|
||||
return netifaces.AF_INET6 in netifaces.gateways()['default']
|
||||
except AttributeError:
|
||||
for ifname, if_addrs in psutil.net_if_addrs().items():
|
||||
for if_addr in if_addrs:
|
||||
if if_addr.family != socket.AF_INET6:
|
||||
continue
|
||||
addr = ipaddress.ip_address(if_addr.address)
|
||||
if not addr.is_link_local and not addr.is_loopback:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
IPv6 support now is detected according to the IP addresses assigned to all
|
||||
network interfaces, instead of presence of IPv6 default route. In case
|
||||
there is any IP v6 address, which is not loopback or link-local, then
|
||||
the host is considered to support IPv6.
|
@ -5,9 +5,9 @@ iso8601>=0.1.11 # MIT
|
||||
jmespath>=0.9.0 # MIT
|
||||
jsonpatch!=1.20,>=1.16 # BSD
|
||||
keystoneauth1>=3.18.0 # Apache-2.0
|
||||
netifaces>=0.10.4 # MIT
|
||||
os-service-types>=1.7.0 # Apache-2.0
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
platformdirs>=3 # MIT License
|
||||
psutil>=3.2.2 # BSD
|
||||
PyYAML>=3.13 # MIT
|
||||
requestsexceptions>=1.2.0 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user