diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 281c48032..e9b7ce245 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -23,6 +23,7 @@ import time from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log +from oslo_utils import netutils import pkg_resources from six.moves.urllib import parse as urlparse from stevedore import extension @@ -365,6 +366,10 @@ class IronicPythonAgent(base.ExecuteCommandMixin): LOG.error('Neither ipa-api-url nor inspection_callback_url' 'found, please check your pxe append parameters.') + if netutils.is_ipv6_enabled(): + # Listens to both IP versions, assuming IPV6_V6ONLY isn't enabled, + # (the default behaviour in linux) + simple_server.WSGIServer.address_family = socket.AF_INET6 wsgi = simple_server.make_server( self.listen_address.hostname, self.listen_address.port, diff --git a/ironic_python_agent/api/config.py b/ironic_python_agent/api/config.py index 0b5ee6348..8dc062471 100644 --- a/ironic_python_agent/api/config.py +++ b/ironic_python_agent/api/config.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from ironic_python_agent import netutils + # Server Specific Configurations # See https://pecan.readthedocs.org/en/latest/configuration.html#server-configuration # noqa server = { 'port': '9999', - 'host': '0.0.0.0' + 'host': netutils.get_wildcard_address() } # Pecan Application Configurations diff --git a/ironic_python_agent/config.py b/ironic_python_agent/config.py index 2fccb3a29..8ba972121 100644 --- a/ironic_python_agent/config.py +++ b/ironic_python_agent/config.py @@ -15,6 +15,7 @@ from oslo_config import cfg from ironic_python_agent import inspector +from ironic_python_agent import netutils from ironic_python_agent import utils CONF = cfg.CONF @@ -31,7 +32,9 @@ cli_opts = [ 'The value must start with either http:// or https://.'), cfg.StrOpt('listen_host', - default=APARAMS.get('ipa-listen-host', '0.0.0.0'), + default=APARAMS.get('ipa-listen-host', + netutils.get_wildcard_address()), + sample_default='::', deprecated_name='listen-host', help='The IP address to listen on. ' 'Can be supplied as "ipa-listen-host" kernel parameter.'), diff --git a/ironic_python_agent/netutils.py b/ironic_python_agent/netutils.py index 4d482b69d..45b85a5d7 100644 --- a/ironic_python_agent/netutils.py +++ b/ironic_python_agent/netutils.py @@ -220,3 +220,9 @@ def wrap_ipv6(ip): if netutils.is_valid_ipv6(ip): return "[%s]" % ip return ip + + +def get_wildcard_address(): + if netutils.is_ipv6_enabled(): + return "::" + return "0.0.0.0" diff --git a/ironic_python_agent/tests/functional/base.py b/ironic_python_agent/tests/functional/base.py index 066500a5a..66fd3207f 100644 --- a/ironic_python_agent/tests/functional/base.py +++ b/ironic_python_agent/tests/functional/base.py @@ -24,6 +24,7 @@ from ironic_python_agent import agent # NOTE(lucasagomes): This import is needed so we can register the # configuration options prior to IPA prior to starting the service from ironic_python_agent import config # noqa +from ironic_python_agent import netutils class FunctionalBase(test_base.BaseTestCase): @@ -40,7 +41,8 @@ class FunctionalBase(test_base.BaseTestCase): self.agent = agent.IronicPythonAgent( api_url='http://127.0.0.1:6835', advertise_address=agent.Host('localhost', 9999), - listen_address=agent.Host('0.0.0.0', int(self.test_port)), + listen_address=agent.Host(netutils.get_wildcard_address(), + int(self.test_port)), ip_lookup_attempts=3, ip_lookup_sleep=10, network_interface=None, diff --git a/releasenotes/notes/ipv6-listen-85d40e58156e398f.yaml b/releasenotes/notes/ipv6-listen-85d40e58156e398f.yaml new file mode 100644 index 000000000..4034733a2 --- /dev/null +++ b/releasenotes/notes/ipv6-listen-85d40e58156e398f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - If booted into a kernel that supports IPv6 Ironic Python Agent + now listens for connections on both the IPv4 and IPv6 wildcard + address.