Skip to content

Commit

Permalink
read_topology_hna: be more resistant to errors in topology files
Browse files Browse the repository at this point in the history
  • Loading branch information
cl4u2 authored and lorenzobracciale committed Sep 4, 2014
1 parent f874113 commit 61d6a1c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions nodeshot/scripts/read_topology_hna.py
Expand Up @@ -104,11 +104,15 @@ def parse(self):
ipaddr1, ipaddr2, hyst, lq, nlq, etx = line.split()
print("Link: %s <--[%s]--> %s" % (ipaddr1, etx, ipaddr2))
self.linklist.append((ipaddr1, ipaddr2, float(etx)))
self.linklist.append((ipaddr2, ipaddr1, float(etx)))
except ValueError:
print ("wrong line or INFINITE ETX: %s" % line)
pass
i+=1
line = self.topologylines[i]
if i < len(self.topologylines):
line = self.topologylines[i]
else:
return

topologytablefound = True
while line.find('Table: Topology') == -1:
Expand All @@ -130,11 +134,15 @@ def parse(self):
ipaddr1, ipaddr2, lq, nlq, etx = line.split()
print("Link: %s --[%s]--> %s" % (ipaddr1, etx, ipaddr2))
self.linklist.append((ipaddr1, ipaddr2, float(etx)))
self.linklist.append((ipaddr2, ipaddr1, float(etx)))
except ValueError:
print ("wrong line or INFINITE ETX: %s" % line)
pass
i+=1
line = self.topologylines[i]
if i < len(self.topologylines):
line = self.topologylines[i]
else:
return

j = i + 1
# parse HNA info
Expand All @@ -154,7 +162,10 @@ def parse(self):
except ValueError:
pass
i+=1
line = self.topologylines[i]
if i < len(self.topologylines):
line = self.topologylines[i]
else:
return
else:
i = j

Expand All @@ -179,7 +190,10 @@ def parse(self):
except ValueError:
pass
i+=1
line = self.topologylines[i]
if i < len(self.topologylines):
line = self.topologylines[i]
else:
return

#debug
#print self.linklist
Expand Down

0 comments on commit 61d6a1c

Please sign in to comment.