Skip to content

Commit

Permalink
Add filters for get_arp_table
Browse files Browse the repository at this point in the history
Refers to #48
  • Loading branch information
Łukasz Kostka committed Dec 29, 2017
1 parent ef11560 commit a0bf527
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions napalm_ros/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ def get_interfaces_counters(self):

return result

def get_arp_table(self):
def get_arp_table(self, ip=None, mac=None, interface=None):
arp_table = []
for entry in self.api('/ip/arp/print'):
params = {
'address': ip,
'interface': interface,
'mac-address': mac
}
params = tuple('?={}={}'.format(key, val) for key, val in params.items() if val)
for entry in self.api.query('/ip/arp/print', *params):
if 'mac-address' not in entry:
continue
arp_table.append(
Expand Down
4 changes: 4 additions & 0 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def __call__(self, command, **kwargs):
full_path = self.find_file(self.sanitize_text(command) + '.json')
return tuple(self.read_json_file(full_path)['data'])

def query(self, command, *args):
full_path = self.find_file(self.sanitize_text(command) + '.json')
return tuple(self.read_json_file(full_path)['data'])

def close(self):
pass

Expand Down

0 comments on commit a0bf527

Please sign in to comment.