summaryrefslogtreecommitdiffstats
path: root/src/software/lmi/software/util/SoftwareConfiguration.py
blob: 99e22571cff2b99610526d74811b53ab862dea00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (C) 2012 Red Hat, Inc.  All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
# Authors: Michal Minar <miminar@redhat.com>
# -*- coding: utf-8 -*-
"""
Module for SoftwareConfiguration class.

SoftwareConfiguration
---------------------

.. autoclass:: SoftwareConfiguration
    :members:

"""

from lmi.common.BaseConfiguration import BaseConfiguration

class SoftwareConfiguration(BaseConfiguration):
    """
        Configuration class specific to software providers.
        OpenLMI configuration file should reside in
        /etc/openlmi/software/software.conf.
    """

    @classmethod
    def provider_prefix(cls):
        return "software"

    @classmethod
    def default_options(cls):
        """ :rtype: (``dict``) Dictionary of default values. """
        defaults = BaseConfiguration.default_options().copy()
        # Maximum time in seconds to wait for a job to accomplish.
        # If timeout expires, spawned process is checked (it might
        # be possibly killed) and is respawned in case it's dead.
        defaults["wait_complete_timeout" ] = "30"
        # Number of seconds to wait before next try to lock yum package
        # database. This applies, when yum database is locked by another
        # process.
        defaults["lock_wait_interval"] = "0.5"
        # Number of seconds to keep package cache in memory after the last use
        # (caused by user request). Package cache takes up a lot of memory.
        defaults["free_database_timeout"] = "60"
        # Default logging level.
        defaults["Level"] = "ERROR"
        return defaults

    @classmethod
    def mandatory_sections(cls):
        return list(BaseConfiguration.mandatory_sections()) + [
            'Yum', 'Jobs', 'YumWorkerLog']

    @property
    def logging_level(self):
        """ Return name of logging level in lower case. """
        return self.config.get('Log', 'Level').lower()