Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetching MAC address table in junos #895

Merged
Merged
Show file tree
Hide file tree
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
27 changes: 16 additions & 11 deletions napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,19 +1547,24 @@ def get_mac_address_table(self):
"""Return the MAC address table."""
mac_address_table = []

if self.device.facts.get("personality", "") in [
"SWITCH"
]: # for EX & QFX devices
if self.device.facts.get("switch_style", "") in [
"VLAN_L2NG"
]: # for L2NG devices
mac_table = junos_views.junos_mac_address_table_switch_l2ng(self.device)
else:
mac_table = junos_views.junos_mac_address_table_switch(self.device)
else:
switch_style = self.device.facts.get("switch_style", "")
if switch_style == "VLAN_L2NG":
mac_table = junos_views.junos_mac_address_table_switch_l2ng(self.device)
elif switch_style == "BRIDGE_DOMAIN":
mac_table = junos_views.junos_mac_address_table(self.device)
else: # switch_style == "VLAN"
mac_table = junos_views.junos_mac_address_table_switch(self.device)

try:
mac_table.get()
except RpcError as e:
# Device hasn't got it's l2 subsystem running
# Don't error but just return an empty result
if "l2-learning subsystem" in e.message:
return []
else:
raise

mac_table.get()
mac_table_items = mac_table.items()

default_values = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
personality: MX
switch_style: BRIDGE_DOMAIN

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"interface": "ge-0/0/0.0",
"moves": 0,
"vlan": 1,
"mac": "EC:13:DB:2D:35:DA",
"static": false,
"last_move": 0,
"active": true
},
{
"interface": "ge-0/0/0.0",
"moves": 0,
"vlan": 9,
"mac": "88:5B:DD:3F:3F:80",
"static": false,
"last_move": 0,
"active": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
personality: SWITCH
switch_style: VLAN
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<ethernet-switching-table-information style="extensive">
<ethernet-switching-table style="extensive">
<mac-table-count>18</mac-table-count>
<mac-table-learned>15</mac-table-learned>
<mac-table-persistent>0</mac-table-persistent>
<mac-table-entry style="extensive">
<mac-vlan>default</mac-vlan>
<mac-vlan-tag>1</mac-vlan-tag>
<mac-address>*</mac-address>
<mac-interface>All-members</mac-interface>
<mac-interfaces-list style="flood-list">
<mac-interfaces>ge-0/0/0.0</mac-interfaces>
</mac-interfaces-list>
<mac-type>Flood</mac-type>
<mac-action>Forward</mac-action>
<mac-nexthop>1355</mac-nexthop>
</mac-table-entry>
<mac-table-entry style="extensive">
<mac-vlan>default</mac-vlan>
<mac-vlan-tag>1</mac-vlan-tag>
<mac-address>ec:13:db:2d:35:da</mac-address>
<mac-interface>ge-0/0/0.0</mac-interface>
<mac-interfaces-list>
<mac-interfaces>ge-0/0/0.0</mac-interfaces>
</mac-interfaces-list>
<mac-type>Learn</mac-type>
<mac-age seconds="0">0</mac-age>
<mac-learned-time seconds="902535">1w3d 10:42:15</mac-learned-time>
<mac-action>Forward</mac-action>
<mac-nexthop>1354</mac-nexthop>
</mac-table-entry>
<mac-table-entry style="extensive">
<mac-vlan>vlan9</mac-vlan>
<mac-vlan-tag>9</mac-vlan-tag>
<mac-address>88:5b:dd:3f:3f:80</mac-address>
<mac-interface>ge-0/0/0.0</mac-interface>
<mac-interfaces-list>
<mac-interfaces>ge-0/0/0.0</mac-interfaces>
</mac-interfaces-list>
<mac-type>Learn</mac-type>
<mac-age seconds="0">0</mac-age>
<mac-learned-time seconds="902533">1w3d 10:42:13</mac-learned-time>
<mac-action>Forward</mac-action>
<mac-nexthop>1354</mac-nexthop>
</mac-table-entry>
</ethernet-switching-table>
</ethernet-switching-table-information>