From b3e57cf3ca923397f269116e9cb5ec7b89b54988 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 7 Jun 2015 15:35:32 +0200 Subject: [PATCH] cli: allow specifying arbitrary properties on "nmcli c add" Syntax: nmcli c add ... -- [+|-]. ... --- clients/cli/connections.c | 20 ++++++++++++++++---- man/nmcli.1.in | 12 +++++++++++- 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] ...\n\n" " up [[id | uuid | path] ] [ifname ] [ap ] [passwd-file ]\n\n" " down [id | uuid | path | apath] ...\n\n" - " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n" + " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS [-- ([+|-]. )+]\n\n" " modify [--temporary] [id | uuid | path] ([+|-]. )+\n\n" " edit [id | uuid | path] \n" " edit [type ] [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 [-- ([+|-]. )+]\n\n" " COMMON_OPTIONS:\n" " type \n" " ifname | \"*\"\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 -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 [-- [+|-]. ...] .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 ] [gw6 ]\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 ] - 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.