mirror of
https://github.com/devplayer0/docker-net-dhcp
synced 2024-11-10 13:10:29 +00:00
Use container hostname instead of container name
This commit is contained in:
parent
4072ce8de4
commit
6a6a105e9a
@ -91,10 +91,10 @@ def await_endpoint_container_iface(n, e, timeout=5):
|
|||||||
raise NetDhcpError('Timed out waiting for container to become availabile')
|
raise NetDhcpError('Timed out waiting for container to become availabile')
|
||||||
return iface
|
return iface
|
||||||
|
|
||||||
def endpoint_container_name(n, e):
|
def endpoint_container_hostname(n, e):
|
||||||
for info in client.networks.get(n).attrs['Containers'].values():
|
for cid, info in client.networks.get(n).attrs['Containers'].items():
|
||||||
if info['EndpointID'] == e:
|
if info['EndpointID'] == e:
|
||||||
return info['Name']
|
return client.containers.get(cid).attrs['Config']['Hostname']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@app.route('/NetworkDriver.GetCapabilities', methods=['POST'])
|
@app.route('/NetworkDriver.GetCapabilities', methods=['POST'])
|
||||||
@ -350,7 +350,7 @@ class ContainerDHCPManager:
|
|||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
iface = await_endpoint_container_iface(self.network, self.endpoint)
|
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)
|
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'], \
|
logger.info('Starting DHCPv4 client on %s in container namespace %s', iface['ifname'], \
|
||||||
|
Loading…
Reference in New Issue
Block a user