summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2007-09-27 17:15:38 -0400
committerAdrian Likins <alikins@redhat.com>2007-09-27 17:15:38 -0400
commitaac0784a0f84c848f47955c57d6fe0dcbd49c035 (patch)
treeb8e87b66a2886906025b635e5f088cbad5de23a7
parent9d94991f51d2e0986fbc933522e32621c2c37a36 (diff)
parent05f84c547f8eadb46f70abc9f612a21225ed5994 (diff)
downloadfunc-aac0784a0f84c848f47955c57d6fe0dcbd49c035.tar.gz
func-aac0784a0f84c848f47955c57d6fe0dcbd49c035.tar.xz
func-aac0784a0f84c848f47955c57d6fe0dcbd49c035.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
-rwxr-xr-xfunc/logger.py13
-rwxr-xr-xminion/logger.py82
-rwxr-xr-xminion/server.py2
-rwxr-xr-xmodules/func_module.py9
4 files changed, 12 insertions, 94 deletions
diff --git a/func/logger.py b/func/logger.py
index f6f9c0f..0da291c 100755
--- a/func/logger.py
+++ b/func/logger.py
@@ -16,7 +16,9 @@
import logging
-import config_data
+from func.config import read_config
+
+from server import FuncdConfig
# from the comments in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
@@ -33,12 +35,9 @@ class Logger(Singleton):
_no_handlers = True
def __init__(self, logfilepath ="/var/log/func/func.log"):
-
- self.config = config_data.Config().get()
- if self.config.has_key("log_level"):
- self.loglevel = logging._levelNames[self.config["log_level"]]
- else:
- self.loglevel = logging.INFO
+ config_file = '/etc/func/minion.conf'
+ self.config = read_config(config_file, FuncdConfig)
+ self.loglevel = logging._levelNames[self.config.log_level]
self._setup_logging()
if self._no_handlers:
self._setup_handlers(logfilepath=logfilepath)
diff --git a/minion/logger.py b/minion/logger.py
deleted file mode 100755
index 9e8b62d..0000000
--- a/minion/logger.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/python
-
-## func
-##
-## Copyright 2007, Red Hat, Inc
-## See AUTHORS
-##
-## This software may be freely redistributed under the terms of the GNU
-## general public license.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-##
-##
-
-
-import logging
-from func.config import BaseConfig, BoolOption, IntOption, Option, ConfigError, read_config, ListOption
-
-from server import FuncdConfig
-
-
-# from the comments in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
-class Singleton(object):
- def __new__(type, *args, **kwargs):
- if not '_the_instance' in type.__dict__:
- type._the_instance = object.__new__(type, *args, **kwargs)
- return type._the_instance
-
-# logging is weird, we don't want to setup multiple handlers
-# so make sure we do that mess only once
-
-class Logger(Singleton):
- _no_handlers = True
-
- def __init__(self, logfilepath ="/var/log/func/func.log"):
- config_fle = '/etc/func/minion.conf'
- self.config = read_config(config_file, FuncdConfig)
- self.loglevel = logging._levelNames[self.config.log_level]
- self._setup_logging()
- if self._no_handlers:
- self._setup_handlers(logfilepath=logfilepath)
-
- def _setup_logging(self):
- self.logger = logging.getLogger("svc")
-
- def _setup_handlers(self, logfilepath="/var/log/func/func.log"):
- handler = logging.FileHandler(logfilepath, "a")
- self.logger.setLevel(self.loglevel)
- formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
- handler.setFormatter(formatter)
- self.logger.addHandler(handler)
- self._no_handlers = False
-
-
-class AuditLogger(Singleton):
- _no_handlers = True
- def __init__(self, logfilepath = "/var/log/func/audit.log"):
- self.loglevel = logging.INFO
- self._setup_logging()
- if self._no_handlers:
- self._setup_handlers(logfilepath=logfilepath)
-
- def log_call(self, CN, cert_hash, method, params):
- # square away a good parseable format at some point -akl
- self.logger.info("%s %s %s called with %s" % (CN, cert_hash, method, params))
-
-
- def _setup_logging(self):
- self.logger = logging.getLogger("audit")
-
- def _setup_handlers(self, logfilepath="/var/log/func/audit.log"):
- handler = logging.FileHandler(logfilepath, "a")
- self.logger.setLevel(self.loglevel)
- formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
- handler.setFormatter(formatter)
- self.logger.addHandler(handler)
- self._no_handlers = False
-
-
-
diff --git a/minion/server.py b/minion/server.py
index af4c4e0..f930cfa 100755
--- a/minion/server.py
+++ b/minion/server.py
@@ -49,7 +49,7 @@ class XmlRpcInterface(object):
Constructor.
"""
- config_fle = '/etc/func/minion.conf'
+ config_file = '/etc/func/minion.conf'
self.config = read_config(config_file, FuncdConfig)
self.logger = logger.Logger().logger
self.audit_logger = logger.AuditLogger()
diff --git a/modules/func_module.py b/modules/func_module.py
index f488e83..2f56ca0 100755
--- a/modules/func_module.py
+++ b/modules/func_module.py
@@ -13,8 +13,10 @@
##
-from func import config_data
+from func import config
from func import logger
+from func.config import read_config
+from func.server import FuncdConfig
class FuncModule(object):
@@ -26,9 +28,8 @@ class FuncModule(object):
def __init__(self):
- config_obj = config_data.Config()
- config_result = config_obj.get()
- self.config = config_result
+ config_file = '/etc/func/minion.conf'
+ self.config = read_config(config_file, FuncdConfig)
self.__init_log()
self.__base_methods = {
# __'s so we don't clobber useful names