diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-06-08 15:18:06 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-07-12 15:46:37 +0200 |
commit | 1375d9c13ad6062f2c84089242f0dcfac1bd8e07 (patch) | |
tree | 395aad60aba3b1d8de488dfd20d75de222d0f6b2 | |
parent | aa12bb353bca34be1bea0625c8e6e7715f24deb3 (diff) | |
download | NetworkManager-1375d9c13ad6062f2c84089242f0dcfac1bd8e07.tar.gz |
cli: add master option to "nmcli c add"
-rw-r--r-- | clients/cli/connections.c | 31 | ||||
-rw-r--r-- | man/nmcli-examples.xml | 12 | ||||
-rw-r--r-- | man/nmcli.1.in | 42 |
3 files changed, 63 insertions, 22 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 2a7d2669f7..cfb6d81bc4 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -251,7 +251,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 [-- ([+|-]<setting>.<property> <value>)+]\n\n" + " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_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" @@ -319,13 +319,16 @@ usage_connection_add (void) { g_printerr (_("Usage: nmcli connection add { ARGUMENTS | help }\n" "\n" - "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+]\n\n" + "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+]\n\n" " COMMON_OPTIONS:\n" " type <type>\n" " ifname <interface name> | \"*\"\n" " [con-name <connection name>]\n" " [autoconnect yes|no]\n\n" " [save yes|no]\n\n" + " [master <master (ifname, or connection UUID or name)>]\n" + " [slave-type <master connection type>]\n\n" + " [save yes|no]\n\n" " TYPE_SPECIFIC_OPTIONS:\n" " ethernet: [mac <MAC address>]\n" " [cloned-mac <cloned MAC address>]\n" @@ -390,6 +393,11 @@ usage_connection_add (void) " olpc-mesh: ssid <SSID>\n" " [channel <1-13>]\n" " [dhcp-anycast <MAC address>]\n\n" + " SLAVE_OPTIONS:\n" + " bridge: [priority <0-63>]\n" + " [path-cost <1-65535>]\n" + " [hairpin yes|no]\n\n" + " team: [config <file>|<raw JSON data>]\n\n" " IP_OPTIONS:\n" " [ip4 <IPv4 address>] [gw4 <IPv4 gateway>]\n" " [ip6 <IPv6 address>] [gw6 <IPv6 gateway>]\n\n")); @@ -4317,8 +4325,9 @@ complete_slave (NMSettingConnection *s_con, const char *checked_master = NULL; if (type) - g_print (_("Warning: 'type' is currently ignored. " - "We only support ethernet slaves for now.\n")); + g_print (_("Warning: 'type' is ignored. " + "Use 'nmcli connection add \"%s\" ...' instead."), + type); if (nm_setting_connection_get_master (s_con)) { /* Master already set. */ @@ -4339,8 +4348,6 @@ complete_slave (NMSettingConnection *s_con, } /* Verify master argument */ checked_master = normalized_master_for_slave (all_connections, master, slave_type, NULL); - if (!checked_master) - g_print (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master); /* Change properties in 'connection' setting */ g_object_set (s_con, @@ -5916,6 +5923,9 @@ do_connection_add (NmCli *nmc, int argc, char **argv) gboolean ifname_mandatory = TRUE; const char *save = NULL; gboolean save_bool = TRUE; + const char *master = NULL; + const char *checked_master = NULL; + const char *slave_type = NULL; AddConnectionInfo *info = NULL; const char *setting_name; GError *error = NULL; @@ -5924,6 +5934,8 @@ do_connection_add (NmCli *nmc, int argc, char **argv) {"autoconnect", TRUE, &autoconnect, FALSE}, {"ifname", TRUE, &ifname, FALSE}, {"save", TRUE, &save, FALSE}, + {"master", TRUE, &master, FALSE}, + {"slave-type", TRUE, &slave_type, FALSE}, {NULL} }; rl_attempted_completion_function = (rl_completion_func_t *) nmcli_con_add_tab_completion; @@ -6024,12 +6036,19 @@ do_connection_add (NmCli *nmc, int argc, char **argv) default_name = unique_connection_name (nmc->connections, try_name); g_free (try_name); } + + if (master) + /* Verify master argument */ + checked_master = normalized_master_for_slave (nmc->connections, master, slave_type, &slave_type); + g_object_set (s_con, NM_SETTING_CONNECTION_ID, default_name, NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_TYPE, setting_name, NM_SETTING_CONNECTION_AUTOCONNECT, auto_bool, NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, + NM_SETTING_CONNECTION_MASTER, checked_master, + NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL); g_free (uuid); g_free (default_name); diff --git a/man/nmcli-examples.xml b/man/nmcli-examples.xml index 23ef231864..a0da09cc2d 100644 --- a/man/nmcli-examples.xml +++ b/man/nmcli-examples.xml @@ -178,8 +178,8 @@ $ nmcli g log level INFO domains DEFAULT <example><title>Adding a bonding master and two slave connection profiles</title> <programlisting><emphasis role="bold"> $ nmcli con add type bond ifname mybond0 mode active-backup -$ nmcli con add type bond-slave ifname eth1 master mybond0 -$ nmcli con add type bond-slave ifname eth2 master mybond0 +$ nmcli con add type ethernet ifname eth1 master mybond0 +$ nmcli con add type ethernet ifname eth2 master mybond0 </emphasis></programlisting> </example> <para> @@ -194,8 +194,8 @@ $ nmcli con add type bond-slave ifname eth2 master mybond0 <example><title>Adding a team master and two slave connection profiles</title> <programlisting><emphasis role="bold"> $ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf -$ nmcli con add type team-slave con-name Team1-slave1 ifname em1 master Team1 -$ nmcli con add type team-slave con-name Team1-slave2 ifname em2 master Team1 +$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1 +$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1 </emphasis></programlisting> </example> <para> @@ -222,8 +222,8 @@ $ nmcli con up Team1-slave2 <example><title>Adding a bridge and two slave profiles</title> <programlisting><emphasis role="bold"> $ nmcli con add type bridge con-name TowerBridge ifname TowerBridge -$ nmcli con add type bridge-slave con-name br-slave-1 ifname ens3 master TowerBridge -$ nmcli con add type bridge-slave con-name br-slave-2 ifname ens4 master TowerBridge +$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge +$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge $ nmcli con modify TowerBridge bridge.stp no </emphasis></programlisting> </example> diff --git a/man/nmcli.1.in b/man/nmcli.1.in index 0c9434c232..7ab3ef8cda 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 [-- [+|-]<setting>.<property> <value> ...] +.B add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- [+|-]<setting>.<property> <value> ...] .br Add a connection for NetworkManager. Arguments differ according to connection types, see below. .RS @@ -426,6 +426,9 @@ Add a connection for NetworkManager. Arguments differ according to connection ty .B COMMON_OPTIONS: .IP "\fItype <type>\fP" 42 \(en connection type; see below \fBTYPE_SPECIFIC_OPTIONS\fP for allowed values; (mandatory) +Note that types \fIbond-slave\fP, \fIteam-slave\fP and \fIbridge-slave\fP create \fIethernet\fP +connection profiles. Their use is discouraged in favor of using a specific type with \fImaster\fP +option. .IP "\fIifname <ifname> | \(dq\&*\(dq\&\fP" 42 \(en interface to bind the connection to. The connection will only be applicable to this interface name. A special value of "\fB*\fP" can be used for interface-independent connections. @@ -437,6 +440,13 @@ Note: use quotes around \fB*\fP to suppress shell expansion. \(en whether the connection profile can be automatically activated (default: yes) .IP "\fI[save yes|no]\fP" 42 \(en whether the connection should be persistent, i.e. NetworkManager should store it on disk (default: yes) +.IP "\fI[master <master (ifname, or connection UUID or name)>]\fP" 42 +\(en master interface name, or connection UUID or ID of master connection profile. +The value can be prefixed with \fBifname/\fP, \fBuuid/\fP or \fBid/\fP to disambiguate it. +See below \fBSLAVE_OPTIONS\fP for additional options for slave connection to masters of various types. +.IP "\fI[slave-type <master connection type>]\fP" 42 +\(en type of master connection. Only required when it can not be inferred (i.e. the master connection does +not exist yet). .RE .RS .TP @@ -580,8 +590,6 @@ The value can be prefixed with \fBifname/\fP, \fBuuid/\fP or \fBid/\fP to disamb .IP "\fImaster <master (ifname, or connection UUID or name)>\fP" 42 \(en master team interface name, or connection UUID or ID of team master connection profile. The value can be prefixed with \fBifname/\fP, \fBuuid/\fP or \fBid/\fP to disambiguate it. -.IP "\fI[config <file>|<raw JSON data>]\fP" 42 -\(en JSON configuration for team .RE .RS .TP @@ -610,13 +618,6 @@ originally introduced in 3.15 upstream kernel) .IP "\fImaster <master (ifname, or connection UUID or name)>\fP" 42 \(en master bridge interface name, or connection UUID or ID of bridge master connection profile. The value can be prefixed with \fBifname/\fP, \fBuuid/\fP or \fBid/\fP to disambiguate it. -.IP "\fI[priority <0-63>]\fP" 42 -\(en STP priority of this slave (default: 32) -.IP "\fI[path-cost <1-65535>]\fP" 42 -\(en STP port cost for destinations via this slave (default: 100) -.IP "\fI[hairpin yes|no]\fP" 42 -\(en 'hairpin mode' for the slave, which allows frames -to be sent back out through the slave the frame was received on (default: yes) .RE .RS .TP @@ -638,6 +639,27 @@ to be sent back out through the slave the frame was received on (default: yes) .RE .RS .TP +.B SLAVE_OPTIONS: +.RE +.RS +.TP +.B bridge: +.IP "\fI[priority <0-63>]\fP" 42 +\(en STP priority of this slave (default: 32) +.IP "\fI[path-cost <1-65535>]\fP" 42 +\(en STP port cost for destinations via this slave (default: 100) +.IP "\fI[hairpin yes|no]\fP" 42 +\(en 'hairpin mode' for the slave, which allows frames +to be sent back out through the slave the frame was received on (default: yes) +.RE +.RS +.TP +.B team: +.IP "\fI[config <file>|<raw JSON data>]\fP" 42 +\(en JSON configuration for team +.RE +.RS +.TP .B IP_OPTIONS: .IP "\fI[ip4 <IPv4 address>] [gw4 <IPv4 gateway>]\fP" 42 \(en IPv4 addresses |