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'], \