Bonding options are related and some combinations don't make sense. Basically,
MIIMON and ARP monitoring mode (and related options) are mutually exclusive.
When nmcli set arp_interval of "0" (the default value),
nm_setting_bond_add_option() cleared the MIIMON options (miimon, updelay and
downdelay).
This commit works around libnm-util's nm_setting_bond_add_option() that clears
miimon options when arp_interval is being set and vice versa, but doesn't
take into account the value of "0" that should be regarded as 'disable'.
https://bugzilla.redhat.com/show_bug.cgi?id=1007355
The commands performing actions without an output only printed a successfull
message for --pretty mode. Some users don't like this silent operation.
This commit makes nmcli print operation success unconditionally. I think that
doesn't hurt; scripts/users can ignore the message if not interested.
https://bugzilla.redhat.com/show_bug.cgi?id=1006444
Also allow leading/trailing white spaces, and more white spaces between IP and
gateway. (Spaces in values and around / are not allowed).
All of these are accepted:
' 1.2.3.4/11 1.2.3.254 '
' 1.2.3.4 '
' fe80::215:ff:fe93:ffff/128 ::1 '
...
https://bugzilla.redhat.com/show_bug.cgi?id=1007368
The format of property values that nmcli prints is not the same (for some
properties) as the format nmcli editor accepts as input from user. The reasons
are that (a) output format is more descriptive and not much suitable to be
typed, (b) it comes in most cases from libnm-util.
'change' command displays current property value and allows users to edit it.
So we convert the output into input format, before presenting it to the user.
https://bugzilla.redhat.com/show_bug.cgi?id=998929
readline() makes changes to terminal and when it doesn't receive unix signals,
it has no chance to perform cleanups on exit. So we have to call its cleanup
functions manually on exit.
https://bugzilla.gnome.org/show_bug.cgi?id=706118
nmc_setting_reset_property() function checks whether we allow changing the property
(set_func != NULL) and if so, the property value is reset to default.
remove <setting>[.property] | <property>
It entirely removes given setting from edited connection. If a property is given,
the command instead resets the property to its default value.
https://bugzilla.gnome.org/show_bug.cgi?id=707576
Synopsis: nmcli --ask connection add
When '--ask' is used, nmcli will ask not only for mandatory arguments but also
for the optional ones, with a series of questions.
readline_x returns NULL for empty input, so it is wrong
to call g_strstrip without checking for NULL first.
Signed-off-by: Thomas Haller <thaller@redhat.com>
The handlers detecting changes of IP addresses/method in nmcli interactive
editor were connected only for newly created connection. That's why the
automagic feature of setting 'method' when 'addresses' are changed and vice
versa worked just for new connections, but not while editing existing
connections.
Before the change if an alias for a setting name existed, it was used instead of
the real name and TAB-completion for the real name didn't work.
before:
nmcli> goto 802<TAB>
no output
now:
nmcli> goto 802<TAB>
nmcli> goto 802-11-wireless
802-11-wireless 802-11-wireless-security
nmcli> goto <TAB>
802-11-wireless-security (wifi-sec) connection ipv6
802-11-wireless (wifi) ipv4
When reading the property name in edit mode, any white space should be
striped from the entered value. Especially, because tab completion will
add a trailing whitespace.
Example:
$ nmcli connection edit
Enter connection type: ethernet
nmcli> goto connection
nmcli connection> describe
Property name? u<TAB>
The <TAB> will complete 'u' to 'uuid '.
This whitespace should be allowed and striped.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Ask for confirmation in these cases:
* autoconnect=yes and connection has not been saved yet
* autoconnect=yes, but saved connection had autoconnect=no
The confirmation can be switched off with
nmcli> nmcli save-confirmation no
The history is saved to ~/.nmcli-history file, separately for each connection.
The file uses glib key-file format. Each group is a connection UUID, keys are
integer numbers (history entry order), and values are the actual commands.
Example ~/.nmcli-history file:
[0bdc9852-2540-4e12-a605-5e65a9483772]
0=help quit
1=print
2=nmcli prompt-color 3
3=help set
4=q
[9142680d-3b87-4feb-ab1e-19e8762329ad]
0=eth
1=set ipv4.addr 1.2.3.4
2=quit
nmcli connection modify [id | uuid | path] <ID> <setting>.<property> [<value>]
missing value means setting the default value (deleting).
Examples:
nmcli con mod ethernet-2 connection.autoconnect no
nmcli con mod "Home Wi-Fi" wifi.mtu 1350
nmcli con mod "T-Mobile 1" gsm.apn internet
nmcli con mod 91782692-512e-4408-9572-667887319ef4 conn.perm user:cimrman
TODO:
- allow modifying multiple properties (using single command)
- Main command loop was moved to run in a separate thread (using GThread).
Otherwise glib main loop would be blocked in processing D-Bus and other
events.
- Handle creating new vs. updating already saved connection.
'change' command puts current value on edit line, so that user can change
it and confirm with <Enter>.
Notes:
* it works for libreadline
* libedit has to be checked
* doesn't work without any edit-line library - how to do that??
property_edit_submenu() is the main function. It is entered from main menu by
'goto'
command.
Commands of this menu:
set - set new value to the property
add - add a value to the property (for non-container properties it is
the same as set)
change - allow editing the current property value
remove - remove the property value(s)
describe - show the property description and/or usage
print - show the property value
back - return to the setting level (main menu)
help - show help (command descriptions)
quit - quit nmcli
So the syntax is now:
nmcli con edit [id | uuid | path ] <ID>
- for editing an existing connection
nmcli con edit [type <new connection type>] [con-name <new connection name>]
- for adding a new connection
Supported libraries are:
GNU Readline (libreadline) http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
NetBSD Editline (libedit) http://www.thrysoee.dk/editline/
We load these symbols:
readline() - main function allowing getting user input and aditing that
add_history() - stores strings to history
rl_insert_text() - insert text into the line at the current cursor position
rl_startup_hook - hook to call just before readline prints the first prompt
nmcli connection edit [type <type>] [con-name <name>]
Examples:
nmcli c e
nmcli c e type ethernet
nmcli c e type wifi con-name "My home Wi-Fi"
nmcli c e type bond
...
We should also quit on 'DEACTIVATED' state' when monitoring active connection
state.
Reproducer:
nmcli con add con-name myvlan dev eth1 id 88
nmcli -p con up myvlan
Add a "monitor-connection-files" config option, which can be set to
"false" to disable automatic reloading of connections on file change.
To go with this, add a new ReloadConnections method on
o.fd.NM.Settings that can be used to manually reload connections, and
add an nm-cli command to call it.
Optional 'ifname' allowed creating connection applicable to all interfaces,
which was confusing for some users. Now we require the user to provide ifname
to lock the connection for an interface. An "unbound" connection can be
created with ifname "*".
$ nmcli connection add type eth ifname eth0
$ nmcli connection add type eth
now becomes
$ nmcli connection add type eth ifname "*"
bond, bridge:
- when ifname is not specified or is "*",
interface name is generated (nm-bond, nm-bridge)
vlan:
- when ifname is not specified or is "*",
vlan device is named "dev.id"
Note: the quotes around * are required to suppress shell expansion.
The data are added to output_data at first, and then they are printed all at
once using print_data(), that takes care of proper alignment and display.
The static 'width' values defined in NmcOutputField columns are not used now,
but dynamically computed maximal widths override them.