From 15196cd66e2311fb5334a8cb64bb63120d89fcf3 Mon Sep 17 00:00:00 2001 From: Curt Moore Date: Tue, 4 Jun 2024 12:45:32 -0500 Subject: [PATCH 1/2] fix: Ensure properties for bonded interfaces are properly translated (#5367) There is a discrepancy between the properties key name formatting in the OpenStack network_data.json and cloudinit network-config.json specifications. Ensure `bond_` is translated to `bond-` when the OpenStack configuration is parsed by cloudinit. Fixes GH-5366 Co-authored-by: Alberto Contreras --- cloudinit/sources/helpers/openstack.py | 9 ++++++++- tests/unittests/sources/helpers/test_openstack.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) 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..663f6c2db3e 100644 --- a/tests/unittests/sources/helpers/test_openstack.py +++ b/tests/unittests/sources/helpers/test_openstack.py @@ -192,9 +192,9 @@ 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", From 0f4082e5e2936a47cb6d0bf9e7da17159903ee0a Mon Sep 17 00:00:00 2001 From: Alberto Contreras Date: Fri, 28 Jun 2024 11:31:43 +0200 Subject: [PATCH 2/2] test: fix unit test openstack vlan mac_address (#5367) After 70f7e78ec2ba75ba6c813413789871c8deeafbcb, mac_address is not rendered for in openstack for network config v1. Fix the unit test to reflect that. --- tests/unittests/sources/helpers/test_openstack.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unittests/sources/helpers/test_openstack.py b/tests/unittests/sources/helpers/test_openstack.py index 663f6c2db3e..7ae164140a0 100644 --- a/tests/unittests/sources/helpers/test_openstack.py +++ b/tests/unittests/sources/helpers/test_openstack.py @@ -200,7 +200,6 @@ def test_bond_mac(self): "type": "bond", }, { - "mac_address": "xx:xx:xx:xx:xx:00", "name": "bond0.123", "subnets": [ {