Created
July 18, 2022 23:13
-
-
Save cyrillkuettel/6d7ffc6f6c37c8148b0affb76ba1af37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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