summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin/base.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugin/base.py66
1 files changed, 4 insertions, 62 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/base.py b/src/lib/Bcfg2/Server/Plugin/base.py
index 03feceb6f..549f7b543 100644
--- a/src/lib/Bcfg2/Server/Plugin/base.py
+++ b/src/lib/Bcfg2/Server/Plugin/base.py
@@ -1,66 +1,11 @@
"""This module provides the base class for Bcfg2 server plugins."""
import os
-import logging
+import Bcfg2.Options
+from Bcfg2.Logger import Debuggable
from Bcfg2.Utils import ClassName
-class Debuggable(object):
- """ Mixin to add a debugging interface to an object and expose it
- via XML-RPC on :class:`Bcfg2.Server.Plugin.base.Plugin` objects """
-
- #: List of names of methods to be exposed as XML-RPC functions
- __rmi__ = ['toggle_debug', 'set_debug']
-
- #: How exposed XML-RPC functions should be dispatched to child
- #: processes.
- __child_rmi__ = __rmi__[:]
-
- def __init__(self, name=None):
- """
- :param name: The name of the logger object to get. If none is
- supplied, the full name of the class (including
- module) will be used.
- :type name: string
-
- .. autoattribute:: __rmi__
- """
- if name is None:
- name = "%s.%s" % (self.__class__.__module__,
- self.__class__.__name__)
- self.debug_flag = False
- self.logger = logging.getLogger(name)
-
- def set_debug(self, debug):
- """ Explicitly enable or disable debugging. This method is exposed
- via XML-RPC.
-
- :returns: bool - The new value of the debug flag
- """
- self.debug_flag = debug
- return debug
-
- def toggle_debug(self):
- """ Turn debugging output on or off. This method is exposed
- via XML-RPC.
-
- :returns: bool - The new value of the debug flag
- """
- return self.set_debug(not self.debug_flag)
-
- def debug_log(self, message, flag=None):
- """ Log a message at the debug level.
-
- :param message: The message to log
- :type message: string
- :param flag: Override the current debug flag with this value
- :type flag: bool
- :returns: None
- """
- if (flag is None and self.debug_flag) or flag:
- self.logger.error(message)
-
-
class Plugin(Debuggable):
""" The base class for all Bcfg2 Server plugins. """
@@ -109,13 +54,10 @@ class Plugin(Debuggable):
#: but not ``__rmi__`` will be ignored.
__child_rmi__ = Debuggable.__child_rmi__
- def __init__(self, core, datastore):
+ def __init__(self, core):
"""
:param core: The Bcfg2.Server.Core initializing the plugin
:type core: Bcfg2.Server.Core
- :param datastore: The path to the Bcfg2 repository on the
- filesystem
- :type datastore: string
:raises: :exc:`OSError` if adding a file monitor failed;
:class:`Bcfg2.Server.Plugin.exceptions.PluginInitError`
on other errors
@@ -125,7 +67,7 @@ class Plugin(Debuggable):
Debuggable.__init__(self, name=self.name)
self.Entries = {}
self.core = core
- self.data = os.path.join(datastore, self.name)
+ self.data = os.path.join(Bcfg2.Options.setup.repository, self.name)
if self.create and not os.path.exists(self.data):
self.logger.warning("%s: %s does not exist, creating" %
(self.name, self.data))