Commit Graph

683 Commits

Author SHA1 Message Date
Beniamino Galvani
ed824102ff cli: fix completion of connection types
Return only main settings and the special slave types.
2017-04-20 14:34:20 +02:00
Beniamino Galvani
07cba18036 cli: accept special slave connection types in editor 2017-04-20 14:34:20 +02:00
Beniamino Galvani
032a3b4712 cli: only return main setting names as connection types
Also, return the special slave types.
2017-04-20 14:34:20 +02:00
Beniamino Galvani
243061edb6 cli: normalize function name 2017-04-20 14:34:20 +02:00
Francesco Giudici
4bdb6b026a nmcli: show secrets when the --show-secrets option is put after the connection id
'nmcli connection show <con_id1> --show-secrets'
secrets were not shown.
'nmcli connection show <con_id1> --show-secrets <con_id2>'
secrets were shown only for connection ids following the
"--show-secrets" option (so only for 'con_id2').

Fix these behaviors showing secrets for all connections also
if the "--show-secrets" option is put after the connection ids.
2017-04-20 12:41:08 +02:00
Thomas Haller
6dfb3e9ffb cli/trivial: remove whitespace between N_ macro and parenthesis
For _() and N_() we don't have a space before the parenthesis.
Be consistent about that.
2017-04-19 18:27:19 +02:00
Beniamino Galvani
f13fd4524c all: detect SR-IOV device support 2017-04-18 22:48:34 +02:00
Beniamino Galvani
67d144dd1e cli: check for deactivation failures
If the D-Bus call to DeactivateConnection() fails, don't wait for the
connection to change state because this is not going to
happen. Instead, notify the user of the error and, if necessary, wait
for remaining connections to be deactivated.

https://bugzilla.redhat.com/show_bug.cgi?id=1422786
2017-04-13 17:18:34 +02:00
Thomas Haller
275ab5fb8f cli: make properties list a list of pointers
That allows for the property list to contain derived
property types. Also, the list can be directly passed
off as a "const NMMetaAbstractInfo *const*" list.
2017-04-13 10:10:12 +02:00
Thomas Haller
f2b5a42c7c cli: let NMMetaNestedPropertyInfo derive NMMetaPropertyInfo 2017-04-13 10:10:12 +02:00
Thomas Haller
886dad49d4 cli: move parsing of meta data fields 2017-04-13 10:10:12 +02:00
Thomas Haller
39bc8dbdf9 cli/trivial: rename NmcOutputSelectionItem type 2017-04-13 10:10:12 +02:00
Thomas Haller
2026d52f11 cli: use virtual get_nested method in _output_selection_select_one() 2017-04-13 10:10:12 +02:00
Beniamino Galvani
8b52e506a7 cli: fix addition of slave connection types
$ nmcli connection add type bond-slave ifname aoeu master aoeu
 Error: bad connection type: 'bond-slave' not among [802-1x, adsl,
 bluetooth, bond, bridge, bridge-port, cdma, connection, dcb, dummy,
 generic, gsm, infiniband, ipv4, ipv6, ip-tunnel, macsec, macvlan,
 802-11-olpc-mesh (olpc-mesh), ppp, pppoe, proxy, serial, team,
 team-port, tun, user, vlan, vpn, vxlan, wimax, 802-3-ethernet
 (ethernet), 802-11-wireless (wifi), 802-11-wireless-security
 (wifi-sec)].

Fixes: d32817999c
2017-04-13 08:43:17 +02:00
Thomas Haller
6d12d2f3a0 cli: move setting creation to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
b629b98687 cli: move completion for connection type to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
2a760897f2 cli: move completion for master connections to meta data
This change (improves) behavior.

Before, we would only complete
  if (g_strcmp0 (con_type, nmc_tab_completion.con_type) != 0)
which doesn't really make sense as it depends on the slave-type,
not nmc_tab_completion.con_type.
2017-04-12 14:12:20 +02:00
Thomas Haller
1e4bc51a4a cli: move completion for devices names to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
d32817999c cli: move information about valid connection settings to common 2017-04-12 14:12:20 +02:00
Thomas Haller
3ed0fc1b45 cli: move setting alias to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
88f100e176 cli: move completing static-value types to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
0fa5fc3f51 cli: move completing VPN service types to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
7ef23e5c0a cli: move prompting for enum values to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
218f46ebcc cli: use meta data's completion in nmcli_con_add_tab_completion() 2017-04-12 14:12:19 +02:00
Thomas Haller
0b7e9c3bef cli: move prompting for boolean values to meta data
This changes behavior, in that yes|no prompt and answer is no longer
localized.

For command line arguments, I think it is always wrong for nmcli to
behave differently based on the localization. That is, input properties
on command line should not be translated.

One could make an argument, that in interactive mode that is different
and the user can be prompted in the his language.

But I think for consistency, it is wrong to ask for localized nmcli input.
2017-04-12 14:12:19 +02:00
Thomas Haller
cfd9f66ae9 cli: add property completion to meta-data
(not used yet).
2017-04-12 14:12:19 +02:00
Thomas Haller
4f19c46a1e cli: move part of setting meta data from "connection.c"'s OptionInfo 2017-04-12 14:12:19 +02:00
Thomas Haller
6763097cc9 cli: make OptionInfo immutable
Don't mutate global state. For now, hack around it by putting
the mutable flags to a separate (global) cache. Obviously, it
still uses global data, but it no longer touches the global
option_info list.
2017-04-12 14:12:06 +02:00
Thomas Haller
e5ebf7a7ef cli: move property option flags to nm-meta-settings-desc.h 2017-04-12 14:10:57 +02:00
Thomas Haller
ddfff04a45 cli: extend NMMetaSettingInfoEditor's get_fcn() to support different output forms 2017-04-12 14:10:56 +02:00
Thomas Haller
b7efa62745 cli: cleanup meta data virtual function arguments
- have the "self" argument first, before the environment arguments.
  It's more idiomatic.
- from within cli, always pass nmc_meta_environment and nmc_meta_arg
  where needed.
- drop the union in NMMetaAbstractInfo. I was suppost to make casts
  nicer, but it doesn't really.
2017-04-12 14:00:00 +02:00
Thomas Haller
41b31051f2 cli: use nmc_print() to output device's IP4 info
The IP4 info adds a new type: to expose strv arguments
for addresses, etc.
2017-04-12 14:00:00 +02:00
Thomas Haller
c5c48d4f5f cli: move global "loop" variable to nmcli.h header 2017-04-12 11:24:04 +02:00
Thomas Haller
03307e3dd6 cli: use nmc_print() to output nmcli general logging 2017-04-12 11:24:04 +02:00
Thomas Haller
16299e5ac0 cli: use nmc_print() to output nmcli general permissions
Add also colors for the output values.
2017-04-12 11:24:04 +02:00
Thomas Haller
3045daf127 cli: use nmc_print() to output setting data 2017-04-12 11:24:04 +02:00
Thomas Haller
fdd758112f cli: merge editor_show_secrets with NmcConfig.show_secrets
The show-secrets flag can be toggled in edit mode

  nmcli> nmcli show-secrets yes

There is no point in tracking two separate flags for it. Inside
edit mode, when the user toggles the show-secrets flag, it should
overwrite the command line option.

These two flags can be merged.
2017-04-12 11:24:04 +02:00
Thomas Haller
f0d91455ca cli: move show_secret field to NmcConfig
The show-secret property is basically a part of the current
configuration, relevant during printing. It will be passed
on to nmc_print(), and hence must be part of NmcConfig.
2017-04-12 11:24:04 +02:00
Thomas Haller
fdd40b6a68 cli: implement new nmc_print() command to generically output cli data
We already have
  - data sources (nm_cli, connections or settings)
  - meta data information how to access the data sources (NMMetaAbstractInfo,
    NmcMetaGenericInfo, NMMetaPropertyInfo)

Add now a generic way to output cli data using nmc_print(). It gets a
list of data-sources (@targets) and a list of available fields (meta
data). It also gets cli configuration (NmcConfig) and field selector
strings (@field_str).

Based on that, it should output the desired data.

This is intended to replaces the previous approach, where functions like
show_nm_status() have full knowledge about how to access the data and
create an intermediate output format (NmcOutputData, NmcOutputField)
that was printed via print_data().
show_nm_status() contained both knowledge about the data itself (how to
print a value) and intimate knoweledge about the output intermediate
format. Also, the intermediate format is hard to understand. For
example, sometimes we put the field prefix in NmcOutputField at index 0
and via the NmcOfFlags we control how to output the data.

Clearly separate the responsibilities.

  - The meta data (NmcMetaGenericInfo) is only concerned with converting
    a data source to a string (or a color format).
  - the field selection (@field_str) only cares about parsing the list
    of NMMetaAbstractInfo.
  - _print_fill() populates a table with output values and header
    entries.
  - _print_do() prints the previously prepared table.

The advantage is that if you want to change anything, you only need to
touch a particular part.

This is only a show-case for `nmcli general status`. Parts are still
un-implemented and will follow.

This changes behavior for --terse mode: the values are now no longer
translated:
  $ LANG=de_DE.utf8 nmcli -t --mode multiline general
2017-04-12 11:24:04 +02:00
Thomas Haller
e79174ca89 cli: refactor enum-to-string function to have non-translating version
We need both translated and non-translated versions.
2017-04-12 11:24:04 +02:00
Thomas Haller
ce28918dbf cli/trivial: move code 2017-04-12 11:24:04 +02:00
Thomas Haller
01b1656f36 cli: cleanup print_required_fields()
Avoid explicit free() calls, but instead have a auto variable
own the string.
2017-04-12 11:24:04 +02:00
Beniamino Galvani
c9c029181e cli: do not show description of unsupported properties
Properties without meta data cannot be set or displayed: do
not show them.
2017-04-12 10:18:01 +02:00
Francesco Giudici
2c4e991aba nmcli: fix "nmcli device monitor <dev>"
Call get_device_list() after next_arg(); call it only after checking
that there are other arguments after "monitor".

Fixes: 6a3d77fbe6
2017-04-11 15:49:30 +02:00
Thomas Haller
c40f6c46ec cli: add accessors for NMMetaAbstractInfo 2017-04-05 16:53:06 +02:00
Thomas Haller
ca0e749c40 cli: move and rename TermColor and TermFormat 2017-04-05 16:53:06 +02:00
Thomas Haller
e3a07633dc cli: fix signature of NMMetaAbstractType:get_fcn()
Depending on the get_type argument, we don't only want
to return strings, but arbitrary pointers.

The out_to_free argument still makes sense, but depending on
the get-type you must know how to free the pointer.
2017-04-05 16:53:06 +02:00
Thomas Haller
9276655975 cli: move NmcMetaGenericInfo to "utils.h" 2017-04-05 16:53:06 +02:00
Thomas Haller
19c70ace95 cli: add get_fcn() to NMMetaAbstractInfo 2017-04-05 16:53:06 +02:00
Thomas Haller
137273669d cli: add nmc_output_selection_create() to parse field selection
nmc_output_selection_create() returns a less opaque result then
a GArray and a GPtrArray for the groups.
2017-04-05 16:53:06 +02:00