Commit Graph

424 Commits

Author SHA1 Message Date
Jiří Klimeš
a1e89b4d29 cli: fix bridge priority default value (rh #1073664)
It is 32768 (0x8000) instead of 128 (0x80). 13c348d fixes that in the setting.

https://bugzilla.redhat.com/show_bug.cgi?id=1073664
2014-03-17 09:08:23 +01:00
Jiří Klimeš
08ed6c5be2 cli: sanitize team config before setting it into property
Replace '\r' and '\n' chareacter with a space in the configuration.
libteamdctl sends the config to team daemon using its usock interface that
separates parameters with '\n'.

Related: rh #1051517
2014-03-12 10:44:29 +01:00
Jiří Klimeš
d7e1ec9183 cli: accept prefix "ifname/", "uuid/" or "id/" for 'master' argument
nmcli con add type team-slave ifname em2 master team-master0
nmcli con add type team-slave ifname em2 master id/team-master0

It helps to disambiguate values for cases where they may overlap,
e.g. "team0" -> "ifname/team0" or "id/team0"
2014-03-12 10:32:37 +01:00
Jiří Klimeš
90c02cafdc cli: allow specifying 'master' for slaves as connection ID (rh #1057494)
nmcli con add type *-slave ifname em1 master <ifname|UUID|name>

'master' property of 'connection' setting has to be either interface name or
connection UUID of master connection. However, to make nmcli more convenient
for users, we also allow specifying connection name and translating it to UUID
automatically.

https://bugzilla.redhat.com/show_bug.cgi?id=1057494
2014-03-12 10:32:11 +01:00
Jiří Klimeš
296d7f6ec7 cli: fix a crash when trying to set a white-space string as IP (rh #1071394)
nmcli con modify my-profile ipv4.addr "   "
nmcli con modify my-profile ipv6.addr "   "

Note:
Empty string should be used to remove IPs, and 'method' might be needed to set
to 'auto' simultaneously, as well.
$ nmcli con modify profile1 ipv4.addr "" ipv4.method auto

https://bugzilla.redhat.com/show_bug.cgi?id=1071394
2014-03-03 12:50:02 +01:00
Thomas Haller
90ff0786cc cli/bash-completion: fix nmcli connection CMD completion for --help option
The --help option (or its aliases -help/help) is only allowed at as
first argument. Fix completion to account for this.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-02 17:55:14 +01:00
Thomas Haller
74b3c22e2f cli/bash-completion: only allow --help as first argument for nmcli connection modify
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-01 02:07:53 +01:00
Thomas Haller
9d7a1d4253 cli/bash-completion: use printf instead of echo (because echo inteprets some --options)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-01 02:07:53 +01:00
Thomas Haller
39dc39ec0a cli/bash-completion: simplify code by passing arrays by indirection to functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-01 02:07:53 +01:00
Thomas Haller
62cf1d85ff cli/bash-completion: complete more then one connections for nmcli connection delete
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-28 14:14:32 +01:00
Thomas Haller
4196cc1179 cli/bash-completion: complete more then one properties for nmcli connection modify
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-28 14:14:32 +01:00
Thomas Haller
280881f552 cli/bash-completion: complet nmcli connection modify --temporary
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-28 14:14:32 +01:00
Thomas Haller
07cdf56a67 cli/bash-completion: support abbreviated options for commands
Add support for abbreviated options as first argument:

nmcli connection show --act <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-28 14:14:32 +01:00
Thomas Haller
7423bc4460 cli/bash-completion: support abbreviations for options
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-28 14:14:32 +01:00
Jiří Klimeš
ebb601302a cli: update 'nmcli con modify' help 2014-02-28 11:44:34 +01:00
Jiří Klimeš
a5673d113c cli: update 'remove' command description for 'nmcli con edit'
to reflect that user can specify a value or index to remove values.
2014-02-28 11:17:49 +01:00
Jiří Klimeš
f29ad0bd52 cli: allow removing properties by-value (in addition to by-index)
It works both in 'nmcli con modify' and 'nmcli con edit'.

The following properties are supported (all container-type properties except
properties with option names):
ipv4.dns
ipv4.dns-searches
ipv4.addresses
ipv4.routes

ipv6.dns
ipv6.dns-searches
ipv6.addresses
ipv6.routes

802-1x.eap
802-1x.altsubject-matches
802-1x.phase2-altsubject-matches

connection.permissions
connection.secondary

802-3-ethernet.mac-address-blacklist

802-11-wireless.mac-address-blacklist

802-11-wireless-security.proto
802-11-wireless-security.pairwise
802-11-wireless-security.group

vlan.ingress-priority-map
vlan.egress-priority-map
2014-02-28 11:17:17 +01:00
Jiří Klimeš
c1ace1b5b2 cli: support removing items from container-type properties in 'nmcli con modify'
Synopsis:
nmcli con modify -<property>.<setting> <value>

'value' can be empty ("") to remove the whole property value value (in this
case the behaviour is the same as without '-').
Or the 'value' is an index of the item to remove, or an option name (for a few
properties that have option names, like bond.options or ethernet.s390-options).

$ nmcli con mod myeth ipv4.dns "10.0.0.55 10.0.0.66 8.8.8.8 8.8.4.4"
---> ipv4.dns: 10.0.0.55, 10.0.0.66, 8.8.8.8, 8.8.4.4
$ nmcli con mod myeth -ipv4.dns 1
---> ipv4.dns: 10.0.0.55, 8.8.8.8, 8.8.4.4

---> bond.options: mode=balance-rr
$ nmcli con mod bond0 +bond.options "mii=500, downdelay=800"
---> bond.options: downdelay=800,miimon=500,mode=balance-rr
$ nmcli con mod bond0 -bond.options downdelay
---> bond.options: miimon=500,mode=balance-rr
2014-02-28 10:31:41 +01:00
Jiří Klimeš
a1c3021aa9 cli: allow modifying multiple properties by 'nmcli con modify'
This is necessary especially for cases where properties depend on each other.
So you need to set them in one command, else the profile won't validate.

Examples:
nmcli con mod em1-1 ipv4.method manual ipv4.addr "192.168.1.2/24,10.10.1.5/8"
nmcli con mod profile ipv4.method link-local ipv4.addr ""
2014-02-28 10:31:41 +01:00
Jiří Klimeš
431b75824b cli: set vs. append property value by 'nmcli con modify' (rh #1044027)
Previously 'nmcli con modify' appended values for multi-value properties.
This commit makes 'nmcli con modify' overwrite the whole value. You can
choose appending values by prefixing the setting.property with '+' sign.
For simple (not container) properties the behaviour is the same both with
and without the '+', of course.

Synopsis:
  nmcli connection modify [+]<setting>.<property <value>

Example:
---> ipv4.dns = 1.2.3.4
$ nmcli connection modify my-em1 ipv4.dns 8.8.8.8
---> ipv4.dns = 8.8.8.8
$ nmcli connection modify my-em1 +ipv4.dns 8.8.4.4
---> ipv4.dns = 8.8.8.8 8.8.4.4

https://bugzilla.redhat.com/show_bug.cgi?id=1044027
2014-02-28 10:31:40 +01:00
Jiří Klimeš
a8e6094e40 cli: allow temporary connection modification by 'nmcli con modify'
nmcli connection modify [--temporary] ...
2014-02-28 10:31:40 +01:00
Thomas Haller
7d73ee75df trivial: more wrong compiler warnings
connection_parser.c: In function 'make_ip4_setting':
  connection_parser.c:660:33: error: 'method' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (!is_static_block && strstr (method, "dhcp")) {

  connections.c: In function ‘load_cmd_line_edit_lib’:
  connections.c:5744:17: error: ‘module’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    g_module_close (module);

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 18:31:07 +01:00
Thomas Haller
d3a2219cee replace snprintf by g_snprintf
Use the glib wrapper for snprintf.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:35:33 +01:00
Thomas Haller
8a67713e9e cli: allow resetting the connection.master to NULL
Without this patch, the following two commands fail:
  nmcli connection modify em1 connection.master
  nmcli connection modify em1 connection.master ""

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 09:44:29 +01:00
Jiří Klimeš
a493cda8d6 cli: better checking of WEP key types in nmcli interactive editor (rh #1040964)
https://bugzilla.redhat.com/show_bug.cgi?id=1040964
2014-02-17 15:22:35 +01:00
Dan Winship
9c4d86ee80 libnm-util, libnm-glib: add versioned deprecation/availability macros
Add versioned NM_DEPRECATED_IN_* and NM_AVAILABLE_IN_* macros, and tag
new/deprecated functions accordingly. (All currently-deprecated
functions are assumed to have been deprecated in 0.9.10.)

Add NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED macros which
can be set to determine which versions will cause warnings.

With the current settings, external consumers of the
libnm-util/libnm-glib APIs will have MIN_REQUIRED and MAX_ALLOWED both
set to NM_VERSION_0_9_8 by default, meaning they will get warnings
about functions added in 0.9.10. NM internally sets
NM_VERSION_MAX_ALLOWED to NM_VERSION_NEXT_STABLE to ensure that it is
always allowed to use all APIs.
2014-02-13 11:24:37 -05:00
Thomas Haller
c52decbfcb cli: show warning when setting band/channel for infra mode (rh #1000096)
The band/channel property is not considered when connecting to an
access point. Print a warning, when setting one of these values in edit
mode.

For now, don't forbid the user to make such setting. Also, because in
the future, wpa_supplicant might support this.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-13 12:22:52 +01:00
Jiří Klimeš
84721804cd cli: fix crash if active connection doesn't have a device (rh #1064333)
$ nmcli dev connect wlan0

This can happen for example when some other process disconnects
the connection being connected.
Also fix printing a message on success.

https://bugzilla.redhat.com/show_bug.cgi?id=1064333
2014-02-12 16:31:39 +01:00
Thomas Haller
c960d474fb cli/bash-completion: make 'ifname' a mandatory parameter for nmcli connection add
For some connection types (bond, bridge, team and vlan), 'ifname' is
optional.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 15:44:16 +01:00
Thomas Haller
6d25080e6a cli/bash-completion: complete 'save' option for nmcli connection add
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 10:49:51 +01:00
Jiří Klimeš
ec0f629ed2 cli: persistent vs. temporary save for 'nmcli con edit' 2014-01-30 10:49:51 +01:00
Jiří Klimeš
2d523bd800 cli: allow creating temporary (unsaved) connection with 'nmcli con add' 2014-01-30 10:49:51 +01:00
Dan Williams
b69e7c451e cli: handle hidden-SSID access points correctly 2014-01-23 17:34:11 -06:00
Thomas Haller
b5e2a45266 cli/bash-completion: update completion for new nmcli connection show syntax
As nmcli changes the syntax for the 'connection show' command,
this patch for bash completion also breaks several cases when
completing for an old nmcli command.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-23 13:46:46 +01:00
Jiří Klimeš
0c4d2b2b9e cli: allow processing all connections with the same name
When there are multiple connection profiles of the same name, we used to take
and process only the first one.
We change the behaviour to process all the connections now in these commands:

nmcli connection show   <duplicated name>
nmcli connection down   <duplicated name>
nmcli connection delete <duplicated name>
2014-01-23 13:46:46 +01:00
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
Dan Winship
e9fe63cdaa trivial: annotate/adjust some code to appease Coverity 2014-01-16 14:23:45 -05:00
Jiří Klimeš
a6432ef4d1 cli: fix printing error on incorrect 'nmcli -f blah dev show'
Don't print extra empty lines before the error.
2014-01-10 13:21:27 +01:00
Thomas Haller
446516bcfa cli/bash-completion: trivial rename of functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 12:12:13 +01:00
Thomas Haller
e59be00d93 cli/bash-completion: add second level help option
Commands now support help at the second level. Add completion for it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 12:12:13 +01:00
Thomas Haller
b4d9958b76 cli/bash-completion: only complete active connections for nmcli con down
Only complete the ids/uuids for active connections in
`nmcli connection down <type> <TAB>`.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 12:12:13 +01:00
Thomas Haller
8c659b79ed cli/bash-completion: cleanup/refactor by making functions generic
Instead of having several bash functions that return some values
via nmcli, add few functions that accept parameters.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 12:12:13 +01:00
Thomas Haller
aa931ab1f2 cli/bash-completion: fix wrong completion for nmcli device wimax
wimax does not support these arguments. This was a copy&paste error from wifi.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 12:11:43 +01:00
Thomas Haller
630a1ccbce cli/bash-completion: remove not yet implemented device type 'adsl'
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-10 11:10:03 +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
Thomas Haller
3051a908a9 cli: fix leaks for getter functions (release GValue)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-08 14:29:19 +01:00
Jiří Klimeš
3668fd7cbc cli: display MTU for devices 2013-12-20 11:37:54 +01:00