Ubuntu: Fix networkd config for multiple VLANs without MTU

TypeError: '>' not supported between instances of 'NoneType' and
'NoneType'

Story: 2009013
Task: 42729

Change-Id: I8e25fdc459102ca6e13bd3d38191554ba32c1f48
This commit is contained in:
Mark Goddard 2021-06-29 16:58:42 +01:00
parent e9a3733e24
commit ead017e196
3 changed files with 46 additions and 1 deletions

View File

@ -626,7 +626,8 @@ def networkd_networks(context, names, inventory_hostname=None):
set(bond_member_to_bond)) set(bond_member_to_bond))
for device in implied_vlan_parents: for device in implied_vlan_parents:
vlan_interfaces = interface_to_vlans[device] vlan_interfaces = interface_to_vlans[device]
mtu = max([vlan["mtu"] for vlan in vlan_interfaces]) vlan_mtus = [vlan["mtu"] for vlan in vlan_interfaces if vlan["mtu"]]
mtu = max(vlan_mtus) if vlan_mtus else None
net = _vlan_parent_network(device, mtu, net = _vlan_parent_network(device, mtu,
[vlan["device"] [vlan["device"]
for vlan in vlan_interfaces]) for vlan in vlan_interfaces])

View File

@ -420,6 +420,44 @@ class TestNetworkdNetworks(BaseNetworkdTest):
} }
self.assertEqual(expected, nets) self.assertEqual(expected, nets)
def test_vlan_multiple(self):
# Test the case with multiple VLANs on an implied parent without MTUs.
# https://storyboard.openstack.org/#!/story/2009013
self._update_context({
"net5_interface": "eth0.3",
"net5_vlan": 3})
nets = networkd.networkd_networks(self.context, ["net2", "net5"])
expected = {
"50-kayobe-eth0": [
{
"Match": [
{"Name": "eth0"}
],
},
{
"Network": [
{"VLAN": "eth0.2"},
{"VLAN": "eth0.3"},
]
},
],
"50-kayobe-eth0.2": [
{
"Match": [
{"Name": "eth0.2"}
]
},
],
"50-kayobe-eth0.3": [
{
"Match": [
{"Name": "eth0.3"}
]
},
]
}
self.assertEqual(expected, nets)
def test_vlan_with_parent(self): def test_vlan_with_parent(self):
nets = networkd.networkd_networks(self.context, ["net1", "net2"]) nets = networkd.networkd_networks(self.context, ["net1", "net2"])
expected = { expected = {

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes an issue with systemd-networkd configuration on Ubuntu with multiple
VLAN interfaces. See `story 2009013
<https://storyboard.openstack.org/#!/story/2009013>`__ for details.