ifcfg-rh: reread from disk when adding new connection

This commit is contained in:
Thomas Haller
2017-10-27 10:05:22 +02:00
parent 304bf5563f
commit 8a1d483ca8
2 changed files with 21 additions and 11 deletions

View File

@@ -679,15 +679,16 @@ add_connection (NMSettingsPlugin *config,
{
SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (config);
gs_free char *path = NULL;
gs_unref_object NMConnection *reread = NULL;
if (save_to_disk) {
if (!nms_ifcfg_rh_writer_write_connection (connection, IFCFG_DIR, NULL, &path, NULL, NULL, error))
if (!nms_ifcfg_rh_writer_write_connection (connection, IFCFG_DIR, NULL, &path, &reread, NULL, error))
return NULL;
} else {
if (!nms_ifcfg_rh_writer_can_write_connection (connection, error))
return NULL;
}
return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error));
return NM_SETTINGS_CONNECTION (update_connection (self, reread ?: connection, path, NULL, FALSE, NULL, error));
}
static void

View File

@@ -3094,15 +3094,24 @@ nms_ifcfg_rh_writer_write_connection (NMConnection *connection,
* A better solution might be, to re-read the connection only based on the
* in-memory representation of what we collected above. But the reader
* does not yet allow to inject the configuration. */
if ( (out_reread || out_reread_same)
&& !do_write_reread (connection,
svFileGetName (ifcfg),
out_reread,
out_reread_same,
&local)) {
_LOGW ("write: failure to re-read connection \"%s\": %s",
svFileGetName (ifcfg), local->message);
g_clear_error (&local);
if (out_reread || out_reread_same) {
if (!do_write_reread (connection,
svFileGetName (ifcfg),
out_reread,
out_reread_same,
&local)) {
_LOGW ("write: failure to re-read connection \"%s\": %s",
svFileGetName (ifcfg), local->message);
g_clear_error (&local);
} else {
if ( out_reread_same
&& !*out_reread_same) {
_LOGD ("write: connection %s (%s) was modified by persisting it to \"%s\" ",
nm_connection_get_id (connection),
nm_connection_get_uuid (connection),
svFileGetName (ifcfg));
}
}
}
/* Only return the filename if this was a newly written ifcfg */