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:
11
nova/wsgi.py
11
nova/wsgi.py
@@ -20,6 +20,7 @@
|
|||||||
"""Utility methods for working with WSGI servers."""
|
"""Utility methods for working with WSGI servers."""
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@@ -82,8 +83,14 @@ class Server(object):
|
|||||||
raise exception.InvalidInput(
|
raise exception.InvalidInput(
|
||||||
reason='The backlog must be more than 1')
|
reason='The backlog must be more than 1')
|
||||||
|
|
||||||
self._socket = eventlet.listen((host, port), backlog=backlog)
|
try:
|
||||||
(self.host, self.port) = self._socket.getsockname()
|
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__)
|
LOG.info(_("%(name)s listening on %(host)s:%(port)s") % self.__dict__)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user