Commit Graph

357 Commits

Author SHA1 Message Date
Thomas Haller
e2f77d30b1 cli: make bash-completion for nmcli support more abbreviations.
Also sub commands can be abbreviated. Add some more aliases to the bash
completion.

Also fix the option 'nmcli radio mobile' which is called 'wwan'.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-13 14:17:44 +02:00
Thomas Haller
faa6a12ba3 cli: make bash-completion support abbreviated object names.
nmcli accepts abbreviated versions of object names, e.g. 'con'
instead of 'connection'. Adjust bash completion to also support
this.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-12 13:33:13 -05:00
Pavel Šimerda
320a9d16a3 all: replace struct in_addr with guint32 2013-08-03 00:15:07 -05:00
Jiří Klimeš
de42b9be67 cli: editor: show current configuration for 'nmcli' command without arguments 2013-07-30 14:04:59 +02:00
Jiří Klimeš
18817877ad cli: confirm connection saving when autoconnect=yes (rh #953296)
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
2013-07-30 14:04:52 +02:00
Jiří Klimeš
6f633a678a cli: editor: automagic changes of IP 'addresses'/'method' if the other is set 2013-07-30 14:04:47 +02:00
Jiří Klimeš
05258cba88 cli: fix reading p-key and parent options for 'con add type infiniband' 2013-07-25 15:01:03 +02:00
Jiří Klimeš
5f0f4b83b1 cli: add support for InfiniBand's 'p-key' and 'parent' to interactive editor 2013-07-22 14:43:39 +02:00
Jiří Klimeš
8bcc68a00b cli: trivial; use mtu variable instead of calling *_get_mtu() again 2013-07-22 14:07:07 +02:00
Jiří Klimeš
ed25c1a443 cli: load/save nmcli editor (readline) history so that it is persistent
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
2013-07-22 13:37:17 +02:00
Jiří Klimeš
34ab351284 cli: update bash-completion file for 'connection modify' 2013-07-22 13:37:17 +02:00
Dan Williams
16f5818927 cli: simplify setting creation 2013-07-22 13:37:17 +02:00
Jiří Klimeš
d4c8df4895 cli: 'connection modify' - modify a single property
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)
2013-07-22 13:37:17 +02:00
Jiří Klimeš
ead6d31eac cli: update bash-completion file for 'connection edit' 2013-07-22 13:37:16 +02:00
Jiří Klimeš
61d06d5db4 cli: use 'dirty' flag for "Do you really want to quit?" confirmation in editor 2013-07-22 13:37:16 +02:00
Jiří Klimeš
8bdb4f7a09 cli: libreadline (libedit) TAB-completion for 'connection edit'
TODO:
 - test with libedit (it seems to be a bit different, buggy?)
2013-07-22 13:37:16 +02:00
Jiří Klimeš
ca1c0cdaf4 cli: add 'nmcli' command for nmcli connection editor configuration
- show/hide status line:  nmcli> nmcli status-line yes | no
- editor prompt color:    nmcli> nmcli prompt-color <0-8>  (0 = normal/without color)
2013-07-22 13:37:16 +02:00
Jiří Klimeš
6f883c310e cli: fix saving connections in the connection editor
- 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.
2013-07-22 13:37:16 +02:00
Jiří Klimeš
07c92ec6e7 cli: insert text to line so that user can edit it
'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??
2013-07-22 13:37:16 +02:00
Jiří Klimeš
68d69bfce8 cli: add a submenu for connection editor for detail property handling
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
2013-07-22 13:37:16 +02:00
Jiří Klimeš
def37e4e0d cli: nmc_property_get_gvalue() nmc_property_set_gvalue()
Functions to
 - get property value and return it in GValue
 - set property value from GValue
2013-07-22 13:37:16 +02:00
Jiří Klimeš
f96cd68d90 cli: allow editing existing connections in interactive editor
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
2013-07-22 13:36:54 +02:00
Jiří Klimeš
da7cd4720c cli: line-editing capability for interactive editor using an edit line library
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
2013-07-22 13:34:48 +02:00
Jiří Klimeš
937eb48590 cli: 'connection edit' - edit/add connections in an interactive editor
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
...
2013-07-22 13:32:32 +02:00
Jiří Klimeš
02ff69100b cli: fix 'arp-interval' and 'arp-ip-target' options in usage help 2013-07-22 09:58:52 +02:00
Jiří Klimeš
f8c8d67e93 cli: fix quitting nmcli on 'nmcli con up'
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
2013-07-03 13:54:06 +02:00
Jiří Klimeš
3eac01256c cli: correct printing success indication on 'nmcli con up' 2013-07-03 13:53:58 +02:00
Jiří Klimeš
4358f5cc39 cli: fix erroneous messages and asserts for activation bond/bridge connections
error messages in bond_bridge_slaves_check():
** (process:11921): CRITICAL **: nm_device_bond_get_slaves: assertion `NM_IS_DEVICE_BOND (device)' failed
** (process:11921): CRITICAL **: nm_device_get_iface: assertion `NM_IS_DEVICE (device)' failed
2013-06-26 13:45:15 +02:00
Jiří Klimeš
5d1a6813d0 cli: print newly added 'gateway-ping-timeout' connection's property 2013-06-24 12:25:12 +02:00
Jiří Klimeš
790b3a753c cli: update bash completion file - 'nmcli connection reload' 2013-06-18 15:45:16 +02:00
Dan Winship
1f81851017 core: add monitor-connection-files=false and ReloadConnections
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.
2013-06-14 12:57:47 -03:00
Dan Winship
2c13439df1 cli: add support for new InfiniBand properties 2013-06-13 15:56:14 -03:00
Jiří Klimeš
a91eafdf95 cli: 'con add': make ifname mandatory (except bond,bridge,vlan) (bgo #698113)
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.
2013-06-13 10:29:22 +02:00
Dan Williams
a1dde9b516 cli: use a table for setting details functions
It's a bit clearer to find the setting and add new ones.
2013-06-06 10:06:39 +02:00
Dan Williams
b0863cbc4d mobile: don't fail in old MM code when using deprecated functions
We want to keep using these deprecated functions when talking to
the old ModemManager to ensure behavior is unchanged.
2013-06-05 12:42:12 -05:00
Jiří Klimeš
e8ee5bdb0b cli: 'dev wifi list': change default displayed columns
Now they are
 #define NMC_FIELDS_DEV_WIFI_LIST_COMMON
         "IN-USE,SSID,MODE,CHAN,RATE,SIGNAL,BARS,SECURITY"
2013-05-31 09:38:04 +02:00
Jiří Klimeš
dca3584b26 cli: 'dev wifi list': change SECURITY values
* remove "Encrypted" tag
 The "Encrypted: " stuff was initially copied from nm-tool, but it doesn't help
 here much. See also http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=a734c836a56f3170202f0555f1a03c9b2835775c
 for APs with WPA & RSN IEs, but no privacy flag.

* remove a space from "WPA ", etc. strings. Translators often leave it out
  and thus break output.

* change "WPA" to "WPA1" to make it clearer

* use "802.1X" instead of "Enterprise" to save some characters
2013-05-31 09:38:04 +02:00
Jiří Klimeš
5f93c4314d cli: 'dev wifi list': add IN-USE (*) field 2013-05-31 09:38:04 +02:00
Jiří Klimeš
e949365db4 cli: 'dev wifi list': 'Infrastructure' -> 'Infra', 'Unknown' -> 'N/A' in MODE 2013-05-31 09:38:03 +02:00
Jiří Klimeš
e339a259b1 cli: 'dev wifi list': add BARS column displaying signal semi-graphically
using unicode characters:
'_'   '▂'     '▄'     '▆'     '█'
0x5f  0x2582  0x2584  0x2586  0x2588
2013-05-31 09:38:03 +02:00
Jiří Klimeš
ac4c3f395d cli: 'dev wifi list': add CHAN column 2013-05-31 09:38:03 +02:00
Jiří Klimeš
28704d1f42 cli: 'dev wifi list' use nm_utils_ssid_to_utf8() to display SSID; add SSID-HEX
This commit removes enclosing '' from SSID.
SSID-HEX is printed as a string of hex characters (each 2 chars represent one
byte).
2013-05-31 09:38:03 +02:00
Jiří Klimeš
66098fa607 cli: trivial update of NmcOutputField initializers
no actual change
2013-05-31 09:38:03 +02:00
Jiří Klimeš
1d1cfd77d3 cli: adapt the code for the new flags and printing facilities
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.
2013-05-31 09:38:03 +02:00
Jiří Klimeš
7fe4345d0d cli: print_required_fields() - fix non-ASCII strings alignment in multiline 2013-05-31 09:38:03 +02:00
Jiří Klimeš
e6870789b5 cli: enhance printing to align tabular output properly and not to waste space
Until now we have used a static width defined for each column for tabular
output. Even if this worked in most cases, it was not optimal, because by
using too wide columns we wasted space, and in case of a too narrow column the
alignment broke. So, we need to know the longest string in a column to be able
to align columns in the tabular output. Thus, the printing has to be postponed
till we have all data available, and can find the widest column. This value is
then used for aligning while printing the data.

Arrays of NmcOutputField (rows) are inserted into output_data array. When all
data have been added, print_data() can be used to print the whole output_data
array with proper alignment.

A single row can be printed using print_required_fields().

Also, output flags are redone to better match the new output_data array.
The flags are needed for every row (in tabular output); they are stored in
the first field (NmcOutputField) for the whole row.

Addapted set_val_str() and set_val_arr() to set value type (char * x char **).
Added set_val_strc(), set_val_arrc() for const values that should not be freed.

output_data takes ownership of the data added to it and takes care of freeing
the memory.

See e.g.
https://bugzilla.gnome.org/show_bug.cgi?id=699503
2013-05-31 09:38:03 +02:00
Jiří Klimeš
0376f0be16 cli: make prompts asking for user input translatable in 'nmcli device' 2013-05-16 14:03:49 +02:00
Jiří Klimeš
d0b74b7d8d cli: 'connection add': allow numeric bonding modes 2013-05-16 10:44:17 +02:00
Jiří Klimeš
2b843dac50 cli: change '--private' to 'private yes|no' in 'nmcli dev wifi connect'
Missing 'private' argument default to private=no, the same way as before.
2013-05-16 10:28:40 +02:00
Jiří Klimeš
fa6ecaed32 cli: remove '--nowait' and '--timeout' options and use global '--wait' instead
'--wait 0' corresponds to '--nowait'
'--wait n' for n > 0 corresponds to '--timeout n'
2013-05-16 10:28:40 +02:00