Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate key names for OpenStack bond properties #5367

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cloudinit/sources/helpers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions tests/unittests/sources/helpers/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
Loading