Commit Graph

131 Commits

Author SHA1 Message Date
Francesco Giudici
f7c72045b7 nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...

Fixes: 16902a2be6
(cherry picked from commit ef0d0d08eb)
2017-03-29 14:25:48 +02:00
Lubomir Rintel
5a71bc8022 cli: add NmCli argument to next_arg()
Will be useful in next commit.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
16902a2be6 cli: use next_arg() on argument boundary
Shift argc and argc manually between argument ant its value and use
next_arg() between arguments everywhere. Whill be useful to parse global
arguments.
2017-03-28 15:32:05 +02:00
Francesco Giudici
a62b72272f nmcli: fix missing CONNECTIONS section name from nmcli -f all -m tab dev show <dev>
When a full section is specified as the field parameter in terse tabular
mode, the section name should be printed followed by all the field values
belonging to that section separated by ':'. The NAME of section CONNECTIONS
was missing.

sample command:
$ nmcli -m tab -t -f CONNECTIONS device show ens3
previous output was:
/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
now:
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
2017-03-28 10:55:00 +02:00
Francesco Giudici
7d96f1f17d nmcli: don't enforce anymore the -f(ields) option in -t(erse) mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
4fa2e1422d nmcli: (trivial) add comment 2017-03-28 10:55:00 +02:00
Francesco Giudici
cf39ef52da nmcli: remove redundant check 2017-03-28 10:55:00 +02:00
Lubomir Rintel
84c484ed5b cli: make match() return boolean
Coccinelle semantic patch:

  @@
  @@
  -int
  +gboolean
          matches (...);

  @@
  expression pattern, cmd, len;
  @@
  -int
  +gboolean
          matches (...)
          {
                  ...
  -               return memcmp (pattern, cmd, len);
  +               return memcmp (pattern, cmd, len) == 0;
          }

  @@
  expression prefix, str;
  @@
  (
  -matches (prefix, str) != 0
  +!matches (prefix, str)
  |
  -matches (prefix, str) == 0
  +matches (prefix, str)
  )

  @@
  expression prefix, str;
  @@
  -(matches (prefix, str))
  +matches (prefix, str)

  @@
  expression prefix, str;
  @@
  -(!matches (prefix, str))
  +!matches (prefix, str)

spatch --smpl-spacing --sp-file match.cocci --dir clients/cli/ \
  --include-headers --macro-file shared/nm-utils/gsystem-local-alloc.h
2017-02-15 13:04:07 +01:00
Lubomir Rintel
01a20015e0 cli: use nmc_do_cmd to get the client and check if the daemon is running
The makes use of asynchronous client initialization, making things a bit
faster and reduces code duplication too.
2016-11-11 16:18:03 +01:00
Lubomir Rintel
3ee03afecc cli: make it possible to call sub-commands with client obtained asynchronously 2016-11-11 16:18:03 +01:00
Lubomir Rintel
6499bb893f cli: get rid of client-global connections list
Caching it in the NmCli object is unnecessary, ugly and would be cumbersome in
future when we'll be creating the client object only when needed.
2016-11-11 16:18:03 +01:00
Thomas Haller
45c0518a5e cli: fix synopsis for hotspot arguments for nmcli device wifi --help 2016-10-12 15:15:19 +02:00
Thomas Haller
29b576bd70 proxy: cleanup handling of proxy-method
The numeric value of NM_SETTING_PROXY_METHOD_NONE should be zero,
as that is the more natural default.

Also, cast all uses of the enum values in g_object_set() to
(int).
2016-10-05 14:46:18 +02:00
Atul Anand
2cb75e08d6 nmcli: Add Proxy support to nmcli
nmcli fixed to allow users edit proxy properties.
2016-10-04 11:44:44 +02:00
Jiří Klimeš
1f0ba2e487 cli: (trivial) move gen_func_ifnames() from devices.c to common.c
and rename it to nmc_rl_gen_func()
2016-09-19 16:55:39 +02:00
Beniamino Galvani
b28b2ba8a9 clients: add define for NMSecretAgentSimple signal name 2016-09-14 23:32:52 +02:00
Lubomir Rintel
8cc6ce7e44 cli: add -f argument completion 2016-08-01 15:51:29 +02:00
Lubomir Rintel
2c24de5814 cli/device: add completion to wifi hotspot subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
1a0dfd31c4 cli/device: add completion to wifi connect subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
8679793f6b cli/device: add completion to wifi list subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
efd22c24e8 cli/device: add completion to wifi rescan subcommand 2016-08-01 13:52:36 +02:00
Lubomir Rintel
3068886043 cli/device: export some useful completion functions
Wi-Fi access point completion functionality and stuff useful for completing
"ifname" and "ap" for "nmcli c up".
2016-08-01 13:52:36 +02:00
Lubomir Rintel
4302e05b1a cli/device: make it possible to limit completion to wifis 2016-08-01 13:52:36 +02:00
Lubomir Rintel
d2842d16e3 cli/device: replace some duplicate code with find_wifi_device_by_iface() 2016-08-01 13:52:36 +02:00
Lubomir Rintel
1d8ab4e276 cli/device: make devices_idx argument to find_wifi_device_by_iface() optional
Most callers don't use it.
2016-08-01 13:52:36 +02:00
Lubomir Rintel
f32285f03f cli/device: make find_wifi_device_by_iface use sorted device array
...as opposed to GPtrArray. The point is to be able to have a single device
list that could be later reused with complete_device().
2016-08-01 13:52:36 +02:00
Lubomir Rintel
58caeea846 cli/trivial: move find_ap_on_device() up 2016-08-01 13:52:36 +02:00
Lubomir Rintel
ed215dc372 cli/trivial: move find_wifi_device_by_iface() up 2016-08-01 13:52:36 +02:00
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