- alter format to be more flexible to values coming back
- no need for default gateway element
This commit is contained in:
parent
bb334f0ab0
commit
a1efb7ab24
1 changed files with 5 additions and 9 deletions
|
|
@ -312,24 +312,20 @@ class Traceroute(object):
|
||||||
if k == 'default':
|
if k == 'default':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(gws[k]) == 1:
|
for r in gws[k]:
|
||||||
(ip,interface,is_gateway) = gws[k][0]
|
(ip,interface,is_gateway) = r
|
||||||
|
|
||||||
if is_gateway:
|
gw_name = "{0}".format(netifaces.address_families[k])
|
||||||
gw_name = 'default'
|
|
||||||
else: # just use the index value from netifaces
|
|
||||||
gw_name = "{0}".format(k)
|
|
||||||
|
|
||||||
routes.append({
|
routes.append({
|
||||||
gw_name : {
|
gw_name : {
|
||||||
'ip_address' : ip,
|
'ip_address' : ip,
|
||||||
'interface' : interface
|
'interface' : interface,
|
||||||
|
'default' : is_gateway
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
print "Error interpretting network routes. check netifaces output"
|
|
||||||
|
|
||||||
return routes
|
return routes
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue