Commit Graph

357 Commits

Author SHA1 Message Date
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
Thomas Haller
7698d5dfc0 cli: bash completion completes filenames for team "config" property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-22 14:10:34 +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
Thomas Haller
32b67cd1be cli: bash completion must not suggest IP options for adding slave types
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 16:38:07 +01:00
Jiří Klimeš
160d6f073e cli: add missing reason-to-string mappings for NMDeviceStateReason 2013-11-18 16:17:23 +01:00
Thomas Haller
df7406fcf2 cli: add 'config' option to bash completion when adding team-slave connection
Like 'team', 'team-slave' also understands the property 'config'.
Add it to bash completion for the 'connection add' command.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-18 12:12:20 +01:00
Thomas Haller
6241366f30 cli: adjust bash completion for nmcli connection load <file>...
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-15 13:39:42 -05: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
bbddc0e18a cli: fix bash completion for curser not at EOL (2)
Previous commit had an error in the following case:
  $ nmcli connection modify  '  <TAB>     id

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:02:23 +01:00
Thomas Haller
93f5687d7b cli: fix bash completion for curser not at EOL
If the curser is not at the end of the line, we want to complete
by ignoring everything right of the curser. However, the variable
$cur is set to the spaces since the last word, so we have to
get rid of them first

Without this, the following did not complete:
  $ nmcli connection modify id   <TAB>  lo
because $cur is set to '  '.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 14:42:59 +01:00
Thomas Haller
ce370fab64 cli: add bash-completion for 'nmcli general hostname'
https://bugzilla.redhat.com/show_bug.cgi?id=1018510
2013-11-13 12:19:51 +01:00
Jiří Klimeš
79ac1cf089 cli: add support for getting/setting hostname to nmcli (rh #1018510)
https://bugzilla.redhat.com/show_bug.cgi?id=1018510
2013-11-13 12:19:51 +01:00
Thomas Haller
d95da820fc cli: tivial fixup whitespace in command description text
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-12 20:45:05 +01:00
Thomas Haller
ed60815d4c cli: improve handling of quoting in bash completion
_init_completion returns the '${words[@]}' array with all the
quotes and escapes. We dont care about it so we drop (unescape)
first.

Before, the following failed:

  nmcli 'c' <TAB>
  nmcli connection modify id Wireless\ Connection\ 1 <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-12 18:49:03 +01:00
Thomas Haller
6107a94099 cli: improve bash completion to complete -h and --help aliases
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:45 +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
Thomas Haller
93131b1df2 cli: fix in matching command line arguments
Ensure in matches() that a non-empty cmd is given, otherwise
as currently

  nmcli general -

matches to '-h' and is thus treated as

  nmcli general -h

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:30 +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
7d57386e04 cli: add support for 'nmcli dev connect ifname XXX' 2013-10-31 15:45:21 -05: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
Thomas Haller
623f8a2be1 cli: fix bash completion for nmcli connection modify
Only complete the setting name if it is at the very first
position after the connection.

e.g. complete the settings name in the case
  $ nmcli connection modify em1 connec<TAB>
but not at
  $ nmcli connection modify em1 connection.autoconnect <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-30 13:33:47 +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
Thomas Haller
2a7c976539 cli: show property names in bash completion for nmcli connection modify
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-24 14:52:08 +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
jvoisin
00ffb78c8d core: add support for EAP-PWD authentication 2013-10-23 21:07:30 -05: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
Thomas Haller
78a8df37d8 cli: fix bash completion to show general options
This fixes an error in the following example:
  $ nmcli con add type bridge con-name test-bridge <TAB>

Before, general options such as 'autoconnect' and 'ifname' were
wrongly not suggested.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-03 16:05:44 +02:00
Thomas Haller
f37686fba7 cli: add primary bonding option in bash completion
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-02 14:19:12 +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