Commit Graph

357 Commits

Author SHA1 Message Date
Jiří Klimeš
9e9afdb25b cli: fix memory leaks on questionnaires 2013-10-02 11:48:07 +02:00
Thomas Haller
ed08a3fe04 cli: fix missing type option 'team' in mcli completion
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-30 19:07:18 +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
Dan Winship
e1e4740648 cli: recognize InfiniBand partitions as virtual
We don't need to hardcode the kinds of devices that are virtual here;
NMConnection already knows.
2013-09-24 11:54:34 -04:00
Jiří Klimeš
f8c23077cc cli: fix bond questionnaire to be able to set miimon (rh #1007355)
Bonding options are related and some combinations don't make sense. Basically,
MIIMON and ARP monitoring mode (and related options) are mutually exclusive.
When nmcli set arp_interval of "0" (the default value),
nm_setting_bond_add_option() cleared the MIIMON options (miimon, updelay and
downdelay).

This commit works around libnm-util's nm_setting_bond_add_option() that clears
miimon options when arp_interval is being set and vice versa, but doesn't
take into account the value of "0" that should be regarded as 'disable'.

https://bugzilla.redhat.com/show_bug.cgi?id=1007355
2013-09-19 16:56:37 +02:00
Jiří Klimeš
9dacfd0a39 cli: always print success message (not only in --pretty mode) (rh #1006444)
The commands performing actions without an output only printed a successfull
message for --pretty mode. Some users don't like this silent operation.
This commit makes nmcli print operation success unconditionally. I think that
doesn't hurt; scripts/users can ignore the message if not interested.

https://bugzilla.redhat.com/show_bug.cgi?id=1006444
2013-09-19 15:24:13 +02:00
Jiří Klimeš
05980f9045 cli: fix the error message for valid IPv6 prefix range to <1-128> 2013-09-19 14:06:36 +02:00
Jiří Klimeš
295df3405c cli: accept gateway in the IP questionnaire of 'nmcli -a con add' (rh #1007368)
Also allow leading/trailing white spaces, and more white spaces between IP and
gateway. (Spaces in values and around / are not allowed).
 All of these are accepted:
'  1.2.3.4/11     1.2.3.254 '
' 1.2.3.4 '
'   fe80::215:ff:fe93:ffff/128  ::1 '
...

https://bugzilla.redhat.com/show_bug.cgi?id=1007368
2013-09-19 12:07:22 +02:00
Jiří Klimeš
1f6e1fbc62 cli: editor 'change' command: output -> input format conversion (rh #998929)
The format of property values that nmcli prints is not the same (for some
properties) as the format nmcli editor accepts as input from user. The reasons
are that (a) output format is more descriptive and not much suitable to be
typed, (b) it comes in most cases from libnm-util.
'change' command displays current property value and allows users to edit it.
So we convert the output into input format, before presenting it to the user.

https://bugzilla.redhat.com/show_bug.cgi?id=998929
2013-09-13 10:56:20 +02:00
Dan Williams
e4b92acdf7 cli: clarify 'startup' property when NM is not running
Wouldn't make a ton of sense to print "started" for the STARTING
property if NM wasn't running.
2013-09-12 13:15:50 -05:00
Dan Williams
15ddc6dce3 cli: fix build error due to possibly uninitialized variable 2013-09-12 13:13:09 -05:00
Jiří Klimeš
1df9948199 cli: add STARTUP field for 'nmcli -f all general status'
It says 'starting' when NM is in the process of startup (still activating
connections); 'started' when NM finished the startup.
2013-09-12 16:29:26 +02:00
Thomas Haller
8548d68381 nmcli: extend bash completion for 'nmcli networking connectivity'
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-12 16:19:42 +02:00
Jiří Klimeš
fa36216787 cli: consolidate a code for connectivity check a bit 2013-09-12 14:45:08 +02:00
Jiří Klimeš
449a0933ce cli: don't call g_strstrip() on NULL arguments
GLib-CRITICAL **: g_strchug: assertion `string != NULL' failed
GLib-CRITICAL **: g_strchomp: assertion `string != NULL' failed
2013-09-12 10:03:23 +02:00
Jiří Klimeš
6014e3fa04 cli: fix an 'nmcli con edit' crash
nmcli> desc   AAA
2013-09-11 18:12:51 +02:00
Jiří Klimeš
b62856a0bb cli: set wep-key-type properly in nmcli con edit (rh #1003945)
Accept both [0,1,2] and [unknown,key,passphrase] as wep-key-type values and
set the property value correctly.

https://bugzilla.redhat.com/show_bug.cgi?id=1003945
2013-09-10 16:23:25 +02:00
Jiří Klimeš
555e5b401c cli: reset terminal using libreadline when quitting on signal (bgo #706118)
readline() makes changes to terminal and when it doesn't receive unix signals,
it has no chance to perform cleanups on exit. So we have to call its cleanup
functions manually on exit.

https://bugzilla.gnome.org/show_bug.cgi?id=706118
2013-09-10 11:45:21 +02:00
Jiří Klimeš
663014ed62 cli: handle POSIX signals in a dedicated thread
For a multihreaded application the safest way to handle unix signals is using
a dedicated thread that processes the signals by sigwait() function. All other
threads have these signals (processed by the thread) blocked.

A few useful links:
http://pubs.opengroup.org/onlinepubs/007904975/functions/sigwait.html
http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.genprogc%2Fdoc%2Fgenprogc%2Fsignal_mgmt.htm
http://www.linuxjournal.com/article/2121?page=0,2
http://www.redwoodsoft.com/~dru/unixbook/book.chinaunix.net/special/ebook/addisonWesley/APUE2/0201433079/ch12lev1sec8.html
https://www.securecoding.cert.org/confluence/display/seccode/CON37-C.+Do+not+call+signal%28%29+in+a+multithreaded+program
2013-09-10 11:41:00 +02:00
Thomas Haller
7ad5c79441 nmcli: minor fixes in bash completion
- the ifname argument for "connection add" is not mandatory
- support the long names for connection types ("802-*")

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-06 17:47:57 +02:00
Jiří Klimeš
9f09ebd582 cli: forbid removing connection.uuid in editor
We expect that UUID is set, else there are various errors. Anyway, users should
not modify connection UUID.
2013-09-06 15:14:30 +02:00
Jiří Klimeš
2eede80108 cli: deny removing values of nmcli-unchangable properties
nmc_setting_reset_property() function checks whether we allow changing the property
(set_func != NULL) and if so, the property value is reset to default.
2013-09-06 15:00:34 +02:00
Jiří Klimeš
70cc30cb73 cli: add missing connection:type to nmc_add_prop_funcs() in editor 2013-09-06 14:12:26 +02:00
Jiří Klimeš
242bebfb3d cli: add 'remove' command to the interactive editor
remove <setting>[.property] | <property>

It entirely removes given setting from edited connection. If a property is given,
the command instead resets the property to its default value.

https://bugzilla.gnome.org/show_bug.cgi?id=707576
2013-09-06 10:10:37 +02:00
Jiří Klimeš
c2faf32b88 cli: 'connection add' - questionnaire mode (rh #953291)
Synopsis: nmcli --ask connection add

When '--ask' is used, nmcli will ask not only for mandatory arguments but also
for the optional ones, with a series of questions.
2013-09-06 09:16:46 +02:00
Thomas Haller
f6703f540c nmcli: reword error message for a wrong user input in edit mode
Before, when specifying a setting.property with missing property name,
the following happened:

  nmcli> set connection.
  Error: invalid property: '' not among [...

Reword this special error case of a missing property to make it more
clear.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 20:02:12 +02:00
Thomas Haller
1111dbf812 nmcli: fix segfault in edit mode when parsing user prompt
readline_x returns NULL for empty input, so it is wrong
to call g_strstrip without checking for NULL first.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 13:59:54 +02:00
Thomas Haller
fc7468131c nmcli: major rework of bash completion
Bash completion does now parse the command line from left to right and
only suggests options that make sense at the current cursor position.

If the cursor is not at the end of the line, the words right from the
cursor are ignored for completion. The reason is, that it would be much
more difficult to figure out the valid options when also looking at
options right from the cursor. However, it should still work nicely
even in this case.

There is still an unsolved issue when completing words with space or
other special characters. However, this issue was present before.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-05 10:47:41 +02:00
Jiří Klimeš
50bec85f98 cli: allow editing team and team-port settings in interactive editor 2013-09-04 12:43:11 +02:00
Jiri Pirko
96303bd9da cli: add missed setting name to nmc_team_slave_settings
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-09-04 12:43:11 +02:00
Jiri Pirko
d338b90cfd cli: add config option for team devices
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-09-04 12:43:11 +02:00
Jiri Pirko
97be00f9e0 cli: add team port setting
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-09-04 12:43:11 +02:00
Jiri Pirko
eb05cbeb9c cli: add team and team-slave detail printing
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-09-04 12:43:11 +02:00
Thomas Haller
00e1e20b16 nmcli: special error message for access denied when SetLogging fails
Setting the logging level fails for normal users due to missing dbus
permissions as configured in src/org.freedesktop.NetworkManager.conf.

In that case, nmcli simply fails showing the dbus error. This error
is however not very clear, so this commit shows a different error
text for the particular case of ACCESS_DENIED.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-04 11:56:46 +02:00
Jiří Klimeš
2d9366bcee cli: connect IP addresses/method handlers for existing connections (rh #998137)
The handlers detecting changes of IP addresses/method in nmcli interactive
editor were connected only for newly created connection. That's why the
automagic feature of setting 'method' when 'addresses' are changed and vice
versa worked just for new connections, but not while editing existing
connections.
2013-09-02 13:20:04 +02:00
Jiří Klimeš
36465df124 cli: remove 802-11-wireless.security property from nmcli as it is deprecated
If a Wi-Fi connection is secured, it contains 802-11-wireless-security setting.
That's it. There's no need to have this property.
2013-09-02 09:46:31 +02:00
Jiří Klimeš
1be3bf17bc cli: add missing 802-1x setting for Wi-Fi connections in the editor
Without that Enterprise type Wi-Fi could not be edited via the nmcli
interactive editor.
2013-08-29 15:56:48 +02:00
Jiří Klimeš
d7788b0d46 cli: fix TAB-completion for aliases in interactive editor
Before the change if an alias for a setting name existed, it was used instead of
the real name and TAB-completion for the real name didn't work.

before:
nmcli> goto 802<TAB>
no output

now:
nmcli> goto 802<TAB>
nmcli> goto 802-11-wireless
802-11-wireless           802-11-wireless-security

nmcli> goto <TAB>
802-11-wireless-security (wifi-sec)  connection                       ipv6
802-11-wireless (wifi)               ipv4
2013-08-29 15:36:55 +02:00
Jiří Klimeš
d646cf909f cli: disable setting 'rate' and 'tx-power' properties in editor
The properties are not implemented in NM core, nor in ifcfg-rh plugin. Thus
they are not preserved over re-reading from ifcfg-* file. Moreover they are
highly dependent on drivers.
When we allowed editing them, the connection changed after re-reading and
was marked as dirty (and users were puzzled).
2013-08-29 13:43:00 +02:00
Dan Winship
a854a273c9 cli: add connectivity support 2013-08-28 10:54:09 -04:00
Thomas Haller
c3ea945c19 nmcli: fix errors in nmcli help output and man page
Fix some spelling errors and wrong parameter description. Also add the
team connection to the manual page.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-28 15:26:50 +02:00
Thomas Haller
2d2b2a48eb cli: change completion to suggest connection ids
Before, whereever a connection id is accepted, the completion only
offered 'id', 'uuid', 'path', etc. With this change, it will additionally
suggest the id of existing connections.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-28 14:36:49 +02:00
Thomas Haller
ab231cb0d9 cli: improve bash completion by parsing options separately.
To support optimal completion, more context must be considered.
Especially the OPTIONS, which must appear before the OBJECT.
Modify bash completion to try parsing first the options.

Before, whenever you had options, completion did not work
anymore (because the object was expected as first argument).
Moreover, options were also suggested after specifying the
object. This is now mitigated by parsing the command line
in two steps.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-28 14:36:49 +02:00
Jiří Klimeš
3cb0bf6bc0 cli: consider empty value as "*" for "Interface name: " prompt 2013-08-27 10:20:41 +02:00
Thomas Haller
a7588227ed cli: bugfix verification for wifi channel in edit mode
This bug caused the edit mode to refuse most of the valid wifi channels.
The bug was present since the beginning, so all versions before this
commit will have this issue.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-23 17:13:56 +02:00
Dan Winship
bfce3f7dc8 build: switch from $(INCLUDES) to $(AM_CPPFLAGS) to make automake happy
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.

In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
2013-08-22 11:49:16 -04:00
Thomas Haller
76186d652f nmcli: strip whitespace when reading property name in edit mode
When reading the property name in edit mode, any white space should be
striped from the entered value. Especially, because tab completion will
add a trailing whitespace.

Example:

  $ nmcli connection edit
  Enter connection type: ethernet
  nmcli> goto connection
  nmcli connection> describe
  Property name? u<TAB>

The <TAB> will complete 'u' to 'uuid '.
This whitespace should be allowed and striped.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-21 10:54:56 +02:00
Thomas Haller
d6aaa988db cli: highlight 'describe' command for edit mode.
When editing starts, print a info message pointing to the 'describe'
command.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-21 10:38:49 +02:00
Jiri Pirko
a523a431d3 cli: add team driver support
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00