summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2015-06-07 15:35:32 +0200
committerLubomir Rintel <lkundrak@v3.sk>2015-07-02 09:33:58 +0200
commitb3e57cf3ca923397f269116e9cb5ec7b89b54988 (patch)
tree8f9d384d6333b27b77179c98b232801655a7fa54
parent15149d915f9f0d0c7870a01b6f61723296495116 (diff)
downloadNetworkManager-b3e57cf3ca923397f269116e9cb5ec7b89b54988.tar.gz
cli: allow specifying arbitrary properties on "nmcli c add"
Syntax: nmcli c add ... -- [+|-]<setting>.<property> <value> ...
-rw-r--r--clients/cli/connections.c20
-rw-r--r--man/nmcli.1.in12
2 files changed, 27 insertions, 5 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 0d0e23e492..796a8947ca 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -253,7 +253,7 @@ usage (void)
" show [--active] [--show-secrets] [id | uuid | path | apath] <ID> ...\n\n"
" up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>] [passwd-file <file with passwords>]\n\n"
" down [id | uuid | path | apath] <ID> ...\n\n"
- " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
+ " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS [-- ([+|-]<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"
@@ -321,7 +321,7 @@ usage_connection_add (void)
{
g_printerr (_("Usage: nmcli connection add { ARGUMENTS | help }\n"
"\n"
- "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
+ "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+]\n\n"
" COMMON_OPTIONS:\n"
" type <type>\n"
" ifname <interface name> | \"*\"\n"
@@ -5568,8 +5568,8 @@ cleanup_olpc:
ip4 = gw4 = ip6 = gw6 = NULL;
- if (!nmc_parse_args (exp_args, TRUE, &argc, &argv, error))
- return FALSE;
+ if (!nmc_parse_args (exp_args, TRUE, &argc, &argv, NULL))
+ break;
/* coverity[dead_error_begin] */
if (ip4) {
@@ -5643,6 +5643,18 @@ cleanup_olpc:
do_questionnaire_ip (connection);
}
+ if (argc) {
+ /* Set extra connection properties. */
+ nmc_arg_t exp_args[] = { {"--", FALSE, NULL, TRUE},
+ {NULL} };
+
+ if (!nmc_parse_args (exp_args, FALSE, &argc, &argv, error))
+ return FALSE;
+
+ if (!read_connection_properties (connection, argc, argv, error))
+ return FALSE;
+ }
+
return TRUE;
}
diff --git a/man/nmcli.1.in b/man/nmcli.1.in
index 87311f30d8..0c9434c232 100644
--- a/man/nmcli.1.in
+++ b/man/nmcli.1.in
@@ -418,7 +418,7 @@ See \fBconnection show\fP above for the description of the <ID>-specifying keywo
.br
If '--wait' option is not specified, the default timeout will be 10 seconds.
.TP
-.B add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS
+.B add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS [-- [+|-]<setting>.<property> <value> ...]
.br
Add a connection for NetworkManager. Arguments differ according to connection types, see below.
.RS
@@ -644,6 +644,11 @@ to be sent back out through the slave the frame was received on (default: yes)
.IP "\fI[ip6 <IPv6 address>] [gw6 <IPv6 gateway>]\fP" 42
\(en IPv6 addresses
.RE
+.RS
+If a \fI--\fP argument is encountered, the rest of command line is interpreted
+as property list in the same format as \fIconnection modify\fP command accepts.
+This makes it possible to adjust the connection properties before it's added.
+.RE
.TP
.B edit [id | uuid | path ] <ID> - edit an existing connection
.RE
@@ -997,6 +1002,11 @@ and disables the connection's "autoconnect" flag.
non-interactively adds a VLAN connection with ID 55. The connection will use eth0 and the VLAN interface
will be named Maxipes\(hyfik.
+.IP "\fB\f(CWnmcli c a ifname eth0 type ethernet -- ipv4.method disabled ipv6.method link-local\fP\fP"
+.IP
+non-interactively adds a connection that will use eth0 Ethernet interface and only have an IPv6 link-local
+address configured.
+
.IP "\fB\f(CWnmcli connection edit ethernet\-em1\-2\fP\fP"
.IP
edits existing "ethernet\(hyem1\(hy2" connection in the interactive editor.