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

Add ability to view routes in a particular table #157

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions napalm_junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,8 @@ def get_mac_address_table(self):

return mac_address_table

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

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

if vrf and not isinstance(vrf, py23_compat.string_types):
raise TypeError('Please specify a valid vrf!')

_COMMON_PROTOCOL_FIELDS_ = [
'destination',
'prefix_length',
Expand Down Expand Up @@ -1162,6 +1165,10 @@ def get_route_to(self, destination='', protocol=''):
if protocol and isinstance(destination, py23_compat.string_types):
rt_kargs['protocol'] = protocol

#table is (almost) a vrf
if vrf:
rt_kargs['table'] = vrf

try:
routes_table.get(**rt_kargs)
except RpcTimeoutError:
Expand Down