cli: add kill switch indication to "nmcli" output

There is some guess work done on the client side. Perhaps the
o.fd.NM.Device could be extended to indicate which kill switch is the
device disabled by. This could be good enough for now though.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/271/commits
This commit is contained in:
Lubomir Rintel 2019-09-12 09:51:06 +02:00
parent a7dd935d87
commit 25fadf8f92
4 changed files with 45 additions and 0 deletions

View file

@ -1242,6 +1242,41 @@ device_overview (NmCli *nmc, NMDevice *device)
g_string_append_printf (outbuf, "%s, ", tmp);
g_free (tmp);
}
switch (nm_device_get_device_type (device)) {
case NM_DEVICE_TYPE_WIFI:
case NM_DEVICE_TYPE_OLPC_MESH:
case NM_DEVICE_TYPE_WIFI_P2P:
if (!nm_client_wireless_get_enabled (nmc->client)) {
tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("sw disabled"));
g_string_append_printf (outbuf, "%s, ", tmp);
g_free (tmp);
}
if (!nm_client_wireless_hardware_get_enabled (nmc->client)) {
tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("hw disabled"));
g_string_append_printf (outbuf, "%s, ", tmp);
g_free (tmp);
}
break;
case NM_DEVICE_TYPE_MODEM:
if ( nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device))
& (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
if (!nm_client_wwan_get_enabled (nmc->client)) {
tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("sw disabled"));
g_string_append_printf (outbuf, "%s, ", tmp);
g_free (tmp);
}
if (!nm_client_wwan_hardware_get_enabled (nmc->client)) {
tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("hw disabled"));
g_string_append_printf (outbuf, "%s, ", tmp);
g_free (tmp);
}
}
break;
default:
break;
}
if (nm_device_is_software (device))
g_string_append_printf (outbuf, "%s, ", _("sw"));
else

View file

@ -52,6 +52,7 @@
[NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "31", \
[NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "31", \
[NM_META_COLOR_DEVICE_UNAVAILABLE] = "2", \
[NM_META_COLOR_DEVICE_DISABLED] = "31", \
[NM_META_COLOR_MANAGER_RUNNING] = "32", \
[NM_META_COLOR_MANAGER_STARTING] = "33", \
[NM_META_COLOR_MANAGER_STOPPED] = "31", \
@ -558,6 +559,7 @@ parse_color_scheme (char *palette_buffer,
[NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "device-firmware-missing",
[NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "device-plugin-missing",
[NM_META_COLOR_DEVICE_UNAVAILABLE] = "device-unavailable",
[NM_META_COLOR_DEVICE_DISABLED] = "device-disabled",
[NM_META_COLOR_DEVICE_UNKNOWN] = "device-unknown",
[NM_META_COLOR_MANAGER_RUNNING] = "manager-running",
[NM_META_COLOR_MANAGER_STARTING] = "manager-starting",

View file

@ -89,6 +89,7 @@ typedef enum {
NM_META_COLOR_DEVICE_FIRMWARE_MISSING,
NM_META_COLOR_DEVICE_PLUGIN_MISSING,
NM_META_COLOR_DEVICE_UNAVAILABLE,
NM_META_COLOR_DEVICE_DISABLED,
NM_META_COLOR_DEVICE_UNKNOWN,
NM_META_COLOR_MANAGER_RUNNING,
NM_META_COLOR_MANAGER_STARTING,

View file

@ -2192,6 +2192,13 @@ It's equivalent to the <literal>+bond.options 'option=value'</literal> syntax.</
</listitem>
</varlistentry>
<varlistentry>
<term><option>device-disabled</option></term>
<listitem>
<para>Device is disabled by software or hardware kill switch.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>manager-running</option></term>
<listitem>