ResolvConf - file /etc/resolv.conf

class insights.parsers.resolv_conf.ResolvConf(context)[source]

Bases: LegacyItemAccess, Parser

Parse the /etc/resolv.conf file into a dictionary of keywords and their values. This is made available via the data property but the object itself can be used as a dictionary thanks to the insights.core.LegacyItemAccess mixin class.

Each keyword found in the file is stored as a key in the data dictionary, storing the list of values given (in order) on all occurrences of that keyword in the file.

According to the man page, the ‘domain’ and ‘search’ keywords are mutually exclusive. If more than one instance of these keywords is present, whichever is last becomes the active resolution method. So, the active key stores which of these keywords was the last present in the file.

Sample file content:

; generated by /sbin/dhclient-script
# This file is being maintained by Puppet.
options timeout:2 attempts:2


>>> resolv = shared[ResolvConf]
>>> resolv['active']
>>> resolv['nameserver']
["", "" ]
>>> resolv['search']
["", ""]
>>>["options"]  # old style access
["timeout:2", "attempts:2"]

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