Commit graph

413 commits

Author SHA1 Message Date
Jiří Klimeš
f227d25ed9 cli: clarify nmcli description for route metric 2014-06-19 10:04:08 +02:00
Jiří Klimeš
7c41835203 cli: editor - do not print separator when printing one setting 2014-06-19 09:24:07 +02:00
Jiří Klimeš
9ab59bdfac cli: editor - enhance TAB completion for 'print' command 2014-06-19 09:24:07 +02:00
Jiří Klimeš
e7830c7925 cli: editor - enhance 'print' command
- allow printing single properties:
nmcli> print con.id
connection.id: my-main-ethernet

- allow printing other settings in second (settings) menu level:
nmcli connection> print ipv4.method
ipv4.method: auto
nmcli connection> print eth
...
2014-06-19 09:23:07 +02:00
Jiří Klimeš
e70d5579af cli: don't accept prefix 0 for routes 2014-06-11 10:07:02 +02:00
Jiří Klimeš
4e9fc8ad61 cli: don't accept default route entries, NM handles the default route itself 2014-06-11 09:58:44 +02:00
Jiří Klimeš
700f5ec0ef cli: allow missing next hop for routes (bgo #727615)
https://bugzilla.gnome.org/show_bug.cgi?id=727615
2014-06-11 09:58:39 +02:00
Dan Williams
dacee1485a cli: fix a couple errors noticed by coverity 2014-06-06 17:25:36 -05:00
Thomas Haller
bcb9f6c910 cli: fix error parsing input arguments in non-interactive mode
Causes the following failure:

   $ /bin/nmcli connection add type ethernet con-name connie ifname '*'

   (process:13883): GLib-CRITICAL **: g_strchug: assertion `string != NULL' failed
   (process:13883): GLib-CRITICAL **: g_strchomp: assertion `string != NULL' failed
   Error: invalid connection type; '' not among [generic, ...].

Regression introduced by commit bfb1200b4f.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 23:19:49 +02:00
Jiří Klimeš
dae8391436 cli: switch to the new-style readline typedefs (bgo #731294)
The old Function, CPFunction, CPPFunction and VFunction typedefs are
considered deprecated starting from readline 4.2 (though were not marked
as such): http://lists.gnu.org/archive/html/bug-bash/2000-10/msg00078.html
Compatibility typedefs have been in place up to readline 6.2 but were
removed with the 6.3 release thus causing build to break.
http://lists.gnu.org/archive/html/bug-readline/2014-04/msg00018.html

https://bugzilla.gnome.org/show_bug.cgi?id=731294
2014-06-06 11:34:23 +02:00
Jiří Klimeš
82db87a144 cli: use readline for quit confirmation in editor, and accept localized answer 2014-06-04 09:47:37 +02:00
Jiří Klimeš
00c700bf2c cli: implement TAB completion for connection and interface names
For commands like
nmcli -a dev disconnect
nmcli -a con up
...
2014-06-04 09:47:37 +02:00
Jiří Klimeš
bfb1200b4f cli: implement TAB completion for inputs in questionnaire mode
and also
- accept yes/no options as localized strings
- simplify some questionnaire code
2014-06-04 09:47:37 +02:00
Jiří Klimeš
480f69e23f cli: use readline also in other commands (besides interactive editor)
It is used for '--ask' option. The main use is for questionnaires
(nmcli -a con add).
2014-06-04 09:47:37 +02:00
Jiří Klimeš
b71af5b144 cli: make prompt argument a printf-like format string, remove history argument
for nmc_readline()
2014-06-04 09:47:37 +02:00
Jiří Klimeš
a3d89d65c4 cli: move readline related functions to common.h to be usable throughout nmcli
Renames
readline_x() to nmc_readline()
gen_func_basic() to nmc_rl_gen_func_basic()

The commit doesn't change functionality, only moves and renames the functions,
so that they can be used in other places too.
2014-06-04 09:47:37 +02:00
Jiří Klimeš
03be41d409 cli/build: make libreadline a build-time dependency (bgo #729846)
and link nmcli against it.

This simplifies code, makes sure that line editing capability is supported,
and will allow using readline on other places too.

https://bugzilla.gnome.org/show_bug.cgi?id=729846
https://bugzilla.redhat.com/show_bug.cgi?id=1007365
2014-06-04 09:47:37 +02:00
Jiří Klimeš
fd93fb9fb9 cli: don't leak 'str' returned by g_strdup_vprintf() 2014-06-04 08:55:35 +02:00
Jiří Klimeš
e88979a354 cli: add optional 'mac' argument for 'nmcli con add type bridge'
This allows setting bridge MAC either on command-line
nmcli con add type bridge con-name mybridge mac 11:22:33:44:55:66
or provide it when asked
nmcli -a con add type bridge con-name mybridge
2014-05-30 17:02:31 +02:00
Jiří Klimeš
43edc90438 cli: support new bridge.mac-address property 2014-05-30 17:02:31 +02:00
Thomas Haller
c4d90c5660 cli: don't use nm_utils_hwaddr_type() to stringify HWADDR
Use nm_utils_hwaddr_ntoa_len() instead of nm_utils_hwaddr_ntoa().
This makes it no longer necessary to determine the type of the MAC
address based on the address length.

This makes the GETTER more accepting towards other lengths.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-29 19:00:59 +02:00
Jiří Klimeš
d7216505bb cli: do not restrict VPN type of created connections (rh #1100750)
There may be third-party VPN plugins nmcli is not aware of.
We still print a warning if nmcli doesn't know the type. It helps to catch up
typos.

https://bugzilla.redhat.com/show_bug.cgi?id=1100750
2014-05-28 09:37:15 +02:00
Jiří Klimeš
649e4be103 cli: extract username and gateway for some more VPN types 2014-05-28 09:37:15 +02:00
Jiří Klimeš
98ae6e06d2 all: g_type_init() has been deprecated in GLib 2.35.0
g_type_init() deprecation:
https://bugzilla.gnome.org/show_bug.cgi?id=686161
2014-05-27 16:58:21 +02:00
Jiří Klimeš
6f9601030a cli: add missing reason-to-string mappings for NMDeviceStateReason 2014-05-26 14:07:01 +02:00
Jiří Klimeš
e6f1c8329f cli: TAB completion for connection.secondaries
We complete UUIDs, because that's easier (no spaces or special characters).
Readline display hook allows to display profile name too, though.
2014-05-23 12:19:29 +02:00
Jiří Klimeš
7696238e84 cli: only allow setting VPN connection as secondaries in editor 2014-05-23 12:19:29 +02:00
Jiří Klimeš
2b37ee2b7a cli: fix completion of interfaces in editor for "activate" command 2014-05-15 13:43:02 +02:00
Jiří Klimeš
e8f5a82e22 cli: fix ambiguity of "o" (on vs off) in nmc_string_to_bool() 2014-05-15 09:50:52 +02:00
Thomas Haller
9ef23947cc all: fix various warnings detected with coverity
https://bugzilla.gnome.org/show_bug.cgi?id=728320

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-02 15:20:30 +02:00
Dan Winship
bea82ca98b all: set G_LOG_DOMAIN appropriately, for better g_log() messages 2014-04-23 10:19:17 -04:00
Jiří Klimeš
645f0204f9 nmcli: improve setting connection.secondaries property
- check if the values being set are existing connections
- also allow specifying connections by names, translating them transparently
   to UUIDs.
- nmcli-specific section for 'describe' command added

(We use a global nm_cli variable in nmc_property_connection_set_secondaries())
2014-04-22 12:40:40 +02:00
Yuri Chornoivan
b25c227e07 fix typos in documentation and messages
https://bugzilla.gnome.org/show_bug.cgi?id=727031

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-03 17:12:31 +02:00
Dan Williams
408ecd6b5f cli: fix setting DCB application priority (rh #1080510)
Priority was originally a 'guint' but then got changed to 'gint' and
apparently we forgot to fix one place up.
2014-04-02 12:06:14 -05:00
Jiří Klimeš
c1e5493117 nmcli: use correct Mbit/s units for maximal bitrate (rh #1080474)
https://bugzilla.redhat.com/show_bug.cgi?id=1080474
2014-04-01 15:15:17 +02:00
Jiří Klimeš
4209f170da nmcli: fix an error when showing progress of activation in editor
(process:7213): CRITICAL **: nm_active_connectiuon_get_state: assertion `NM_IS_ACTIVE_CONNECTION (connection)' failed
2014-03-31 18:10:55 +02:00
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
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