Minor fixes

pull/8/head
Jack O'Sullivan 5 years ago
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())
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')
res_iface = {
'MacAddress': '',
'Address': '',
'AddressIPv6': ''
}
(bridge
.add_port(if_host)
.commit())
res_iface = {
'MacAddress': '',
'Address': '',
'AddressIPv6': ''
}
try:
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…
Cancel
Save