diff options
author | Dan Winship <danw@gnome.org> | 2013-10-31 15:18:47 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-11-15 13:39:40 -0500 |
commit | 9a532db182078bf54ec9752b58b32dc4e010aee2 (patch) | |
tree | 47c11cd630d9c46ac6f6a1a5194b96362f3f0e6a | |
parent | a52ebc74b53b545e734eacb1e1e940dd62a3df7b (diff) | |
download | NetworkManager-9a532db182078bf54ec9752b58b32dc4e010aee2.tar.gz |
cli: add "nmcli con load file..."
https://bugzilla.gnome.org/show_bug.cgi?id=709830
-rw-r--r-- | cli/src/connections.c | 51 | ||||
-rw-r--r-- | man/nmcli.1.in | 8 |
2 files changed, 57 insertions, 2 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c index 8ae9ce3337..49083528e4 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -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); } diff --git a/man/nmcli.1.in b/man/nmcli.1.in index 9a2e83afa1..540283f69c 100644 --- a/man/nmcli.1.in +++ b/man/nmcli.1.in @@ -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 |