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 thedata
property but the object itself can be used as a dictionary thanks to theinsights.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. # DO NOT EDIT search a.b.com b.c.com options timeout:2 attempts:2 nameserver 10.160.224.51 nameserver 10.61.193.11
Examples
>>> resolv = shared[ResolvConf] >>> resolv['active'] 'search' >>> resolv['nameserver'] ["10.160.224.51", "10.61.193.11" ] >>> resolv['search'] ["a.b.com", "b.c.com"] >>> resolv.data["options"] # old style access ["timeout:2", "attempts:2"]