mirror of
https://github.com/devplayer0/docker-net-dhcp
synced 2024-11-16 21:28:01 +00:00
Minor fixes
This commit is contained in:
parent
7afa8efbd6
commit
866bb1b5cd
@ -145,21 +145,28 @@ def create_endpoint():
|
||||
.set('state', 'up')
|
||||
.commit())
|
||||
|
||||
time.sleep(0.5)
|
||||
if_container = (ndb.interfaces[if_container]
|
||||
.set('state', 'up')
|
||||
.commit())
|
||||
(bridge
|
||||
.add_port(if_host)
|
||||
.commit())
|
||||
|
||||
res_iface = {
|
||||
'MacAddress': '',
|
||||
'Address': '',
|
||||
'AddressIPv6': ''
|
||||
}
|
||||
|
||||
try:
|
||||
start = time.time()
|
||||
while isinstance(if_container, str) and time.time() - start < 10:
|
||||
try:
|
||||
if_container = (ndb.interfaces[if_container]
|
||||
.set('state', 'up')
|
||||
.commit())
|
||||
except KeyError:
|
||||
time.sleep(0.5)
|
||||
if isinstance(if_container, str):
|
||||
raise NetDhcpError(f'timed out waiting for {if_container} to appear in host')
|
||||
|
||||
(bridge
|
||||
.add_port(if_host)
|
||||
.commit())
|
||||
|
||||
res_iface = {
|
||||
'MacAddress': '',
|
||||
'Address': '',
|
||||
'AddressIPv6': ''
|
||||
}
|
||||
|
||||
if 'MacAddress' in req_iface and req_iface['MacAddress']:
|
||||
(if_container
|
||||
.set('address', req_iface['MacAddress'])
|
||||
@ -199,9 +206,10 @@ def create_endpoint():
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
(bridge
|
||||
.del_port(if_host)
|
||||
.commit())
|
||||
if not isinstance(if_container, str):
|
||||
(bridge
|
||||
.del_port(if_host)
|
||||
.commit())
|
||||
(if_host
|
||||
.remove()
|
||||
.commit())
|
||||
|
@ -67,7 +67,7 @@ class DHCPClient:
|
||||
self._event_queue = posix_ipc.MessageQueue(f'/udhcpc{self._suffix}_{iface["address"].replace(":", "_")}', \
|
||||
flags=os.O_CREAT | os.O_EXCL, max_messages=2, max_message_size=1024)
|
||||
self.proc = Popen(cmdline, env={'EVENT_QUEUE': self._event_queue.name}, stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=close_fds)
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if hostname:
|
||||
logger.debug('[udhcpc%s#%d] using hostname "%s"', self._suffix, self.proc.pid, hostname)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user