Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cyrillkuettel/6d7ffc6f6c37c8148b0affb76ba1af37 to your computer and use it in GitHub Desktop.
Save cyrillkuettel/6d7ffc6f6c37c8148b0affb76ba1af37 to your computer and use it in GitHub Desktop.
import jnettool.tools.elements.NetworkElement
import jnettool.tools.Routing
import jnettool.tools.RouteInsector
ne = jnettool.tools.elements.NetworkElement('171.0.2.45')
try:
routing_table = ne.getRoutingTable()
except jnettool.tools.elements.MissingVar:
logging.exception('No routing table found')
ne.cleanup('rollback')
else:
num_routes = routing_table.getSize()
for RToffset in range(num_routes):
route = routing_table.getRouteByIndex(RToffset)
name = route.getName()
ipaddr = route.getIPAddr()
print "%15s -> %s" % (name, ipaddr)
finally:
ne.cleanup('commit')
ne.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment