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

Setting logical interface mtu to be lowest address family mtu #2165

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def _convert_to_dict(interfaces):
# The dictionary values will end up being tuples instead of dictionaries
interfaces = dict(interfaces)
for iface, iface_data in interfaces.items():

result[iface] = {
"is_up": iface_data["is_up"],
# For physical interfaces <admin-status> will always be there, so just
Expand All @@ -459,7 +460,18 @@ def _convert_to_dict(interfaces):

match_mtu = re.search(r"(\w+)", str(iface_data["mtu"]) or "")
mtu = napalm.base.helpers.convert(int, match_mtu.group(0), 0)
result[iface]["mtu"] = mtu

# For logical interfaces, parsing out each addr family MTU and,
# if they are set, using the lowest value
if "addr_family" in iface_data.keys():
af_mtus = [
napalm.base.helpers.convert(int, af["af_mtu"], mtu)
for af in dict(iface_data["addr_family"]).values()
]
result[iface]["mtu"] = min(af_mtus) if af_mtus else mtu

else:
result[iface]["mtu"] = mtu
match = re.search(r"(\d+|[Aa]uto)(\w*)", iface_data["speed"] or "")
if match and match.group(1).lower() == "auto":
match = re.search(
Expand Down
13 changes: 12 additions & 1 deletion napalm/junos/utils/junos_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@ junos_logical_iface_view:
last_flapped: { ../interface-flapped/@seconds: int }
speed: ../speed
negotiated_speed: ../ethernet-autonegotiation/link-partner-speed
mtu: ../mtu
mac_address: ../current-physical-address
mtu: ../mtu
addr_family: junos_logical_iface_af_table

junos_logical_iface_af_table:
item: address-family
key: address-family-name
view: junos_logical_iface_af_view

junos_logical_iface_af_view:
fields:
af_mtu: mtu


####
#### BGP tables
Expand Down
Loading