summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-02-06 11:12:18 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-02-28 10:31:40 +0100
commit431b75824b29e50f2ee80b6b0c8e56c0dc769572 (patch)
treee09368203c69bfff996105cfaec125316867c24c /cli
parenta8e6094e403ebc4bb5de976a152cfcc57ac1a49b (diff)
downloadNetworkManager-431b75824b29e50f2ee80b6b0c8e56c0dc769572.tar.gz
cli: set vs. append property value by 'nmcli con modify' (rh #1044027)
Previously 'nmcli con modify' appended values for multi-value properties. This commit makes 'nmcli con modify' overwrite the whole value. You can choose appending values by prefixing the setting.property with '+' sign. For simple (not container) properties the behaviour is the same both with and without the '+', of course. Synopsis: nmcli connection modify [+]<setting>.<property <value> Example: ---> ipv4.dns = 1.2.3.4 $ nmcli connection modify my-em1 ipv4.dns 8.8.8.8 ---> ipv4.dns = 8.8.8.8 $ nmcli connection modify my-em1 +ipv4.dns 8.8.4.4 ---> ipv4.dns = 8.8.8.8 8.8.4.4 https://bugzilla.redhat.com/show_bug.cgi?id=1044027
Diffstat (limited to 'cli')
-rw-r--r--cli/src/connections.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c
index 49c5dc85c0..d204fab4b9 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -268,7 +268,7 @@ usage (void)
#endif
" down [id | uuid | path | apath] <ID>\n\n"
" add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
- " modify [--temporary] [id | uuid | path] <ID> <setting>.<property> <value>\n\n"
+ " modify [--temporary] [id | uuid | path] <ID> [+]<setting>.<property> <value>\n\n"
" edit [id | uuid | path] <ID>\n"
" edit [type <new_con_type>] [con-name <new_con_name>]\n\n"
" delete [id | uuid | path] <ID>\n\n"
@@ -416,10 +416,13 @@ usage_connection_modify (void)
fprintf (stderr,
_("Usage: nmcli connection modify { ARGUMENTS | help }\n"
"\n"
- "ARGUMENTS := [id | uuid | path] <ID> <setting name>.<property name> [<value>]\n"
+ "ARGUMENTS := [id | uuid | path] <ID> [+]<setting>.<property> <value>\n"
"\n"
"Modify a single property in the connection profile.\n"
- "The profile is identified by its name, UUID or D-Bus path.\n\n"));
+ "The profile is identified by its name, UUID or D-Bus path.\n\n"
+ "\n"
+ "Examples:\n"
+ "nmcli con mod em1-1 +ipv4.dns 8.8.4.4\n\n"));
}
static void
@@ -7825,7 +7828,10 @@ modify_connection_cb (NMRemoteConnection *connection,
}
static NMCResultCode
-do_connection_modify (NmCli *nmc, gboolean temporary, int argc, char **argv)
+do_connection_modify (NmCli *nmc,
+ gboolean temporary,
+ int argc,
+ char **argv)
{
NMConnection *connection = NULL;
NMRemoteConnection *rc = NULL;
@@ -7839,6 +7845,7 @@ do_connection_modify (NmCli *nmc, gboolean temporary, int argc, char **argv)
char **strv = NULL;
const char *setting_name;
char *property_name = NULL;
+ gboolean append = FALSE;
GError *error = NULL;
nmc->should_wait = FALSE;
@@ -7894,6 +7901,12 @@ do_connection_modify (NmCli *nmc, gboolean temporary, int argc, char **argv)
nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
goto finish;
}
+
+ if (set_prop[0] == '+') {
+ set_prop++;
+ append = TRUE;
+ }
+
strv = g_strsplit (set_prop, ".", 2);
if (g_strv_length (strv) != 2) {
g_string_printf (nmc->return_text, _("Error: invalid <setting>.<property> '%s'."),
@@ -7937,6 +7950,8 @@ do_connection_modify (NmCli *nmc, gboolean temporary, int argc, char **argv)
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto finish;
}
+ if (!append)
+ nmc_setting_reset_property (setting, property_name, NULL);
if (!nmc_setting_set_property (setting, property_name, value, &error)) {
g_string_printf (nmc->return_text, _("Error: failed to modify %s.%s: %s."),
strv[0], strv[1], error->message);