mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 13:28:02 +02:00
cli: add "nmcli con load file..."
https://bugzilla.gnome.org/show_bug.cgi?id=709830
This commit is contained in:
parent
a52ebc74b5
commit
9a532db182
2 changed files with 57 additions and 2 deletions
|
|
@ -227,7 +227,8 @@ usage (void)
|
||||||
" modify [ id | uuid | path ] <ID> <setting>.<property> <value>\n\n"
|
" 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"
|
" edit [ id | uuid | path ] <ID> | [type <new_con_type>] [con-name <new_con_name>]\n\n"
|
||||||
" delete [ id | uuid | path ] <ID>\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",
|
"edit",
|
||||||
"delete",
|
"delete",
|
||||||
"reload",
|
"reload",
|
||||||
|
"load",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -7262,6 +7264,50 @@ do_connection_reload (NmCli *nmc, int argc, char **argv)
|
||||||
return nmc->return_value;
|
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 {
|
typedef struct {
|
||||||
NmCli *nmc;
|
NmCli *nmc;
|
||||||
|
|
@ -7347,6 +7393,9 @@ parse_cmd (NmCli *nmc, int argc, char **argv)
|
||||||
else if (matches(*argv, "reload") == 0) {
|
else if (matches(*argv, "reload") == 0) {
|
||||||
nmc->return_value = do_connection_reload (nmc, argc-1, argv+1);
|
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) {
|
else if (matches (*argv, "modify") == 0) {
|
||||||
nmc->return_value = do_connection_modify (nmc, argc-1, argv+1);
|
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"
|
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".
|
, and when connected to the static network the user would run "nmcli con up testing".
|
||||||
.TP
|
.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
|
.sp
|
||||||
.RS
|
.RS
|
||||||
.TP
|
.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
|
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
|
then \fINetworkManager\fP will reload connection files any time they change
|
||||||
(monitor-connection-files=true in \fINetworkManager.conf\fP(5)).
|
(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
|
.RE
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue