summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-03-21 19:54:01 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-03-21 19:54:01 +0000
commit5a355d83a0a3c3e693787e8627a041850f006950 (patch)
tree52a13a5c011a4f27e317ebb8a7ce3cebe39c38d8 /src
parentfaedeaa2be43630da9f07b90e33221030d85baba (diff)
downloadbcfg2-5a355d83a0a3c3e693787e8627a041850f006950.tar.gz
bcfg2-5a355d83a0a3c3e693787e8627a041850f006950.tar.bz2
bcfg2-5a355d83a0a3c3e693787e8627a041850f006950.zip
plugin infrastructure improvements
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4432 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugin.py45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index b7109732f..0166abaa8 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -8,11 +8,12 @@ from lxml.etree import XML, XMLSyntaxError
logger = logging.getLogger('Bcfg2.Plugin')
default_file_metadata = {'owner': 'root', 'group': 'root', 'perms': '644',
- 'encoding': 'ascii'}
+ 'encoding': 'ascii', 'paranoid':"false"}
info_regex = re.compile( \
- '^owner:(\s)*(?P<owner>\w+)$|group:(\s)*(?P<group>\w+)$|' +
- 'perms:(\s)*(?P<perms>\w+)$')
+ '^owner:(\s)*(?P<owner>\S+)|group:(\s)*(?P<group>\S+)|' +
+ 'perms:(\s)*(?P<perms>\w+)|encoding:(\s)*(?P<encoding>\w+)|' +
+ '(?P<paranoid>paranoid(\s)*)|mtime:(\s)*(?P<mtime>\w+)$' )
class PluginInitError(Exception):
'''Error raised in cases of Plugin initialization errors'''
@@ -419,6 +420,30 @@ class Specificity:
self.hostname == metadata.hostname or \
self.group in metadata.group
+ def __cmp__(self, other):
+ '''sort most to least specific'''
+ if self.all:
+ return 1
+ if self.group:
+ if other.hostname:
+ return 1
+ if other.group and other.prio > self.prio:
+ return 1
+ if other.group and other.prio == self.prio:
+ return 0
+ return -1
+
+ def more_specific(self, other):
+ '''test if self is more specific than other'''
+ if self.all:
+ True
+ elif self.group:
+ if other.hostname:
+ return True
+ elif other.group and other.prio > self.prio:
+ return True
+ return False
+
class EntrySet:
'''Entry sets deal with the host- and group-specific entries'''
def __init__(self, basename, path, props, entry_type):
@@ -484,14 +509,12 @@ class EntrySet:
continue
else:
mgd = match.groupdict()
- if mgd['owner']:
- self.metadata['owner'] = mgd['owner']
- elif mgd['group']:
- self.metadata['group'] = mgd['group']
- elif mgd['perms']:
- self.metadata['perms'] = mgd['perms']
- if len(self.metadata['perms']) == 3:
- self.metadata['perms'] = "0%s" % (self.metadata['perms'])
+ for key, value in mgd.iteritems():
+ if value:
+ self.metadata[key] = value
+ if len(self.metadata['perms']) == 3:
+ self.metadata['perms'] = "0%s" % \
+ (self.metadata['perms'])
def reset_metadata(self, event):
'''reset metadata to defaults if info or info.xml removed'''