NFS exports configuration

NFSExports and NFSExportsD provide a parsed output of the content of an exports file as defined in man exports(5). The content is parsed into a dictionary, where the key is the export path and the value is another dictionary, where the key is the hostname and the value is the option list, parsed into an actual list.

The default ("-") hostname is not specially handled, nor are wildcards.

If export paths are defined multiple times in a file, only the first one is parsed. All subsequent redefinitions are not parsed and the raw line is added to the ignored_lines member.

All raw lines are kept in raw_lines, which is a dict where the key is the export path and the value is the stripped raw line.

Parsers included in this module are:

NFSExports - file nfs_exports

NFSExportsD - files in the nfs_exports.d directory

Sample content of the /etc/exports file:

/home/utcs/shared/ro                    @group(ro,sync),sync,no_root_squash),sync,no_root_squash)
/home/insights/shared/rw                @group(rw,sync),sync,no_root_squash),sync,no_root_squash)
/home/insights/shared/special/all/mail  @group(rw,sync,no_root_squash)
/home/insights/ins/special/all/config   @group(ro,sync,no_root_squash),sync,no_root_squash)
#/home/insights                ,sync,no_root_squash)
/home/example                           @group(rw,sync,root_squash),sync,no_root_squash),sync,no_root_squash)
# A duplicate host for this exported path
/home/example                 ,sync,no_root_squash)


>>> type(exports)
<class 'insights.parsers.nfs_exports.NFSExports'>
>>> type( == type({})
>>> exports.raw_lines['/home/insights/shared/rw']  # List of lines that define this path
['/home/insights/shared/rw                @group(rw,sync),sync,no_root_squash),sync,no_root_squash)']
>>> exports.raw_lines['/home/example']  # Lines are stored even if they contain duplicate hosts
['/home/example                           @group(rw,sync,root_squash),sync,no_root_squash),sync,no_root_squash)', '/home/example                 ,sync,no_root_squash)']
>>> exports.ignored_exports
{'/home/example': {'': ['rw', 'sync', 'no_root_squash']}}
>>> sorted(list(exports.all_options()))
['no_root_squash', 'ro', 'root_squash', 'rw', 'sync']
>>> sorted(list(exports.export_paths()))
['/home/example', '/home/insights/ins/special/all/config', '/home/insights/shared/rw', '/home/insights/shared/special/all/mail', '/home/utcs/shared/ro']
class insights.parsers.nfs_exports.NFSExports(context)[source]

Bases: insights.parsers.nfs_exports.NFSExportsBase

Subclass to attach nfs_exports spec to

class insights.parsers.nfs_exports.NFSExportsBase(context)[source]

Bases: insights.core.Parser

Class to parse /etc/exports and /etc/exports.d/*.exports.

Exports are stored keyed on the path of the export, and then the host definition. The flags are stored as a list. NFS allows the same path to be listed on multiple lines and in multiple files, but an exported path can only have one definition for a given host.


Key is export path, value is a dict, where the key is the client host and the value is a list of options.




A dictionary of exported paths that have host definitions that conflicted with a previous definition.




A synonym for the above ignored_exports dictionary, for historical reasons.




The list of the raw lines that define each exported path, including any lines that may have ignored exports.


dict of lists


Returns the set of all options used in all export entries


Returns the set of all export paths as strings


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

static reconstitute(path, d)[source]


This function is deprecated. Please use the raw_lines dictionary property of the parser instance instead, as this contains the actual lines from the exports file.

‘Reconstitute’ a line from its parsed value. The original lines are not used for this. The hosts in d are listed in alphabetical order, and the options are listed in the order originally given.

  • path (str) -- The exported path

  • d (dict) -- The hosts definition of the exported path


A line simulating the definition of that exported path to those hosts.

Return type


class insights.parsers.nfs_exports.NFSExportsD(context)[source]

Bases: insights.parsers.nfs_exports.NFSExportsBase

Subclass to attach nfs_exports.d spec to