Commit Graph

36 Commits

Author SHA1 Message Date
Thomas Haller
940979a5a6 cli: merge IPv4 and IPv6 versions of ip/dhcp config print 2018-07-09 15:43:55 +02:00
Thomas Haller
ff273b8221 cli: drop duplicate IPv6 property metadata 2018-07-09 15:43:55 +02:00
Thomas Haller
096ac93f8a cli: rework printing of dhcp options 2018-07-09 15:43:55 +02:00
Thomas Haller
4b3297271e cli: rework connection handling for multiple results
Functions like nmc_find_connection() and nmc_find_active_connection()
can easily find multiple matching results. For example, the
"connection.id" in NetworkManager is not enforced to be unique,
so if the user adds multiple connections with the same name,
they should be all selected.

The previous API had a @pos argument, that allowed to iterate over
the results. Change that, to return all matches in a GPtrArray.

Also, extend connection-show and other places, to anticipate that
a connection might be active multiple times in any moment.
2018-05-14 17:53:03 +02:00
Thomas Haller
5e34a4b424 cli: move find_active_connection() to common.c
Beside nmc_find_connection(), which is very similar.

Also, drop unused argument @cons.
2018-05-14 17:53:03 +02:00
Thomas Haller
5e69b8b9f1 cli: merge IPv4 and IPv6 variants of print_dhcp_config() 2018-04-23 15:43:39 +02:00
Beniamino Galvani
aa964ae969 build: move nm-client-utils.c to libnmc-base.a
In a later commit we'll add a new generic client function used by
nmcli and nmtui. nm-client-utils.c seems the right place for it, so
move the file to the base library that is used by both clients.

While at it, also put in that file some functions that will be needed
by nmtui.
2017-10-16 17:25:35 +02:00
Thomas Haller
b629b98687 cli: move completion for connection type to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
41b31051f2 cli: use nmc_print() to output device's IP4 info
The IP4 info adds a new type: to expose strv arguments
for addresses, etc.
2017-04-12 14:00:00 +02:00
Thomas Haller
bfb9fd0d2f cli: split tracking of meta data out of NmcOutputField
When generating output data, nmcli iterates over a list of
property-descriptors (nmc_fields_ip4_config), creates an intermediate
array (output_data) and finally prints it.

However, previously both the meta data (nmc_fields_ip4_config) and
the intermediate format use the same type NmcOutputField. This means,
certain fields are relevant to describe a property, and other fields
are output/formatting fields.

Split this up. Now, the meta data is tracked in form of an NMMetaAbstractInfo
lists. This separates the information about properties from intermediate steps
during creation of the output.

Note that currently functions like print_ip4_config() still have all the
knowledge about how to generate the output. That is wrong, instead, the
meta data (NMMetaAbstractInfo) should describe how to create the output
and then all those functions could be replaced. This means, later we want
to add more knowledge to the NMMetaAbstractInfo, so it is important to
keep them separate from NmcOutputField.
2017-04-05 16:53:06 +02:00
Thomas Haller
29bcfc2522 cli: don't track output data in global NmCli structure
We should not violate the global data to track the output data
while it is constructed and printed.

Most of the time, we actually clear the output data anyway --
either before constructing it, or after printing it.
In some cases we didn't, but I think that is a bug. It's really
hard to keep track of this.

The output data should belong to a certain scope and get destroyed
afterwards. Passing it around is very confusing. Don't do that.
2017-03-30 14:56:21 +02:00
Thomas Haller
23298bfc88 cli: move utils function from common.h to nm-meta-setting-desc.c
These functions are only used by nm-meta-setting-desc.c. Make them internal.
Unfortunately, they are part of "common.h" which cannot be used without
the rest of nmcli. Still todo.
2017-03-30 13:09:58 +02:00
Thomas Haller
cb66cf96d7 cli: add values_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Beniamino Galvani
d094914120 cli: support route options 2017-03-06 15:20:25 +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
Atul Anand
20098591d9 proxy: change semantics of pac-script
libnm-core: pac-script property in NMSettingProxy now represents the
script itself not the location. It ensures that the connection is
self contained.

nmcli: Supports loading of PAC Script via file path or written explicitly.
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
e9f96024ae cli: return sane error message for D-Bus policy permission errors
The error returned to users when a load_connection(s)/set_logging call
fails due to D-Bus policy denial is a bit obscure:

  $ nmcli general logging level debug
  Error: failed to set logging: Rejected send message, 4 matched rules;
  type="method_call", sender=":1.233" (uid=1001 pid=27225 comm="nmcli
  general logging level debug ")
  interface="org.freedesktop.NetworkManager" member="SetLogging" error
  name="(unset)" requested_reply="0" destination=":1.207" (uid=0
  pid=25793 comm="/usr/sbin/NetworkManager --no-daemon ")

Convert it to a more comprehensible:

  $ nmcli general logging level debug
  Error: failed to set logging: access denied

https://bugzilla.redhat.com/show_bug.cgi?id=1362542
(cherry picked from commit 805925f9ef)
2016-08-20 10:45:55 +02:00
Lubomir Rintel
8cc6ce7e44 cli: add -f argument completion 2016-08-01 15:51:29 +02:00
Lubomir Rintel
2895261c91 cli/connections: do connection completion in get_connection()
Start completing by the id if the filter type is not specified
2016-08-01 13:52:36 +02:00
Lubomir Rintel
1e582f0172 cli: add boolean value completion helper 2016-06-29 20:49:34 +02:00
Lubomir Rintel
e2fe0eeb18 cli: add arbitrary string list completion helper 2016-06-29 20:49:34 +02:00
Lubomir Rintel
1a88eac02a cli: split out do_cmd() 2016-06-29 20:28:42 +02:00
Jiří Klimeš
a14306c2ce cli: do not echo passwords on terminal when asking for them
adds nmc_readline_echo() function that can disable displaying characters.
2015-12-07 14:14:58 +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š
cd217db21c cli: move unique_connection_name() to common.c as nmc_unique_connection_name() 2015-11-09 16:17:39 +01:00
Beniamino Galvani
f208e7030f cli: add 'metered' property to device 2015-06-09 18:11:25 +02:00
Jiří Klimeš
4b799db1d3 cli: add support for secret agent to 'nmcli dev connect' too
And move secrets getting code to common.c (without changes).
2014-11-20 16:36:29 +01:00
Dan Winship
ca18b2d442 libnm: create NMDhcpConfig as parent of NMDhcp4Config and NMDhcp6Config
As with NMIP4Config and NMIP6Config, merge the two DHCP config classes
into one in the public API.
2014-11-07 07:49:40 -05:00
Dan Winship
d34910b128 libnm: create NMIPConfig as parent of NMIP4Config and NMIP6Config
Create NMIPConfig as the parent of NMIP4Config and NMIP6Config, and
remove the two subclasses from the public API; while it's convenient
to still have both internally, they are now identical to the outside
world.
2014-11-07 07:49:40 -05:00
Dan Winship
f17699f4e3 libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway
The gateway is a global property of the IPv4/IPv6 configuration, not
an attribute of any particular address. So represent it as such in the
API; remove the gateway from NMIPAddress, and add it to
NMSettingIPConfig.

Behind the scenes, the gateway is still serialized along with the
first address in NMSettingIPConfig:addresses, and is deserialized from
that if the settings dictionary doesn't contain a 'gateway' key.

Adjust nmcli's interactive mode to prompt for IP addresses and gateway
separately. (Patch partly from Jirka Klimeš.)
2014-11-07 07:49:40 -05:00
Dan Winship
21c8a6b20e libnm-core, all: merge IPv4 and IPv6 address/route types
Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
and NMIP6Route into NMIPRoute. The new types represent IP addresses as
strings, rather than in binary, and so are address-family agnostic.
2014-11-07 07:49:40 -05:00
Dan Winship
6ae4224850 libnm: change GSList to GPtrArray in libnm methods
libnm mostly used GPtrArrays in its APIs, except that arrays of
connections were usually GSLists. Fix this and make them GPtrArrays
too (and rename nm_client_list_connections() to
nm_client_get_connections() to match everything else).
2014-10-28 17:17:17 -04:00
Dan Winship
d0b05b34d5 libnm: add NetworkManager.h, disallow including individual headers
Add NetworkManager.h, which includes all of the other NM header, and
require all external users of libnm to use that rather than the
individual headers.

(An exception is made for nm-dbus-interface.h,
nm-vpn-dbus-interface.h, and nm-version.h, which can be included
separately.)
2014-08-01 14:34:40 -04:00
Dan Winship
3ac0f52878 libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").

NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-08-01 14:34:06 -04:00
Dan Winship
3d25d70461 clients: reorganize source tree, put all the installed clients together
Create a new clients/ subdirectory at the top level, and move cli/ and
tui/ into it, as well as nm-online.c (which was previously in test/,
which made no sense).

cli/ was split into two subdirectories, src/ and completion/. While
this does simplify things (given that the completion file and the
binary both need to be named "nmcli"), it bloats the source tree, and
we can work around it by just renaming the completion file at install
time. Then we can combine the two directories into one and just have
it all under clients/cli/.
2014-07-30 15:56:19 -04:00