Commit Graph

357 Commits

Author SHA1 Message Date
Jiří Klimeš
7d55426992 cli: add global '--wait <seconds>' option - timeout waiting for operations
--wait <0-maxint>

0    : means "do not wait". nmcli exits immediatelly with success.
1... : if operation doesn't finish within the timeout, nmcli exits with an error
2013-05-16 10:28:40 +02:00
Jiří Klimeš
a453563bee cli: remove RUNNING field from default 'common' fields
That way it is not displayed by default:
$ nmcli general status

But can be explicitly requested:
$ nmcli -t -f running,version general status
$ nmcli -f all general status

E.g. Fedora initscripts do this in
/etc/sysconfig/network-scripts/network-functions

is_nm_running ()
{
    [ "$(LANG=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ]
}
2013-05-10 12:28:01 +02:00
Jiří Klimeš
24f05292da cli: update bash-completion file for 'connection add'
* _nmcli_list vs. _nmcli_list_nl - space vs. new-line separated list
* connection add
  - various types, modes, mac, ifname, ...
2013-05-07 19:41:37 +02:00
Jiří Klimeš
6c2e7706af cli: 'connection add': accept multiple IP addresses 2013-05-07 19:41:37 +02:00
Jiří Klimeš
3901281077 cli: 'connection add' command for adding NM connections non-interactively
A few examples:
nmcli --ask connection add
nmcli connection add type ethernet
nmcli -p connection add type ethernet con-name "my ethernet connection 1"
nmcli connection add type ethernet ip4 192.168.100.5/24
nmcli connection add type ethernet ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
nmcli connection add type ethernet ifname eth0
nmcli connection add type ethernet autoconnect no ifname eth0
nmcli connection add type wifi con-name Rakosnicek ssid Brcalnik
nmcli --ask connection add type wifi con-name My_WiFi
nmcli c a type infiniband con-name Infi1 transport-mode connected
nmcli c a type bluetooth addr 12:54:00:fd:db:26
nmcli c a type bluetooth addr 12:54:00:fd:db:26 bt-type dun-cdma
nmcli c a type gsm apn internet
nmcli c a type cdma
nmcli c a type bond
nmcli c a type bond ifname mybond0 mode active-backup
nmcli c a ifname maxipes-fik type vlan dev eth0 id 55
nmcli c a con-name VLAN1 type vlan dev eth0 id 44 ingress "2:4,3:55" egress "1:3" flags 6
nmcli c a type bridge ifname br0 stp on ip4 10.0.0.25
nmcli c a ifname eth0 type bridge-slave master 30fc816a-e7dd-4ae7-a86e-ab0c9cee51c2 hairpin no path-cost 333 priority 20
nmcli c a type bridge-slave master br2
2013-05-07 19:41:36 +02:00
Jiří Klimeš
5761a46da0 cli: add functions for creating NM address and route structures to common.c
nmc_parse_and_build_ip[4|6]_address() creating NMIP[4|6]Address
nmc_parse_and_build_ip[4|6]_route() creating NMIP[4|6]Route
2013-05-07 19:41:36 +02:00
Jiří Klimeš
04d590a923 cli: nmc_string_to_bool() - util function for converting string to boolean
["true", "yes", "on"] -> TRUE
["false", "no", "off"] -> FALSE
2013-05-07 19:41:36 +02:00
Jiří Klimeš
ddd3ea2cd4 cli: util functions for converting string to int
nmc_string_to_int()  - converts string to signed long int (decimal)
nmc_string_to_uint() - converts string to unsigned long int (decimal)
nmc_string_to_int_base()  - converts string to signed long int with given base
nmc_string_to_uint_base() - converts string to unsigned long int with given base
2013-05-07 19:41:36 +02:00
Jiří Klimeš
8598ee1139 cli: nmc_string_is_valid() utility function
This function checks whether a string is contained among allowed strings. It
performs case-insensitive comparison and supports shortcuts if they are unique.
It returns a pointer to the found string in allowed array, or NULL.
2013-05-07 19:41:36 +02:00
Dan Winship
440223fa3c cli: sort the output of "nmcli dev"
Sort the output of "nmcli dev", first by state (with connected devices
first and unmanaged ones last), then by type and interface name.
2013-05-07 12:46:56 -04:00
Dan Winship
ae9a389f83 libnm-glib, cli: add nm_device_get_type_description
Add a new libnm-glib method to get the type description for a device,
and use it in nmcli. For most types, the type description is based on
the class name, but for NMDeviceGeneric, it comes from the
:type-description property.
2013-05-07 12:46:56 -04:00
Dan Winship
ab7ebead2c core: add IP configuration for unmanaged devices
Use NMPlatform to read the IP address/route configuration of unmanaged
devices, and export that via D-Bus like we do with NM-generated IP
configs.
2013-05-07 12:46:55 -04:00
Jiří Klimeš
4d048cc2d8 cli: fix displaying unknown flags/bands 2013-05-06 14:00:10 +02:00
Dan Williams
e09550ec62 cli: clarify generic getter alloc/free behavior 2013-05-03 10:31:50 -05:00
Jiří Klimeš
47710f8211 cli: 'con up' - give bond/bridge slaves 10s to appear while activating master
If there are no slaves after the timeout, exit nmcli with an error, assuming
that NM is waiting for slaves to finish activation:
"(bondx) "IPv4 config waiting until slaves are ready"
"(bondx) "IPv6 config waiting until slaves are ready"
2013-04-30 09:28:13 +02:00
Jiří Klimeš
8215fd92fc cli: rename 'nmcli dev wifi scan' to 'nmcli dev wifi rescan' (bgo #698241) 2013-04-24 10:22:57 +02:00
Jiří Klimeš
3560024de9 cli: remove obsolete 'nmcli nm'
The functionality is present in 'general', 'networking' and 'radio'.
We changed syntax anyway, so it doesn't make much sense to keep 'nm'.
2013-04-24 10:04:43 +02:00
Jiří Klimeš
3bf97fafe7 cli: rename 'iface' --> 'ifname' in all commands 2013-04-24 10:04:37 +02:00
Jiří Klimeš
5f523d8f4d cli: accept shortcuts for --mode and --escape arguments
--mode tabular | multiline  -->  --mode t | m
--escape yes | no           -->  --escape y | n
2013-04-24 10:04:33 +02:00
Jiří Klimeš
d3ea9ee472 cli: handle NULL gracefully in nmc_arg_is_help() 2013-04-18 12:42:54 +02:00
Jiří Klimeš
7d5df73d76 cli: add nmc_arg_is_help() and use it to save some code lines 2013-04-18 11:25:49 +02:00
Pavel Šimerda
b292af8e1d trivial: avoid -Wshadow
jklimes: read vs. read(3), use 'num' instead
2013-04-15 13:43:34 +02:00
Jiří Klimeš
654a79ba88 cli: update bash completion file for the new syntax 2013-04-09 10:31:13 +02:00
Jiří Klimeš
c84315fd12 cli: 'connection delete' - do not stop on invalid connection arguments
Rather report it and continue with the next one. This is the behaviour
e.g. 'rm' command uses.
2013-04-08 16:14:56 -05:00
Jiří Klimeš
7dddead250 trivial: format nmcli usage help 2013-04-08 16:14:11 -05:00
Jiří Klimeš
15398f6fc3 trivial: fix some comments and error messages in devices.c 2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ebe727d83 cli: add 'nmcli general logging'
nmcli general logging [level <log level>] [domains <log domains>]

Examples:
nmcli general logging    - print current level and domains values
nmcli general logging level ERR  - change logging level to ERR
nmcli general logging level DEBUG domains DNS  - change logging level to DEBUG and domains to DNS
nmcli g l domains DEFAULT  - set default log domains (the ones active when NM)
2013-04-08 16:14:11 -05:00
Jiří Klimeš
e2d8ca7924 cli: util function to parse command-line arguments
nmc_parse_args() - parse command-line arguments
2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ddd7bc2dc cli: split 'nmcli switch' --> 'nmcli networking' and 'nmcli radio' 2013-04-08 16:14:11 -05:00
Jiří Klimeš
7e7335471c cli: rename HARDWARE -> HW in status/switch fields 2013-04-08 16:14:11 -05:00
Jiří Klimeš
2bafd7a707 cli: split 'general' into 'nmcli switch' and 'nmcli general' commands
They basically contain operations previously available via 'nmcli nm'.
'nmcli nm' is still kept for backward compatibility.

Usage:
nmcli switch  [all|networking|wifi|wwan|wimax [on/off]]
nmcli general [status|permissions]

Examples:
nmcli switch all         - show all switches
nmcli switch wifi off    - switch Wi-Fi off

nmcli g s    - show NM status
nmcli g p    - show NM permissions
2013-04-08 16:14:10 -05:00
Jiří Klimeš
7a8d654691 cli: rename 'device list' -> 'device show' and remove 'iface' keyword
Examples:
nmcli device show         - shows details for all available devices
nmcli device show eth0    - shows details for eth0
nmcli device show em1.25  - shows details for em1.25 VLAN device
2013-04-08 16:12:34 -05:00
Jiří Klimeš
51f055f74c cli: remove iface keyword for 'nmcli device disconnect'
'nmcli disconnect' allows specifying only one interface at a time.
2013-04-08 16:12:34 -05:00
Jiří Klimeš
60f54cd65d cli: 'device disconnect' - ask for interface when missing and '--ask' is present 2013-04-08 16:12:34 -05:00
Jiří Klimeš
0db4b4db90 cli: 'device wifi connect' - ask for SSID/BSSID and password if not provided
when '--ask' parameter is specified
2013-04-08 16:12:34 -05:00
Jiří Klimeš
9e8013314e cli: 'connection delete' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:12:04 -05:00
Jiří Klimeš
786ba05bfa cli: 'connection down' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:12:03 -05:00
Jiří Klimeš
97dbf98cdd cli: 'connection up' - ask for a connection name if not provided
when '--ask' switch is used
2013-04-08 16:09:23 -05:00
Jiří Klimeš
b0bee192e8 cli: add nmc_string_to_arg_array() to split a string to arguments array 2013-04-08 16:09:23 -05:00
Jiří Klimeš
7c629bf0f4 cli: nmc_get_user_input() util function for getting user input 2013-04-08 16:09:23 -05:00
Jiří Klimeš
981a687f77 cli: add '--ask' global option
It will be used to ask user for required but missing data/parameters.
2013-04-08 16:09:23 -05:00
Jiří Klimeš
abbde8d76f cli: add 'nmcli device wifi scan' command
This requests NetworkManager to perform scanning for Wi-Fi networks.
NetworkManager scans periodically, but this command can be used by impatient
users who don't want to wait for the next scan.

Direct D-Bus API call example:
gdbus call --system -d org.freedesktop.NetworkManager \
           -o /org/freedesktop/NetworkManager/Devices/2 \
           -m org.freedesktop.NetworkManager.Device.Wireless.RequestScan {}
2013-04-08 16:09:23 -05:00
Jiří Klimeš
831b7e2352 cli: move 'nmcli con status' under 'nmcli connection show' as 'active'
The static connection profiles are 'configured'.

So, now we have:
nmcli connection show configured [[id|uuid|path] <ID>]
  - shows configured connections
nmcli connection show active     [[id|uuid|path|apath] <ID>]
  - shows active connections

Without arguments the commands list all connections; with an argument, the details
of the requested connection is shown.
2013-04-08 16:09:23 -05:00
Jiří Klimeš
245d86bbcb cli: make id|uuid optional for 'nmcli connection down'
and also allow identifying connetions with 'path' and 'apath' that accepts either
the whole D-Dus path or just an index.

nmcli connection down [id|uuid|path|apath] <ID>

Example:
nmcli connection down con1
nmcli connection down con1 con2 apath 1 id my-wifi
2013-04-08 16:09:23 -05:00
Jiří Klimeš
6d5a88f02c cli: make id|uuid optional for 'nmcli connection up'
and also allow identifying connetions with 'path' that accepts either the whole
D-Dus path or just an index.

nmcli connection up [id|uuid|path] <ID>

Examples:
nmcli connection up "My Home Wi-Fi"
nmcli connection up id "My Home Wi-Fi"
nmcli connection up path /org/freedesktop/NetworkManager/Settings/18
nmcli connection up path 18

Note:
In order to be able to identify connections with just index number, the 'path'
keyword has to be provided.
2013-04-08 16:06:40 -05:00
Jiří Klimeš
4eef48d4aa cli: make id|uuid optional for 'nmcli connection delete'
and also allow identifying connetions with 'path' that accepts either the whole
D-Dus path or just an index.

nmcli connection delete [id|uuid|path] <ID>

Example:
nmcli connection delete "Wired 1" "Wired 2" "Wired 3"
nmcli connection delete id MyMain id "Quick Test 1" "Quick Test 2" path 23 path 47
2013-04-08 16:04:22 -05:00
Jiří Klimeš
1e106e31b8 cli: make id|uuid specifiers optional for 'connection list' and 'connection status'
And also allow:
 - identifying connetions with 'path'/'apath' accepting either the whole D-Dus path
   or just an index
 - multiple connections on cmdline at once

nmcli connection list   [[id|uuid|path] <ID>]
nmcli connection status [[id|uuid|path|apath] <ID>]

Examples:
nmcli c l
nmcli c l "My Wi-Fi 1" airpoirt1 cpath 23 id "My Wi-Fi 2"
nmcli c s
nmcli c s apath 1 ee19b893-e2a7-42cf-ac82-34506f07a05f
2013-04-08 15:52:15 -05:00
Jiří Klimeš
5e4d264917 cli: rename 'nm' object to 'general'
nmcli general

'nm' is kept for backward compatibility.
2013-04-08 15:52:15 -05:00
Dan Williams
38d5770f3e cli: remove VPN state workaround from 191da673a8
This is no longer required, and state is signaled correctly.
2013-04-08 11:30:32 -05:00
Dan Williams
a829c0439d cli: use nm_client_get_manager_running() instead of nmc_is_nm_running()
We now guarantee that NMClient won't dbus-activate NetworkManager so
there is no need for a custom function to prevent this.
2013-04-08 11:30:32 -05:00