def main(device_ip, peer_ip): config = ConfigDictionary() username = config.username() password = config.password() print(device_ip + " logging in as " + username) jdev = Device(user=username, host=device_ip, password=password) jdev.open(gather_facts=False) jdev.timeout = 6000 try: resultxml = jdev.rpc.get_route_information(table='inet.0', protocol='bgp', peer=peer_ip, extensive=True) except Exception as err: print "CMD:" etree.dump(err.cmd) print "RSP:" etree.dump(err.rsp) for routexml in resultxml.findall('.//rt'): route = RouteData(routexml) print "destination: " + route.prefix() + "as-path: " + route.aspath() jdev.close()
def main(device_ip, peer_ip): config = ConfigDictionary() username = config.username() password = config.password() print (device_ip + " logging in as " + username) jdev = Device(user=username, host=device_ip, password=password) jdev.open(gather_facts=False) jdev.timeout=6000 try: resultxml = jdev.rpc.get_route_information(table='inet.0',protocol='bgp',peer=peer_ip,extensive=True) except Exception as err: print "CMD:" etree.dump(err.cmd) print "RSP:" etree.dump(err.rsp) for routexml in resultxml.findall('.//rt'): route = RouteData(routexml) print "destination: " + route.prefix() + "as-path: " + route.aspath() jdev.close()
def test_can_obtain_clean_aspath_for_route(self): resultxml = etree.fromstring( open('./tests/test_data/bgp_route.xml').read()) route = RouteData(resultxml.find('.//rt')) self.assertTrue(route.aspath() == '6939 6461 12536')
def test_can_obtain_clean_aspath_for_route(self): resultxml = etree.fromstring(open('./tests/test_data/bgp_route.xml').read()) route = RouteData(resultxml.find('.//rt')) self.assertTrue(route.aspath() == '6939 6461 12536')