Commit Graph

194 Commits

Author SHA1 Message Date
Jiří Klimeš
26f8889286 cli: consolidate active and configured connections (rh #997999)
Handle connection profiles in a single 'show' command instead of 'show active'
and 'show configured'.

nmcli con show [--active] [[id|uuid|path|apath] <bla>]

nmcli con show           : display all connection profiles
nmcli con show --active  : only display active connection profiles
                           (filters out inactive profiles)

nmcli con show myeth     : display details of "myeth" profile, and also active
                           connection info (if the profile is active)
nmcli -f profile con show myeth : only display "myeth"'s static configuration
nmcli -f active  con show myeth : only display active details of "myeth"
nmcli -f connection.id,ipv4,general con show myeth
                                          : display "connection.id"a property
                                            "ipv4" setting and "GENERAL" group
                                            of active data

https://bugzilla.redhat.com/show_bug.cgi?id=997999
2014-01-23 13:45:46 +01:00
Jiří Klimeš
6b19d530e8 cli: always get up-to-date dirty status 2014-01-21 16:39:43 +01:00
Jiří Klimeš
92939e6919 cli: fix crash when edited profile was removed by another client (rh #1011942)
Use g_weak_ref_get() that either returns an object with reference increment or
returns NULL.
That fixes the problem.  However, in the long run we should rework the editor
loop trying to merge that with GMainLoop, which could help for various issues.

https://bugzilla.redhat.com/show_bug.cgi?id=1011942
2014-01-21 16:36:00 +01:00
Jiří Klimeš
07adfe4de4 cli: fix TAB-completion and 'goto' after saving connection
On 'save' we replace settings in the local connection, so we also need to
update stored setting pointers.
2014-01-20 17:38:11 +01:00
Jiří Klimeš
e44bb5e6fc cli: add 'help' for second level commands (bgo #698237) (rh #1034119)
In addition to 'nmcli connection help', you can now use:
nmcli con up help
nmcli con down help
nmcli dev wifi help
etc.

The help option can also be in the form of --help/-h, or even shortened.

https://bugzilla.gnome.org/show_bug.cgi?id=698237
https://bugzilla.redhat.com/show_bug.cgi?id=1034119
2014-01-09 10:14:03 +01:00
Dan Winship
f1f4f32c02 cli: get IP/DHCP config directly from the NMActiveConnection (rh #1036132)
Now that NMActiveConnection has IP and DHCP config info, use that
directly in "nmcli con show active" rather than getting it from the
connection's device; this way, we get the right info for VPN
connections as well.
2013-12-19 11:49:50 -05:00
Jiří Klimeš
107fdd6b01 cli: support PPPoE connection types in 'nmcli con add' 2013-12-18 16:45:59 +01:00
Jiří Klimeš
80851c3550 cli: consider empty value as "*" for "Interface name [*]: " prompt (rh #953397)
And, do it right this time.

https://bugzilla.redhat.com/show_bug.cgi?id=953397
2013-12-18 16:10:48 +01:00
Jiří Klimeš
340542a2f2 Revert "cli: consider empty value as "*" for "Interface name: " prompt"
This reverts commit 3cb0bf6bc0.
It broke 'ifname' being required as a mandatory parameter as decided in
https://bugzilla.gnome.org/show_bug.cgi?id=698113
2013-12-18 16:05:37 +01:00
Jiří Klimeš
d79b56a7e9 cli: 'id' option for 'nmcli con add type vlan' is mandatory (rh #953397)
So update documentation accordingly.

https://bugzilla.redhat.com/show_bug.cgi?id=953397
2013-12-18 15:49:10 +01:00
Jiří Klimeš
4ef8696c77 cli: allow '--field group.field' for nmcli con show conf <bla>
That means you can display single property.

Example:
$ nmcli -f connection.id,802-3-ethernet.mtu s c my-eth-profile
connection.id:                          my-eth-profile
802-3-ethernet.mtu:                     auto
2013-12-17 13:52:11 +01:00
Jiří Klimeš
990f83b7d3 cli: allow '--field group.field' for nmcli con show active <bla>
Example:
$ nmcli -f general.name,ip4.address c s a myeth
GENERAL.NAME:                           myeth
IP4.ADDRESS[1]:                         ip = 10.34.25.228/23, gw = 10.34.25.254
2013-12-17 13:52:02 +01:00
Jiří Klimeš
94bb83a370 cli: allow specifying 'group.name' syntax for '--fields'
and use it for 'nmcli device show'.

This allows filtering output not only for whole groups, but also for individual
fields in commands that print data in groups (sections).

Example:
$ nmcli -f general.device,general.driver,ipv4,ipv6.address device show eth0
GENERAL.DEVICE:                         eth0
GENERAL.DRIVER:                         e1000e
IP4.ADDRESS[1]:                         ip = 10.0.5.228/23, gw = 10.0.5.254
IP4.ADDRESS[2]:                         ip = 5.5.5.5/32, gw = 5.5.5.1
IP4.DNS[1]:                             192.168.122.1
IP4.DNS[2]:                             8.8.8.8
IP4.DOMAIN[1]:                          mycompany.com
2013-12-17 13:51:34 +01:00
Jiří Klimeš
72922f2068 cli: fix description of connection parameters and specify some default values 2013-12-13 09:50:09 +01:00
Jiří Klimeš
df104771ae cli: support PPPoE connection type in nmcli connection editor 2013-12-11 16:54:17 +01:00
Jiří Klimeš
62f07eea26 cli: fix nmcli help for connection object (rh #1036545)
https://bugzilla.redhat.com/show_bug.cgi?id=1036545
2013-12-02 15:40:11 +01:00
Jiří Klimeš
655af71c6d nmcli: fix connecting VLANs without an explicit interface-name (rh #1034908)
nm_connection_get_virtual_iface_name() doesn't work when determining virtual
connections, because for VLANs it can return NULL.

See also commit e1e4740648.

https://bugzilla.redhat.com/show_bug.cgi?id=1034908
2013-11-28 16:50:42 +01:00
Dan Williams
d35cb5b77c cli: add support for DCB settings 2013-11-27 10:05:43 -06:00
Dan Winship
461920bb96 cli: add NMC_RESULT_ERROR_NOT_FOUND and use as appropriate
This will allow callers to distinguish "no such connection" from
"connection failed to activate", etc.

https://bugzilla.redhat.com/show_bug.cgi?id=1022256
2013-11-22 13:51:25 -05:00
Jiří Klimeš
472ee8104d cli: initialize interface-name for new team connections in editor 2013-11-22 14:28:08 +01:00
Jiří Klimeš
cdec23d314 cli: complete file names for properties whose value is a file name
Note:
Tilde expansion is enabled, so ~/abc<TAB> expands the string to /home/joe/abc.
However, when user did not use the completion and typed "~/myfile" manually,
the path could not be opened.

nmcli 802-1x.ca-cert> set ~/newca.crt
Error: failed to set 'ca-cert' property: Failed to open file '~/newca.crt': No such file or directory
2013-11-22 14:09:10 +01:00
Jiří Klimeš
a3c06afc12 cli: support file names for 'config' argument when creating team connections
nmcli con add type team config /home/cimrman/team-config.json

libteam (and in turn NetworkManager) configures team devices via plain config
data in JSON format. However, it is useful and more user-friendly for nmcli to
accept also a file name that contains the config data, and read it. Thus the
user is not forced to type whole (possibly long) config on the command line.
2013-11-22 14:09:10 +01:00
Dan Winship
9a532db182 cli: add "nmcli con load file..."
https://bugzilla.gnome.org/show_bug.cgi?id=709830
2013-11-15 13:39:40 -05:00
Jiří Klimeš
2a2af5825a cli: allow editing 'generic' connections 2013-11-14 13:53:44 +01:00
Jiří Klimeš
dbba05a3db cli: fix crash on editing 'lo' connection (rh #1030395)
https://bugzilla.redhat.com/show_bug.cgi?id=1030395
2013-11-14 13:53:21 +01:00
Thomas Haller
97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
ab92a0d69c cli: fix reading IP config for *-slaves
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
0139ad37f7 cli: fix potential crash in nmcli when using strcmp
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
c9cfbae12b cli: make command line parsing check for help option first
Move the checks for nmc_arg_is_help to the beginning of the
checks for command matches.

Up to now, no command begins with 'h', so this has no behavioral
change whatsoever. But imagine a command that begins with 'h'
(for example `nmcli general hostname`), in that case `nmcli general h`
should still show the help, as users might be accustomed to this
abbreviation.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:45 +01:00
Jiří Klimeš
5a4e40bacf cli: fix 'nmcli con up bad_name' or 'nmcli con up'
** (process:25157): CRITICAL **: nmc_activate_connection: assertion `NM_IS_CONNECTION (connection) || ifname' failed
Error: unknown error.

Regression caused by 42c7ea85a1.
2013-11-07 18:01:16 +01:00
Dan Williams
42c7ea85a1 cli: add support for 'nmcli con up ifname XXX'
Passes a NULL connection to nm_client_activate_connection() allowing
NetworkManager to pick the best available connection for the interface.
2013-10-31 15:45:20 -05:00
Jiří Klimeš
375220cae1 cli: TAB-complete devices for 'activate' command in the editor 2013-10-31 09:00:56 +01:00
Jiří Klimeš
8d9718bd0f cli: add 'activate' menu command for interactive editor (rh #1004883)
This command allows activating the edited connection.

Monitoring the progress of the activation is a bit complicated by the fact
that the callback activate_connection_editor_cb() is invoked in main loop
thread, and not in the editor thread itself.

https://bugzilla.redhat.com/show_bug.cgi?id=1004883
2013-10-31 08:53:56 +01:00
Jiří Klimeš
26dca13c7e cli: fix VLAN egress priority mapping for 'nmcli connection add'
Found with Coverity.
2013-10-30 17:25:45 +01:00
Jiří Klimeš
a4004fd2e9 cli: fix new connection initialization in the editor
This fixes a regression caused by ecd49fb435

In addition, initialize Wi-Fi mode to "infrastructure".
2013-10-25 14:26:00 +02:00
Jiří Klimeš
9ca6fa71f1 cli: do not pass con_type to callbacks, get the type from device
This simplifies the code.

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2013-10-23 22:22:35 -04:00
Dan Winship
0221971da5 nmcli: fix some leaks found by valgrind
https://bugzilla.gnome.org/show_bug.cgi?id=709369
2013-10-23 22:22:35 -04:00
Jiří Klimeš
ecd49fb435 cli: add IPv{4,6} setting for all new non-slave connections in editor 2013-10-23 16:22:18 +02:00
Jiří Klimeš
3d14d52325 cli: copy remote connection to local one on 'save' (rh #997958)
Plugins may have problems with preserving some properties on write/read cycle,
may add ipv{4,6} settings when they are not present in the connection, etc.
That makes local and remote connection differ.
So we copy remote connection into the local to get rid of such problems.

Note:
68f12b4e9c and
f03635e5ac
commits ensure that all connection (except slaves) have IPv{4,6} settings.

https://bugzilla.redhat.com/show_bug.cgi?id=997958
2013-10-23 16:22:18 +02:00
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Jiří Klimeš
6a8fd3f469 cli: properly initialize new team-slave connections in editor 2013-10-21 16:30:04 +02:00
Yuri Chornoivan
61de24ba35 Fix typos
https://bugzilla.gnome.org/show_bug.cgi?id=710505
2013-10-19 11:49:18 -04:00
Jiří Klimeš
b2ff06fc12 cli: fix a possible crash when casting NULL using NM_CONNECTION (rh #1011942)
https://bugzilla.redhat.com/show_bug.cgi?id=1011942
2013-10-03 19:14:16 +02:00
Jiří Klimeš
8695410d86 cli: enhance TAB-completion in nmcli editor
- completion now works for command shortcuts too
  nmcli> g ethe<TAB>
- completion now allows leading spaces
  nmcli>   desc wifi.ss<TAB>
- fix completion of settings when property is already there
  nmcli> set con<TAB>.id
- fix completion of properties in setting.property
  nmcli> des con.inter<TAB> bla
2013-10-03 16:39:30 +02:00
Jiří Klimeš
e6fa711088 trivial: remove stray ')' from nmcli prompts in questions 2013-10-02 11:48:07 +02:00
Jiří Klimeš
62d113f6c2 cli: accept 'primary' bonding option 2013-10-02 11:48:07 +02:00
Jiří Klimeš
1bb78f6ecf cli: enhance questionnaire for bond connections (rh #1007355)
The session now looks like this:

There are optional arguments for 'bond' connection type.
Do you want to provide them? (yes/no) [yes]
Bonding mode [balance-rr]:
Bonding monitoring mode (miimon or arp) [miimon]: miimon
Bonding miimon [100]:
Bonding downdelay [0]:
Bonding updelay [0]:

...when answered arp...
Bonding arp-interval [0]:
Bonding arp-ip-target [none]:

https://bugzilla.redhat.com/show_bug.cgi?id=1007355
2013-10-02 11:48:07 +02:00
Jiří Klimeš
9e9afdb25b cli: fix memory leaks on questionnaires 2013-10-02 11:48:07 +02:00
Jiří Klimeš
a74d3678d1 cli: use a generic function asking for both IPv4/IPv6 in questionnaire 2013-09-30 13:42:13 +02:00
Jiří Klimeš
5ba3e42b1e cli: be more verbose when adding IP addresses in questionnaire (rh #1006450)
Now the session looks like this:
Do you want to add IP addresses? (yes/no) [yes]
Press <Enter> to finish adding addresses.
IPv4 address (IP[/plen] [gateway]) [none]: 10.0.0.22/24 10.0.0.1
  Address successfully added: 10.0.0.22/24 10.0.0.1
IPv4 address (IP[/plen] [gateway]) [none]: 10.0.0.22/24 10.0.0.1
  Warning: address already present: 10.0.0.22/24 10.0.0.1
IPv4 address (IP[/plen] [gateway]) [none]: 192.168.1.1 abc
Error: invalid gateway 'abc'
IPv4 address (IP[/plen] [gateway]) [none]:
IPv6 address (IP[/plen] [gateway]) [none]: abcd::1234 ::2 blabla
  Address successfully added: abcd::1234 ::2
  Warning: ignoring garbage at the end: 'blabla'
IPv6 address (IP[/plen] [gateway]) [none]:
2013-09-30 13:39:44 +02:00