From 6a6a105e9a2064f37f22a0326a65a47f906b5e6d Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Thu, 19 Sep 2019 21:03:56 +0100 Subject: [PATCH] Use container hostname instead of container name --- net-dhcp/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net-dhcp/network.py b/net-dhcp/network.py index 892abfd..1a76824 100644 --- a/net-dhcp/network.py +++ b/net-dhcp/network.py @@ -91,10 +91,10 @@ def await_endpoint_container_iface(n, e, timeout=5): raise NetDhcpError('Timed out waiting for container to become availabile') return iface -def endpoint_container_name(n, e): - for info in client.networks.get(n).attrs['Containers'].values(): +def endpoint_container_hostname(n, e): + for cid, info in client.networks.get(n).attrs['Containers'].items(): if info['EndpointID'] == e: - return info['Name'] + return client.containers.get(cid).attrs['Config']['Hostname'] return None @app.route('/NetworkDriver.GetCapabilities', methods=['POST']) @@ -350,7 +350,7 @@ class ContainerDHCPManager: def run(self): try: iface = await_endpoint_container_iface(self.network, self.endpoint) - hostname = endpoint_container_name(self.network, self.endpoint) + hostname = endpoint_container_hostname(self.network, self.endpoint) self.dhcp = udhcpc.DHCPClient(iface, event_listener=self._on_event, hostname=hostname) logger.info('Starting DHCPv4 client on %s in container namespace %s', iface['ifname'], \