Nmcli parsers

This file will parse the output of command line tools used to manage NetworkManager.

Parsers provided by this module include:

NmcliDevShow - command /usr/bin/nmcli dev show

NmcliConnShow - command /usr/bin/nmcli conn show

class insights.parsers.nmcli.NmcliConnShow(context, extra_bad_lines=None)[source]

Bases: CommandParser

This file will parse the output of all the nmcli connections.

Sample configuration from a teamed interface in file /usr/bin/nmcli conn show:

NAME      UUID                                  TYPE      DEVICE
enp0s3    320d4923-c410-4b22-b7e9-afc5f794eecc  ethernet  enp0s3
virbr0    7c7dec66-4a8c-4b49-834a-889194b3b83c  bridge    virbr0
test-net  f858b1cc-d149-4de0-93bc-b1826256847a  ethernet  --

Examples

>>> type(static_conn)
<class 'insights.parsers.nmcli.NmcliConnShow'>
>>> static_conn.disconnected_connection
['test-net-1']
data

list of connections wrapped in dictionaries

Type:

list

property disconnected_connection

It will return all the disconnected static route connections.

Type:

(list)

parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.nmcli.NmcliDevShow(context, extra_bad_lines=None)[source]

Bases: CommandParser, dict

Warning

This parser may be for a single device, please use insights.combiners.nmcli.AllNmcliDevShow instead for all the devices.

This class will parse the output of command nmcli dev show, and the information will be stored in dictionary format.

NetworkManager displays all the devices and their current states along with network configuration and connection status.

This parser works like a python dictionary, all parsed data can be accessed via the dict interfaces.

Sample input for /usr/bin/nmcli dev show:

GENERAL.DEVICE:                         em3
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         B8:AA:BB:DE:F8:B9
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     em3
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.16.184.98/22
IP4.GATEWAY:                            10.16.187.254
IP4.DNS[1]:                             10.16.36.29
IP4.DNS[2]:                             10.11.5.19
IP4.DNS[3]:                             10.5.30.160
IP4.DOMAIN[1]:                          abc.lab.eng.example.com
IP6.ADDRESS[1]:                         2620:52:0:10bb:ba2a:72ff:fede:f8b9/64
IP6.ADDRESS[2]:                         fe80::ba2a:72ff:fede:f8b9/64
IP6.GATEWAY:                            fe80:52:0:10bb::fc
IP6.ROUTE[1]:                           dst = 2620:52:0:10bb::/64, nh = ::, mt = 100

GENERAL.DEVICE:                         em1
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         B8:AA:BB:DE:F8:BB
GENERAL.MTU:                            1500
GENERAL.STATE:                          30 (disconnected)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               off

GENERAL.DEVICE:                         em2
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         B8:AA:BB:DE:F8:BC
GENERAL.MTU:                            1500
GENERAL.STATE:                          30 (disconnected)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               off

Examples

>>> type(nmcli_obj)
<class 'insights.parsers.nmcli.NmcliDevShow'>
>>> nmcli_obj['em3']['STATE']
'connected'
>>> nmcli_obj.get('em2')['HWADDR']
'B8:AA:BB:DE:F8:BC'
>>> sorted(nmcli_obj.connected_devices)
['em1', 'em2', 'em3']
property connected_devices

The list of devices who’s state is connected and managed by NetworkManager

Type:

(list)

property data

Dict with the device name as the key and device details as the value.

Type:

(dict)

parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.nmcli.NmcliDevShowSos(context, extra_bad_lines=None)[source]

Bases: NmcliDevShow

Warning

This parser may be for a single device, please use insights.combiners.nmcli.AllNmcliDevShow instead for all the devices.

In some versions of sosreport, the nmcli dev show command is separated to individual files for different devices. While in some versions, it’s still a whole file. The base class NmcliDevShow could handle both of them, except that the parsing results is stored into a list for separated files.