daemon: Wait longer for EMANE network interfaces to exist.

When EMANE is still running.
This commit is contained in:
Tom Goff 2016-10-12 17:37:27 +00:00
parent 6d1b5d28a1
commit b1beff1eba
2 changed files with 29 additions and 1 deletions

View file

@ -1153,6 +1153,22 @@ class Emane(ConfigurableManager):
self.session.sdt.updatenodegeo(node.objid, lat, long, alt)
return True
def emanerunning(self, node):
'''\
Return True if an EMANE process associated with the given node
is running, False otherwise.
'''
status = -1
cmd = ['pkill', '-0', '-x', 'emane']
try:
if self.version < self.EMANE092:
status = subprocess.call(cmd)
else:
status = node.cmd(cmd, wait=True)
except:
pass
return status == 0
def emane_version():
'Return the locally installed EMANE version identifier and string.'
cmd = ('emane', '--version')

View file

@ -116,7 +116,19 @@ class TunTap(PyCoreNetIf):
def nodedevexists():
cmd = (IP_BIN, 'link', 'show', self.name)
return self.node.cmd(cmd)
count = 0
while True:
try:
self.waitfor(nodedevexists)
break
except RuntimeError:
# check if this is an EMANE interface; if so, continue
# waiting if EMANE is still running
if count < 5 and isinstance(self.net, EmaneNode) and \
self.node.session.emane.emanerunning(self.node):
count += 1
else:
raise
def install(self):
''' Install this TAP into its namespace. This is not done from the