Commit 9a532db1 authored by Dan Winship's avatar Dan Winship

cli: add "nmcli con load file..."

https://bugzilla.gnome.org/show_bug.cgi?id=709830
parent a52ebc74
......@@ -227,7 +227,8 @@ usage (void)
" modify [ id | uuid | path ] <ID> <setting>.<property> <value>\n\n"
" edit [ id | uuid | path ] <ID> | [type <new_con_type>] [con-name <new_con_name>]\n\n"
" delete [ id | uuid | path ] <ID>\n\n"
" reload\n\n\n"
" reload\n\n"
" load <filename> [ <filename>... ]\n\n\n"
));
}
......@@ -313,6 +314,7 @@ static const char *real_con_commands[] = {
"edit",
"delete",
"reload",
"load",
NULL
};
......@@ -7262,6 +7264,50 @@ do_connection_reload (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
static NMCResultCode
do_connection_load (NmCli *nmc, int argc, char **argv)
{
GError *error = NULL;
char **filenames, **failures = NULL;
int i;
nmc->return_value = NMC_RESULT_SUCCESS;
nmc->should_wait = FALSE;
if (!nm_client_get_manager_running (nmc->client)) {
g_string_printf (nmc->return_text, _("Error: NetworkManager is not running."));
nmc->return_value = NMC_RESULT_ERROR_NM_NOT_RUNNING;
return nmc->return_value;
}
if (argc == 0) {
g_string_printf (nmc->return_text, _("Error: No connection specified."));
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
return nmc->return_value;
}
filenames = g_new (char *, argc + 1);
for (i = 0; i < argc; i++)
filenames[i] = argv[i];
filenames[i] = NULL;
nm_remote_settings_load_connections (nmc->system_settings, filenames, &failures, &error);
g_free (filenames);
if (error) {
g_string_printf (nmc->return_text, _("Error: %s."), error->message);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
g_error_free (error);
}
if (failures) {
for (i = 0; failures[i]; i++)
fprintf (stderr, _("Could not load file '%s'\n"), failures[i]);
g_strfreev (failures);
}
return nmc->return_value;
}
typedef struct {
NmCli *nmc;
......@@ -7347,6 +7393,9 @@ parse_cmd (NmCli *nmc, int argc, char **argv)
else if (matches(*argv, "reload") == 0) {
nmc->return_value = do_connection_reload (nmc, argc-1, argv+1);
}
else if (matches(*argv, "load") == 0) {
nmc->return_value = do_connection_load (nmc, argc-1, argv+1);
}
else if (matches (*argv, "modify") == 0) {
nmc->return_value = do_connection_modify (nmc, argc-1, argv+1);
}
......
......@@ -272,7 +272,7 @@ be saved as two connections which both apply to eth0, one for DHCP (called
connected to the DHCP-enabled network the user would run "nmcli con up default"
, and when connected to the static network the user would run "nmcli con up testing".
.TP
.SS \fICOMMAND\fP := { show | up | down | add | edit | modify | delete | reload }
.SS \fICOMMAND\fP := { show | up | down | add | edit | modify | delete | reload | load }
.sp
.RS
.TP
......@@ -615,6 +615,12 @@ to tell \fINetworkManager\fP to re-read the connection profiles from disk when
a change was made to them. However, the auto-loading feature can be enabled and
then \fINetworkManager\fP will reload connection files any time they change
(monitor-connection-files=true in \fINetworkManager.conf\fP(5)).
.TP
.B load <filename> [<filename>...]
.br
Load/reload one or more connection files from disk. Use this after manually
editing a connection file to ensure that \fBNetworkManager\fP is aware
of its latest state.
.RE
.TP
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment