cli: allow specifying arbitrary properties on "nmcli c add"

Syntax: nmcli c add ... -- [+|-]<setting>.<property> <value> ...
This commit is contained in:
Lubomir Rintel 2015-06-07 15:35:32 +02:00
parent 15149d915f
commit b3e57cf3ca
2 changed files with 27 additions and 5 deletions

View file

@ -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;
}

View file

@ -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.