summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-07-06 13:02:53 +0200
committerMichal Minar <miminar@redhat.com>2013-07-23 13:52:33 +0200
commit81c8ccb5cb9dc4dd556307930650fc9479d51edb (patch)
tree7016bc39d360b7abdd7554c84d06b6abdde46df6 /src
parent1978fd29febb1c54cce970ff72fde9d36aadf65c (diff)
downloadopenlmi-providers-81c8ccb5cb9dc4dd556307930650fc9479d51edb.tar.gz
openlmi-providers-81c8ccb5cb9dc4dd556307930650fc9479d51edb.tar.xz
openlmi-providers-81c8ccb5cb9dc4dd556307930650fc9479d51edb.zip
software: added software configuration class
Added SoftwareConfiguration class for instantiation of a main, global configuration object for all software providers.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/software/cli/software.py3
-rw-r--r--src/software/lmi/software/util/SoftwareConfiguration.py70
2 files changed, 72 insertions, 1 deletions
diff --git a/src/software/cli/software.py b/src/software/cli/software.py
index 93704ae..9ae1172 100755
--- a/src/software/cli/software.py
+++ b/src/software/cli/software.py
@@ -76,7 +76,8 @@ def make_pkg_path(name, epoch, ver, rel, arch):
@return instance name for LMI_SoftwareIdentity
"""
return pywbem.CIMInstanceName(
- classname="LMI_SoftwareIdentity", namespace="root/cimv2",
+ classname="LMI_SoftwareIdentity",
+ namespace=util.Configuration.get_instance().namespace,
keybindings={
"InstanceID" : util.make_nevra(
name, epoch, ver, rel, arch, "ALWAYS")})
diff --git a/src/software/lmi/software/util/SoftwareConfiguration.py b/src/software/lmi/software/util/SoftwareConfiguration.py
new file mode 100644
index 0000000..99e2257
--- /dev/null
+++ b/src/software/lmi/software/util/SoftwareConfiguration.py
@@ -0,0 +1,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()