Skip to content

Commit d7eb828

Browse files
authored
fix(opennebula): coerce MTU to int in gen_conf() (#6856)
ONE_CONTEXT passes ETHx_MTU as a string, but Netplan's network-config-v2 schema requires mtu to be an integer. Without this, cloud-init schema validation fails with "'1500' is not of type 'integer'".
1 parent 18c8830 commit d7eb828

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cloudinit/sources/DataSourceOpenNebula.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def gen_conf(self) -> Dict[str, Any]:
302302
# Set MTU size
303303
mtu = self.get_mtu(c_dev)
304304
if mtu:
305-
devconf["mtu"] = mtu
305+
devconf["mtu"] = int(mtu)
306306

307307
ethernets[dev] = devconf
308308

tests/unittests/sources/test_opennebula.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def test_gen_conf_mtu(self, m_get_phys_by_mac):
789789
"version": 2,
790790
"ethernets": {
791791
nic: {
792-
"mtu": "1280",
792+
"mtu": 1280,
793793
"match": {"macaddress": MACADDR},
794794
"addresses": [IP_BY_MACADDR + "/" + IP4_PREFIX],
795795
}
@@ -898,7 +898,7 @@ def test_eth0_v4v6_override(self):
898898
"addresses": ["1.2.3.6", "1.2.3.7", "1.2.3.8"],
899899
"search": ["example.com", "example.org"],
900900
},
901-
"mtu": "1280",
901+
"mtu": 1280,
902902
}
903903
},
904904
}
@@ -959,7 +959,7 @@ def test_multiple_nics(self):
959959
"addresses": ["1.2.3.6", "1.2.3.7", "1.2.3.8"],
960960
"search": ["example.com"],
961961
},
962-
"mtu": "1280",
962+
"mtu": 1280,
963963
},
964964
"enp0s25": {
965965
"match": {"macaddress": MAC_1},

0 commit comments

Comments
 (0)