You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The resolve_networks function contains incorrect logic for replacing network variable placeholders with their corresponding network IDs. The current implementation uses the first key in the network hash, which can lead to incorrect substitutions if the key order does not match.
To Reproduce
Steps to reproduce the behavior:
Create a template with vm_template_contents containing network variable placeholders (e.g., $CUSTOM1_VAR).
Define networks_values with multiple network entries.
Execute the resolve_networks function with the template.
Observe that the variable placeholders might be replaced with incorrect network IDs due to key order mismatch.
Expected behavior
The variable placeholders in vm_template_contents should be replaced with the correct network IDs based on the matching keys.
Details
Affected Component: OneFlow
Hypervisor: KVM
Version: Current development version
Additional context
In continuation of PR #6522 (Fix flow key order hardcode), there were changes made in commit 0d1ac37583a43bac6454c3e939fa014e7672c3d2, but the resolve_networks function was not updated. The current logic in the resolve_networks function is incorrect and should be updated for better accuracy.
In the current implementation, net[net.keys[0]] is used to get the network value. This approach can lead to incorrect results if the order of keys in net does not match key[0].
Description
The
resolve_networks
function contains incorrect logic for replacing network variable placeholders with their corresponding network IDs. The current implementation uses the first key in the network hash, which can lead to incorrect substitutions if the key order does not match.To Reproduce
Steps to reproduce the behavior:
Example in OpenNebula/terraform-provider-opennebula#527
Expected behavior
The variable placeholders in
vm_template_contents
should be replaced with the correct network IDs based on the matching keys.Details
Additional context
In continuation of PR #6522 (Fix flow key order hardcode), there were changes made in commit 0d1ac37583a43bac6454c3e939fa014e7672c3d2, but the resolve_networks function was not updated. The current logic in the resolve_networks function is incorrect and should be updated for better accuracy.
Current Logic:
In the current implementation,
![image](https://private-user-images.githubusercontent.com/1240425/332601361-d8f6c12b-6094-4cc4-9336-b089e843985d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NjYzMTIsIm5iZ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MTdUMDM0MDEyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGViMGU0Zjc1MTc5MTkyNWRiN2Q3Y2ZlMzBhNmU4ZmM4ZjFhNWE0ZDdlMWY0ZjQwYzhkNjUyN2U5ZmQ3MTM1ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.5I2tSTrZ0wDby0VXBxEvtIODBncHHPkSzcArO4ugQJY)
net[net.keys[0]]
is used to get the network value. This approach can lead to incorrect results if the order of keys in net does not match key[0].Suggested Improvement:
By using
net[key[0]]
directly, we ensure that the correct network value corresponding tokey[0]
is used, making the function more reliable.Progress Status
The text was updated successfully, but these errors were encountered: