mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 20:50:19 +01:00
ovs: ensure existing "external-ids" get updated during reapply
"mutate" with operation "insert" does not update existing entries. Delete them first. Otherwise, a reapply that only change the value of an external-ids entry does not work. Note that https://www.rfc-editor.org/rfc/rfc7047 says about "<mutations>": If <mutator> is "insert", then each of the key-value pairs in the map in <value> is added to <column> only if its key is not already present. The required type of <value> is slightly relaxed, in that it may have fewer than the minimum number of elements specified by the column's type. Fixes:7055539c9f('core/ovs: support setting OVS external-ids') (cherry picked from commitd219527dba)
This commit is contained in:
parent
621b20fba2
commit
c3e1290e36
1 changed files with 14 additions and 13 deletions
|
|
@ -714,26 +714,27 @@ _j_create_external_ids_array_update(const char *connection_uuid,
|
|||
|
||||
mutations = json_array();
|
||||
|
||||
array = json_array();
|
||||
if (exid_old) {
|
||||
array = NULL;
|
||||
g_hash_table_iter_init(&iter, exid_old);
|
||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
||||
if (nm_g_hash_table_contains(exid_new, key))
|
||||
continue;
|
||||
if (NM_STR_HAS_PREFIX(key, NM_OVS_EXTERNAL_ID_NM_PREFIX))
|
||||
continue;
|
||||
|
||||
if (!array)
|
||||
array = json_array();
|
||||
|
||||
json_array_append_new(array, json_string(key));
|
||||
}
|
||||
if (array) {
|
||||
json_array_append_new(
|
||||
mutations,
|
||||
json_pack("[s, s, [s, o]]", "external_ids", "delete", "set", array));
|
||||
}
|
||||
if (exid_new) {
|
||||
g_hash_table_iter_init(&iter, exid_new);
|
||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
||||
if (nm_g_hash_table_contains(exid_old, key))
|
||||
continue;
|
||||
json_array_append_new(array, json_string(key));
|
||||
}
|
||||
}
|
||||
if (!nm_g_hash_table_contains(exid_old, NM_OVS_EXTERNAL_ID_NM_PREFIX)
|
||||
&& !nm_g_hash_table_contains(exid_new, NM_OVS_EXTERNAL_ID_NM_PREFIX)) {
|
||||
json_array_append_new(array, json_string(NM_OVS_EXTERNAL_ID_NM_PREFIX));
|
||||
}
|
||||
json_array_append_new(mutations,
|
||||
json_pack("[s, s, [s, o]]", "external_ids", "delete", "set", array));
|
||||
|
||||
array = json_array();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue