YumConf - file /etc/yum.conf

This module provides parsing for the /etc/yum.conf file. The YumConf class parses the information in the file /etc/yum.conf. See the IniConfigFile class for more information on attributes and methods.

Sample input data looks like:

[main]

cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

[rhel-7-server-rpms]

metadata_expire = 86400
baseurl = https://cdn.redhat.com/content/rhel/server/7/$basearch
name = Red Hat Enterprise Linux 7 Server (RPMs)
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled = 1
gpgcheck = 1

Examples

>>> yconf = shared[YumConf]
>>> yconf.defaults()
{'admin_token': 'ADMIN', 'compute_port': '8774'}
>>> 'main' in yconf
True
>>> 'rhel-7-server-rpms' in yconf
True
>>> yconf.has_option('main', 'gpgcheck')
True
>>> yconf.has_option('main', 'foo')
False
>>> yconf.get('rhel-7-server-rpms', 'enabled')
'1'
>>> yconf.items('main')
{'plugins': '1',
 'keepcache': '0',
 'cachedir': '/var/cache/yum/$basearch/$releasever',
 'exactarch': '1',
 'obsoletes': '1',
 'installonly_limit': '3',
 'debuglevel': '2',
 'gpgcheck': '1',
 'logfile': '/var/log/yum.log'}
class insights.parsers.yum_conf.YumConf(context)[source]

Bases: insights.core.IniConfigFile

Parse contents of file /etc/yum.conf.

parse_content(content)[source]

Parses content of the config file.

In child class overload and call super to set flag allow_no_values and allow keys with no value in config file:

def parse_content(self, content):
    super(YourClass, self).parse_content(content,
                                         allow_no_values=True)