summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-07-01 18:02:21 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-07-01 18:02:21 +0000
commit82f49dd3f9fca03f1d364dec6b9c60c70c9ecc0d (patch)
tree6d72dfd483135b07e0819a01f116121599cd4004 /src
parent2320401d4273287f36ac23a7d5966c19adfed6ff (diff)
downloadbcfg2-82f49dd3f9fca03f1d364dec6b9c60c70c9ecc0d.tar.gz
bcfg2-82f49dd3f9fca03f1d364dec6b9c60c70c9ecc0d.tar.bz2
bcfg2-82f49dd3f9fca03f1d364dec6b9c60c70c9ecc0d.zip
Plugin.py: Add configurable metadata settings to bcfg2.conf (ticket #680)
The default settings for ConfigFile metadata were previously hardcoded in Plugin.py. This change enables setting global user-specified defaults in the [mdata] section of bcfg2.conf. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5308 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Options.py12
-rw-r--r--src/lib/Server/Plugin.py33
2 files changed, 38 insertions, 7 deletions
diff --git a/src/lib/Options.py b/src/lib/Options.py
index ea3630389..716c21f09 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -176,6 +176,18 @@ DEBUG = Option("Enable debugging output", False, cmd='-d')
VERBOSE = Option("Enable verbose output", False, cmd='-v')
DAEMON = Option("Daemonize process, storing pid", False,
cmd='-D', odesc="<pidfile>")
+MDATA_OWNER = Option('Default ConfigFile owner',
+ default='root', cf=('mdata', 'owner'),
+ odesc='owner permissions')
+MDATA_GROUP = Option('Default ConfigFile group',
+ default='root', cf=('mdata', 'group'),
+ odesc='group permissions')
+MDATA_PERMS = Option('Default ConfigFile permissions',
+ '644', cf=('mdata', 'perms'),
+ odesc='octal permissions')
+MDATA_PARANOID = Option('Default ConfigFile paranoid setting',
+ 'false', cf=('mdata', 'paranoid'),
+ odesc='ConfigFile paranoid setting')
SERVER_REPOSITORY = Option('Server repository path', '/var/lib/bcfg2',
cf=('server', 'repository'), cmd='-Q',
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index f0cbaa693..269508b13 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -1,14 +1,28 @@
'''This module provides the baseclass for Bcfg2 Server Plugins'''
__revision__ = '$Revision$'
-import logging, lxml.etree, re, copy, posixpath
+import copy
+import logging
+import lxml.etree
+import posixpath
+import re
from lxml.etree import XML, XMLSyntaxError
+import Bcfg2.Options
+
+# grab default metadata info from bcfg2.conf
+opts = {'owner':Bcfg2.Options.MDATA_OWNER,
+ 'group':Bcfg2.Options.MDATA_GROUP,
+ 'perms':Bcfg2.Options.MDATA_PERMS,
+ 'paranoid':Bcfg2.Options.MDATA_PARANOID}
+mdata_setup = Bcfg2.Options.OptionParser(opts)
+mdata_setup.parse([])
+del mdata_setup['args']
+
logger = logging.getLogger('Bcfg2.Plugin')
-default_file_metadata = {'owner': 'root', 'group': 'root', 'perms': '644',
- 'encoding': 'ascii', 'paranoid':"false"}
+default_file_metadata = mdata_setup
info_regex = re.compile( \
'^owner:(\s)*(?P<owner>\S+)|group:(\s)*(?P<group>\S+)|' +
@@ -24,8 +38,8 @@ class PluginExecutionError(Exception):
pass
class Plugin(object):
- '''This is the base class for all Bcfg2 Server plugins. Several attributes must be defined
- in the subclass:
+ '''This is the base class for all Bcfg2 Server plugins.
+ Several attributes must be defined in the subclass:
name : the name of the plugin
__version__ : a version string
__author__ : the author/contact for the plugin
@@ -211,7 +225,10 @@ class DirectoryBacked(object):
elif name in self.entries:
self.entries[name].HandleEvent()
else:
- if ((name[-1] == '~') or (name[:2] == '.#') or (name[-4:] == '.swp') or (name in ['SCCS', '.svn'])):
+ if ((name[-1] == '~') or
+ (name[:2] == '.#') or
+ (name[-4:] == '.swp') or
+ (name in ['SCCS', '.svn'])):
return
if not self.patterns.match(name):
return
@@ -238,7 +255,9 @@ class DirectoryBacked(object):
elif action in ['endExist']:
pass
else:
- print "Got unknown event %s %s %s" % (event.requestID, event.code2str(), event.filename)
+ print "Got unknown event %s %s %s" % (event.requestID,
+ event.code2str(),
+ event.filename)
class XMLFileBacked(FileBacked):
'''This object is a coherent cache for an XML file to be used as a part of DirectoryBacked.'''