summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironic_python_agent/agent.py20
-rw-r--r--ironic_python_agent/hardware.py14
-rw-r--r--lower-constraints.txt1
-rw-r--r--requirements.txt1
4 files changed, 21 insertions, 15 deletions
diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py
index c9fe2acc..25a08d59 100644
--- a/ironic_python_agent/agent.py
+++ b/ironic_python_agent/agent.py
@@ -13,6 +13,7 @@
# limitations under the License.
import collections
+import ipaddress
import os
import random
import select
@@ -23,7 +24,6 @@ from wsgiref import simple_server
from ironic_lib import exception as lib_exc
from ironic_lib import mdns
-import netaddr
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
@@ -238,14 +238,22 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
try:
source = out.strip().split('\n')[0].split('src')[1].split()[0]
- if netaddr.IPAddress(source).is_link_local():
- LOG.info('Ignoring link-local source to %(dest)s: %(rec)s',
- {'dest': dest, 'rec': out})
- return
- return source
except IndexError:
LOG.warning('No route to host %(dest)s, route record: %(rec)s',
{'dest': dest, 'rec': out})
+ return
+
+ try:
+ if ipaddress.ip_address(source).is_link_local:
+ LOG.info('Ignoring link-local source to %(dest)s: %(rec)s',
+ {'dest': dest, 'rec': out})
+ return
+ except ValueError as exc:
+ LOG.warning('Invalid IP address %(addr)s returned as a route '
+ 'to host %(dest)s: %(err)s',
+ {'dest': dest, 'addr': source, 'err': exc})
+
+ return source
def set_agent_advertise_addr(self):
"""Set advertised IP address for the agent, if not already set.
diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py
index 79f7ac8f..fd0b3f91 100644
--- a/ironic_python_agent/hardware.py
+++ b/ironic_python_agent/hardware.py
@@ -15,6 +15,7 @@
import abc
import binascii
import functools
+import ipaddress
import json
from multiprocessing.pool import ThreadPool
import os
@@ -24,7 +25,6 @@ import time
from ironic_lib import disk_utils
from ironic_lib import utils as il_utils
-import netaddr
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
@@ -1320,9 +1320,9 @@ class GenericHardwareManager(HardwareManager):
out = out.strip()
try:
- netaddr.IPAddress(out)
- except netaddr.AddrFormatError:
- LOG.warning('Invalid IP address: %s', out)
+ ipaddress.ip_address(out)
+ except ValueError as exc:
+ LOG.warning('Invalid IP address %s: %s', out, exc)
continue
# In case we get 0.0.0.0 on a valid channel, we need to keep
@@ -1397,9 +1397,9 @@ class GenericHardwareManager(HardwareManager):
continue
try:
- return str(netaddr.IPNetwork(address).ip)
- except netaddr.AddrFormatError:
- LOG.warning('Invalid IP address: %s', address)
+ return str(ipaddress.ip_interface(address).ip)
+ except ValueError as exc:
+ LOG.warning('Invalid IP address %s: %s', address, exc)
continue
except (processutils.ProcessExecutionError, OSError) as e:
# Not error, because it's normal in virtual environment
diff --git a/lower-constraints.txt b/lower-constraints.txt
index ddf4e85c..038fffdd 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -37,7 +37,6 @@ mock==2.0.0
monotonic==1.4
mox3==0.25.0
msgpack==0.5.6
-netaddr==0.7.18
netifaces==0.10.4
openstackdocstheme==1.20.0
os-client-config==1.29.0
diff --git a/requirements.txt b/requirements.txt
index 77b1c153..47e6c6b1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,6 @@
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
-netaddr>=0.7.18 # BSD
netifaces>=0.10.4 # MIT
oslo.config>=5.2.0 # Apache-2.0
oslo.concurrency>=3.26.0 # Apache-2.0