diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py index 69a35db7241..70998dda2ee 100644 --- a/cloudinit/sources/helpers/openstack.py +++ b/cloudinit/sources/helpers/openstack.py @@ -672,7 +672,14 @@ def convert_net_json(network_json=None, known_macs=None): if k == "bond_links": continue elif k.startswith("bond"): - params.update({k: v}) + # There is a difference in key name formatting for + # bond parameters in the cloudinit and OpenStack + # network schemas. The keys begin with 'bond-' in the + # cloudinit schema but 'bond_' in OpenStack + # network_data.json schema. Translate them to what + # is expected by cloudinit. + translated_key = "bond-{}".format(k.split("bond_", 1)[-1]) + params.update({translated_key: v}) # openstack does not provide a name for the bond. # they do provide an 'id', but that is possibly non-sensical. diff --git a/tests/unittests/sources/helpers/test_openstack.py b/tests/unittests/sources/helpers/test_openstack.py index 312d66a0186..7ae164140a0 100644 --- a/tests/unittests/sources/helpers/test_openstack.py +++ b/tests/unittests/sources/helpers/test_openstack.py @@ -192,15 +192,14 @@ def test_bond_mac(self): "name": "bond0", "mac_address": "xx:xx:xx:xx:xx:00", "params": { - "bond_miimon": 100, - "bond_mode": "802.3ad", - "bond_xmit_hash_policy": "layer3+4", + "bond-miimon": 100, + "bond-mode": "802.3ad", + "bond-xmit_hash_policy": "layer3+4", }, "subnets": [], "type": "bond", }, { - "mac_address": "xx:xx:xx:xx:xx:00", "name": "bond0.123", "subnets": [ {