Agent: Listen for connections on both IPv4 and IPv6 ports

Allow connections if deploying over a IPv6 network.

Change-Id: Ied2f6be4aa4d1a70524df1df3506e596f6926e5b
Closes-Bug: #1650539
This commit is contained in:
Derek Higgins 2016-12-16 13:28:11 +00:00
parent 51ab461af8
commit b4e41e2dd2
6 changed files with 26 additions and 3 deletions

View File

@ -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,

View File

@ -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

View File

@ -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.'),

View File

@ -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"

View File

@ -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,

View File

@ -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.