Commit Graph

153 Commits

Author SHA1 Message Date
Lubomir Rintel
402828d2ed cli/devices: export device_state_to_color()
Also, get rid of the ColorInfo structure. It was not too nice anyway.
2016-07-19 14:29:05 +02:00
Jiří Klimeš
c875471430 nmcli: fix 'nmcli device modify' description
Fixes: 8b4494598d
2016-07-15 12:26:24 +02:00
Jiří Klimeš
887cdcc217 nmcli: remove the extra full stop from error messages
$ nmcli dev modify
Error: No interface specified..
$ nmcli dev modify bla
Error: Device 'bla' not found..
2016-07-15 11:43:32 +02:00
Lubomir Rintel
9dafcc8b26 cli/device: allow completion of the "wifi" command name
That's the "wifi" string itself. The subcommands need some work.
2016-06-29 20:49:34 +02:00
Lubomir Rintel
b8bc57c9d3 cli/device: add "lldp list" subcommand completion 2016-06-29 20:49:34 +02:00
Lubomir Rintel
08969b1789 cli: make subcommand dispatch do autocompletion 2016-06-29 20:49:34 +02:00
Lubomir Rintel
39f6d5a5ba cli/device: make "lldp list" subcommand use get_device() 2016-06-29 20:44:05 +02:00
Lubomir Rintel
95a13ef100 cli/device: make "set" subcommand use get_devices() 2016-06-29 20:39:09 +02:00
Lubomir Rintel
78c4038d8c cli/device: convert lldp subcommand to nmc_do_cmd() 2016-06-29 20:32:31 +02:00
Lubomir Rintel
05108ca975 cli/device: convert wifi subcommand to nmc_do_cmd() 2016-06-29 20:32:31 +02:00
Lubomir Rintel
8b4494598d cli/device: add modify command
It modifies the applied connection using the Reapply API.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
c054b871f7 cli/device: add device name completion
Useful with connect, disconnect, delete, monitor, show and reapply.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
59bc820e66 cli/device: split get_device()
Parsing a single device name from the command line is generally
useful. Remove the open coded versions in reapply, connect & status.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
55d349bc34 cli/trivial: rename device_list() to get_device_list()
It will look nicer when we have get_device().
2016-06-29 20:28:42 +02:00
Lubomir Rintel
5182ab3d5d cli/device: use nmc_do_cmd() 2016-06-29 20:28:42 +02:00
Lubomir Rintel
a30224f6af cli: use should_wait consistently
It's a semaphore, not a boolean.
2016-06-29 20:28:42 +02:00
Lubomir Rintel
56804f4a3f cli/trivial: rename some functions for consistency
Some functions that take device lists use plural form in name.
2016-06-29 20:28:42 +02:00
Beniamino Galvani
bf7b9c60b6 cli: initialize connection list in do_device_connect()
The connection list may be required in nmc_secrets_requested() if
secrets are needed.

Fixes: 45fc268890

https://bugzilla.gnome.org/show_bug.cgi?id=767987
2016-06-27 13:09:20 +02:00
Thomas Haller
466bf2f633 build: avoid compiler warnings about non-constant format strings (-Wformat-nonliteral) 2016-06-05 12:22:01 +02:00
Beniamino Galvani
3c649e6429 team: expose current device configuration through D-Bus and nmcli
Add a new "Config" property to the D-Bus interface for team devices
and show its value through "nmcli device show". The property contains
the full JSON configuration from teamd for the device.

https://bugzilla.redhat.com/show_bug.cgi?id=1310435
2016-05-26 09:16:46 +02:00
Thomas Haller
7752f390c2 cli: declare external variable nm_cli in <nmcli.h> header 2016-05-03 11:53:15 +02:00
Thomas Haller
d742ea7817 cli: don't allow multiple <ifname> arguments to device-reapply
Just like `nmcli device connect` only allows one argument, don't allow
multiple device arguments for reapply.

Allowing multiple device names makes it more complicated to add
additional options to the command. For example, it would be useful
to have a

    nmcli device reapply eth0 connection id other-connection

but when allowing multiple device names, it gets more complicated in
documentation, command line parsing and bash completion.

Note that the user can achieve a very similar outcome by using the
shell:

    for DEV in eth0 eth1 eth2; do
        nmcli device reapply $DEV &
    done
    wait

argubaly, this doesn't report the exit status properly. To properly
handle that would require more effort. Also, it is somewhat less
efficient, but well.

This is an API change, however it is very new API that probably nobody
is using much. Also, the documentation (man nmcli) didn't mention the
possibility to pass multiple device names.
2016-05-03 11:52:57 +02:00
Thomas Haller
b217b68b80 cli: refactor cleanup in do_device_reapply() 2016-05-03 11:52:40 +02:00
Francesco Giudici
3c67a1ec5e cli: remove version check against NM
When performing NM package upgrade the new version of nmcli will be immediately
available while NM daemon will not, as it would not restart in order to avoid
to disrupt connectivity. This could create issues with tools leveraging
on nmcli output (till reboot). As apart from this case it is very unlikely
that a user can have this nmcli / NM daemon version mismatch situation,
the check could cause more harm than benefit in real user case
scenarios.

https://bugzilla.redhat.com/show_bug.cgi?id=1291785
2016-04-28 09:35:20 +02:00
Thomas Haller
8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Thomas Haller
6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Lubomir Rintel
868e1ddc07 cli: remove some dead code
Coverity points out.
2016-02-12 15:48:12 +01:00
Lubomir Rintel
1783826856 cli: sort_access_points() doesn't take a NULL argument
The device never returns NULL access point list, it only deallocates it on
dispose(). Make this clear for Coverity:

CID 59387 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking aps suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
2016-02-11 17:01:03 +01:00
Lubomir Rintel
fa6375cd8b cli: add nmcli d reapply
Client support for O.FD.NM.Device.Reapply().
2016-01-10 23:13:34 +01:00
Jiří Klimeš
629de4e689 cli: add global --show-secrets option
- it controls echoing passwords input on terminal
- it replaces --show-secrets in 'nmcli connection show', which is deprecated now
- it replaces --show-password in 'nmcli device wifi hotspot', which is deprecated now
2015-12-07 14:14:58 +01:00
Jiří Klimeš
1056408fd4 cli: use nmc_readline_echo() for asking password in 'nmcli dev wifi connect' 2015-12-07 14:14:58 +01:00
Lubomir Rintel
d03f347b9d cli: add nmcli monitor
https://bugzilla.redhat.com/show_bug.cgi?id=1034158
2015-12-05 12:16:23 +01:00
Lubomir Rintel
9b49284f0c cli,devices: add device monitor 2015-12-05 12:16:04 +01:00
Lubomir Rintel
2a646a74dd cli,devices: factor out parsing of the interface list
This is duplicated already and the monitor will use it.
2015-12-05 12:05:17 +01:00
Lubomir Rintel
225f6594c4 cli,devices: factor out device_state_to_color()
We'll use this for device status monitor too.
2015-12-05 12:05:17 +01:00
Lubomir Rintel
88ae8d2b13 cli: turn should_wait into a semaphore
Count the exit blockers. We'll want to terminate the device monitor in case all
monitored devices vanish.
2015-12-05 12:05:17 +01:00
Jiří Klimeš
579fd36566 cli: improve error messages for 'nmcli device set'
Fixes: 4dffbf8f6a
2015-11-25 16:39:00 +01:00
Jiří Klimeš
0dc48370b4 cli: print a warning if BSSID is given instead of SSID for hidden AP
$ nmcli dev wifi connect 00:22:6B:EB:1D:CA hidden yes
Warning: '00:22:6B:EB:1D:CA' should be SSID for hidden APs; but it looks like a BSSID.
Error: Failed to add/activate new connection: 802-11-wireless.ssid: connection does not match access point
2015-11-11 09:47:51 +01:00
Beniamino Galvani
5b3137984d cli: add command for displaying LLDP neighbors
The list of LLDP neighbors is available through the D-Bus interface
and libnm already provides functions to retrieve it; make the list
available through nmcli as well. Sample output:

  $ nmcli device lldp
  NEIGHBOR[0].DEVICE:                     eth0
  NEIGHBOR[0].CHASSIS-ID:                 00:13:21:58:CA:42
  NEIGHBOR[0].PORT-ID:                    1
  NEIGHBOR[0].PORT-DESCRIPTION:           1
  NEIGHBOR[0].SYSTEM-NAME:                ProCurve Switch 2600-8-PWR
  NEIGHBOR[0].SYSTEM-DESCRIPTION:         ProCurve J8762A Switch 2600-8-PWR, revision H.08.89
  NEIGHBOR[0].SYSTEM-CAPABILITIES:        20 (mac-bridge,router)
  NEIGHBOR[1].DEVICE:                     eth2
  NEIGHBOR[1].CHASSIS-ID:                 00:01:30:F8:AD:A2
  NEIGHBOR[1].PORT-ID:                    1/1
  NEIGHBOR[1].PORT-DESCRIPTION:           Summit300-48-Port 1001
  NEIGHBOR[1].SYSTEM-NAME:                Summit300-48
  NEIGHBOR[1].SYSTEM-DESCRIPTION:         Summit300-48 - Version 7.4e.1 (Build 5)
  NEIGHBOR[1].SYSTEM-CAPABILITIES:        20 (mac-bridge,router)

https://bugzilla.gnome.org/show_bug.cgi?id=757307
2015-11-10 14:06:02 +01:00
Jiří Klimeš
2f52a10be1 cli: add '--show-password' option for 'nmcli device wifi hotspot'
It is useful to show nmcli-generated hotspot password (if a user does not
provide his own password). Without the option the user would have to look into
the generated profile in order to find out the password.
2015-11-10 09:15:06 +01:00
Jiří Klimeš
781d24f1dd cli: add 'password' option for 'nmcli device wifi hotspot'
It allows user provided password to be used to secure the hotspot.
Otherwise, nmcli will generate a suitable password.
2015-11-10 09:10:48 +01:00
Jiří Klimeš
d6427d7198 cli: add 'nmcli device wifi hotspot' command
Synopsis:
nmcli device wifi hotspot [ifname <ifname>] [con-name <name>] [ssid <SSID>]
                          [band a|bg] [channel <channel>]
2015-11-10 09:08:05 +01:00
Thomas Haller
6a82b4e2ed cli: fix nmcli device set DEV managed true
Fixes: 4dffbf8f6a
2015-11-06 14:52:11 +01:00
Jiří Klimeš
e7ed259fdc cli: print s390 subchannels for devices that have that 2015-09-29 09:31:41 +02:00
Jiří Klimeš
9294962cc4 cli: remove static width parameter from fields definition
The width is no longer needed because the actual field's width is computed
dynamically just before printing.
(as of commit e6870789b5)
2015-09-25 12:09:51 +02:00
Thomas Haller
4cb0ab5d29 cli: fix type on printed nmcli error message
Fixes: 4dffbf8f6a
2015-09-21 18:25:50 +02:00
Thomas Haller
7405d5c7b7 nmcli: extend nmcli device set command to accept explicit ifname specifier
Without it, you cannot set the properties of a device named "help".
Now you can with:

  $ nmcli device set ifname help autoconnect no
2015-09-18 13:14:44 +02:00
Lubomir Rintel
4dffbf8f6a cli: add nmcli device set command
Co-Authored-By: Thomas Haller <thaller@redhat.com>
2015-09-18 13:14:35 +02:00
Jiří Klimeš
5955a66e09 cli: fix connecting to a hidden SSID with 'nmcli dev wifi connect' (bgo #752173)
We have to set 802-11-wireless.hidden=true to be able to connect to hidden SSIDs.
nmcli user indicates hidden SSID with 'hidden yes' parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=752173
2015-08-14 12:42:56 +02:00
Jiří Klimeš
e247567d87 cli: add 'ssid' parameter for 'nmcli device wifi rescan'
'ssid' can repeat when more SSIDs should be scanned, e.g.
$ nmcli dev wifi rescan ssid "hidden cafe" ssid AP12 ssid "my home Wi-Fi"

Bash completion fixed by thaller@redhat.com
2015-08-14 12:42:15 +02:00