Enhance wsgi to listen on ipv6 address

* Check if the hostname is ipv6 and set the family appropriately
* Add test case for wsgi.Server and service.WSGIService

Change-Id: I6edd467467fa3d623d62e146750b3a6c42d8833c
This commit is contained in:
Davanum Srinivas
2013-01-09 11:41:18 -05:00
parent bb6c50ebf7
commit cf5df6e371

View File

@@ -20,6 +20,7 @@
"""Utility methods for working with WSGI servers."""
import os.path
import socket
import sys
import eventlet
@@ -82,8 +83,14 @@ class Server(object):
raise exception.InvalidInput(
reason='The backlog must be more than 1')
self._socket = eventlet.listen((host, port), backlog=backlog)
(self.host, self.port) = self._socket.getsockname()
try:
socket.inet_pton(socket.AF_INET6, host)
family = socket.AF_INET6
except Exception:
family = socket.AF_INET
self._socket = eventlet.listen((host, port), family, backlog=backlog)
(self.host, self.port) = self._socket.getsockname()[0:2]
LOG.info(_("%(name)s listening on %(host)s:%(port)s") % self.__dict__)
def start(self):