Skip to content
This repository was archived by the owner on Feb 10, 2018. It is now read-only.

Commit ce829f7

Browse files
Pshem KowalczykPshem Kowalczyk
Pshem Kowalczyk
authored and
Pshem Kowalczyk
committed
Add ability to view routes in particular table
1 parent 3406130 commit ce829f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

napalm_junos/junos.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,8 @@ def get_mac_address_table(self):
11011101

11021102
return mac_address_table
11031103

1104-
def get_route_to(self, destination='', protocol=''):
1105-
"""Return route details to a specific destination, learned from a certain protocol."""
1104+
def get_route_to(self, destination='', protocol='', table=''):
1105+
"""Return route details to a specific destination, learned from a certain protocol, visible in a particular table."""
11061106
routes = {}
11071107

11081108
if not isinstance(destination, py23_compat.string_types):
@@ -1114,6 +1114,9 @@ def get_route_to(self, destination='', protocol=''):
11141114
if protocol == 'connected':
11151115
protocol = 'direct' # this is how is called on JunOS
11161116

1117+
if table and not isinstance(table, py23_compat.string_types):
1118+
raise TypeError('Please specify a valid table!')
1119+
11171120
_COMMON_PROTOCOL_FIELDS_ = [
11181121
'destination',
11191122
'prefix_length',
@@ -1162,6 +1165,9 @@ def get_route_to(self, destination='', protocol=''):
11621165
if protocol and isinstance(destination, py23_compat.string_types):
11631166
rt_kargs['protocol'] = protocol
11641167

1168+
if table:
1169+
rt_kargs['table'] = table
1170+
11651171
try:
11661172
routes_table.get(**rt_kargs)
11671173
except RpcTimeoutError:

0 commit comments

Comments
 (0)