Skip to content

Commit b4e41e2

Browse files
committed
Agent: Listen for connections on both IPv4 and IPv6 ports
Allow connections if deploying over a IPv6 network. Change-Id: Ied2f6be4aa4d1a70524df1df3506e596f6926e5b Closes-Bug: #1650539
1 parent 51ab461 commit b4e41e2

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

ironic_python_agent/agent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from oslo_concurrency import processutils
2424
from oslo_config import cfg
2525
from oslo_log import log
26+
from oslo_utils import netutils
2627
import pkg_resources
2728
from six.moves.urllib import parse as urlparse
2829
from stevedore import extension
@@ -365,6 +366,10 @@ def run(self):
365366
LOG.error('Neither ipa-api-url nor inspection_callback_url'
366367
'found, please check your pxe append parameters.')
367368

369+
if netutils.is_ipv6_enabled():
370+
# Listens to both IP versions, assuming IPV6_V6ONLY isn't enabled,
371+
# (the default behaviour in linux)
372+
simple_server.WSGIServer.address_family = socket.AF_INET6
368373
wsgi = simple_server.make_server(
369374
self.listen_address.hostname,
370375
self.listen_address.port,

ironic_python_agent/api/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from ironic_python_agent import netutils
16+
1517
# Server Specific Configurations
1618
# See https://pecan.readthedocs.org/en/latest/configuration.html#server-configuration # noqa
1719
server = {
1820
'port': '9999',
19-
'host': '0.0.0.0'
21+
'host': netutils.get_wildcard_address()
2022
}
2123

2224
# Pecan Application Configurations

ironic_python_agent/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from oslo_config import cfg
1616

1717
from ironic_python_agent import inspector
18+
from ironic_python_agent import netutils
1819
from ironic_python_agent import utils
1920

2021
CONF = cfg.CONF
@@ -31,7 +32,9 @@
3132
'The value must start with either http:// or https://.'),
3233

3334
cfg.StrOpt('listen_host',
34-
default=APARAMS.get('ipa-listen-host', '0.0.0.0'),
35+
default=APARAMS.get('ipa-listen-host',
36+
netutils.get_wildcard_address()),
37+
sample_default='::',
3538
deprecated_name='listen-host',
3639
help='The IP address to listen on. '
3740
'Can be supplied as "ipa-listen-host" kernel parameter.'),

ironic_python_agent/netutils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,9 @@ def wrap_ipv6(ip):
220220
if netutils.is_valid_ipv6(ip):
221221
return "[%s]" % ip
222222
return ip
223+
224+
225+
def get_wildcard_address():
226+
if netutils.is_ipv6_enabled():
227+
return "::"
228+
return "0.0.0.0"

ironic_python_agent/tests/functional/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# NOTE(lucasagomes): This import is needed so we can register the
2525
# configuration options prior to IPA prior to starting the service
2626
from ironic_python_agent import config # noqa
27+
from ironic_python_agent import netutils
2728

2829

2930
class FunctionalBase(test_base.BaseTestCase):
@@ -40,7 +41,8 @@ def setUp(self):
4041
self.agent = agent.IronicPythonAgent(
4142
api_url='http://127.0.0.1:6835',
4243
advertise_address=agent.Host('localhost', 9999),
43-
listen_address=agent.Host('0.0.0.0', int(self.test_port)),
44+
listen_address=agent.Host(netutils.get_wildcard_address(),
45+
int(self.test_port)),
4446
ip_lookup_attempts=3,
4547
ip_lookup_sleep=10,
4648
network_interface=None,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- If booted into a kernel that supports IPv6 Ironic Python Agent
4+
now listens for connections on both the IPv4 and IPv6 wildcard
5+
address.

0 commit comments

Comments
 (0)