Skip to content

Commit

Permalink
[networking_mapping] Fix MTU mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
pablintino authored and openshift-merge-bot[bot] committed Jan 19, 2024
1 parent e4a84f1 commit 41b91e2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/net_map/networking_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def vlan(self) -> typing.Union[int, None]:
return self.__vlan

@property
def mtu(self) -> typing.Union[int, None]:
def mtu(self) -> typing.Optional[int]:
"""MTU, if using a non-default value."""
return self.__mtu

Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/net_map/networking_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __map_instance_network(
if device_name and net_def.vlan
else device_name
)
mtu = iface_data.get("mtu", net_def.mtu)
mtu = net_def.mtu if net_def.mtu is not None else iface_data.get("mtu", None)
return networking_env_definitions.MappedInstanceNetwork(
net_def.name,
skip_nm=self.__map_instance_net_skip_nm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
"ip_v4": "172.19.0.37",
"netmask_v4": "255.255.255.0",
"prefix_length_v4": 24,
"mtu": 1500,
"parent_interface": "eth1",
"vlan_id": 22
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"ip_v6": "fd5e:bdb2:6091:9306:0000:0000:0000:0190",
"netmask_v6": "ffff:ffff:ffff:ffff:0000:0000:0000:0000",
"prefix_length_v6": 64,
"mtu": 1500,
"parent_interface": "eth1",
"vlan_id": 21
},
Expand Down Expand Up @@ -192,6 +193,7 @@
"ip_v6": "fd5e:bdb2:6091:9306:0000:0000:0000:0191",
"netmask_v6": "ffff:ffff:ffff:ffff:0000:0000:0000:0000",
"prefix_length_v6": 64,
"mtu": 1500,
"parent_interface": "eth2",
"vlan_id": 21
},
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/module_utils/test_utils/net_map_stub_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
INSTANCE_1_LO_IFACE_DATA = {
"device": "lo",
"macaddress": "27:b9:47:74:b3:00",
"mtu": 65536,
}
INSTANCE_1_ETH0_IFACE_DATA = {
"device": "eth0",
"macaddress": "27:b9:47:74:b3:01",
"mtu": 1500,
}
INSTANCE_1_ETH1_IFACE_DATA = {
"device": "eth1",
"macaddress": INSTANCE_1_MACADDR,
"mtu": 1500,
}
INSTANCE_1_ETH2_IFACE_DATA = {
"device": "eth2",
Expand All @@ -42,36 +45,44 @@
INSTANCE_1_OVS_SYSTEM_IFACE_DATA = {
"device": "ovs-system",
"macaddress": "c0:18:64:65:63:d9",
"mtu": 1500,
}
INSTANCE_2_MACADDR = "a1:69:da:21:aa:03"
INSTANCE_2_LO_IFACE_DATA = {
"device": "lo",
"macaddress": "a1:69:da:21:aa:00",
"mtu": 65536,
}
INSTANCE_2_ETH0_IFACE_DATA = {
"device": "eth0",
"macaddress": "a1:69:da:21:aa:01",
"mtu": 1500,
}
INSTANCE_2_ETH1_IFACE_DATA = {
"device": "eth1",
"macaddress": "a1:69:da:21:aa:02",
"mtu": 1500,
}
INSTANCE_2_ETH2_IFACE_DATA = {
"device": "eth2",
"macaddress": INSTANCE_2_MACADDR,
"mtu": 1500,
}
INSTANCE_2_OVS_SYSTEM_IFACE_DATA = {
"device": "ovs-system",
"macaddress": "61:6f:54:a6:ee:12",
"mtu": 1500,
}
INSTANCE_3_MACADDR = "bf:99:4b:3f:5e:01"
INSTANCE_3_LO_IFACE_DATA = {
"device": "lo",
"macaddress": "bf:99:4b:3f:5e:00",
"mtu": 65536,
}
INSTANCE_3_ETH0_IFACE_DATA = {
"device": "eth0",
"macaddress": INSTANCE_3_MACADDR,
"mtu": 1500,
}
INSTANCE_3_ETH1_IFACE_DATA = {
"device": "eth1",
Expand All @@ -80,10 +91,12 @@
INSTANCE_3_ETH2_IFACE_DATA = {
"device": "eth2",
"macaddress": "bf:99:4b:3f:5e:03",
"mtu": 1500,
}
INSTANCE_3_OVS_SYSTEM_IFACE_DATA = {
"device": "ovs-system",
"macaddress": "1a:36:eb:a9:fc:33",
"mtu": 1500,
}
GROUP_ALL_NAME = "all"
GROUP_1_NAME = "group-1"
Expand Down

0 comments on commit 41b91e2

Please sign in to comment.