Commit 6d7769d4 authored by Philip ABBET's avatar Philip ABBET
Browse files

Fix the host ip address determination

parent 224ac477
Pipeline #5781 failed with stage
in 3 minutes and 13 seconds
......@@ -45,15 +45,6 @@ from . import dock
from . import baseformat
def get_network_ip_address(host_address):
'''Returns the most sensible network IP address given a host address'''
import socket
import difflib
possible_addresses = socket.gethostbyname_ex(socket.gethostname())[2]
return difflib.get_close_matches(host_address, possible_addresses, cutoff=0)[0]
class Server(gevent.Greenlet):
'''A 0MQ server for our communication with the user process'''
......@@ -69,7 +60,7 @@ class Server(gevent.Greenlet):
self.context = zmq.Context()
self.socket = self.context.socket(zmq.PAIR)
self.address = 'tcp://' + get_network_ip_address(host_address)
self.address = 'tcp://' + host_address
port = self.socket.bind_to_random_port(self.address)
self.address += ':%d' % port
logger.debug("zmq server bound to `%s'", self.address)
......
......@@ -39,6 +39,7 @@ import six
import docker
import requests
import simplejson
import socket
from . import stats
......@@ -107,8 +108,9 @@ class Host(object):
@property
def ip(self):
'''The IP address of the docker host'''
return '127.0.0.1'
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 0)) # connecting to a UDP address doesn't send packets
return s.getsockname()[0]
def _discover_environments(self, raise_on_errors=True):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment