diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-01-18 16:41:20 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-01-18 16:41:20 +0000 |
commit | 441f870b6c25dd4ff861555cdfe0518b2f276a3e (patch) | |
tree | 00099912c7434284476b2bf30489fd987fd68d30 /src | |
parent | a48f5677961538cbba6c3e794e1d267649f8a15d (diff) | |
download | bcfg2-441f870b6c25dd4ff861555cdfe0518b2f276a3e.tar.gz bcfg2-441f870b6c25dd4ff861555cdfe0518b2f276a3e.tar.bz2 bcfg2-441f870b6c25dd4ff861555cdfe0518b2f276a3e.zip |
Implement file filtering for XMLDirectories (Base, Bundler, Pkgmgr, Rules, Svcmgr) (Resolves Ticket #300)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2695 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugin.py | 17 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Base.py | 4 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Bundler.py | 4 |
3 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index 6b37585ed..6fe3d6a43 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -1,7 +1,7 @@ '''This module provides the baseclass for Bcfg2 Server Plugins''' __revision__ = '$Revision$' -import logging, lxml.etree +import logging, lxml.etree, re from lxml.etree import XML, XMLSyntaxError @@ -89,8 +89,9 @@ class FileBacked(object): class DirectoryBacked(object): '''This object is a coherent cache for a filesystem hierarchy of files.''' __child__ = FileBacked + patterns = re.compile('.*') - def __init__(self, name, fam): + def __init__(self, name, fam) object.__init__(self) self.name = name self.fam = fam @@ -113,6 +114,8 @@ class DirectoryBacked(object): else: if ((name[-1] == '~') or (name[:2] == '.#') or (name[-4:] == '.swp') or (name in ['SCCS', '.svn'])): return + if not self.patterns.match(name): + return self.entries[name] = self.__child__('%s/%s' % (self.name, name)) self.entries[name].HandleEvent() @@ -302,7 +305,11 @@ class XMLSrc(XMLFileBacked): self.pnode.Match(metadata, cache[1]) self.cache = cache -class PrioDir(Plugin, DirectoryBacked): +class XMLDirectoryBacked(DirectoryBacked): + '''Directorybacked for *.xml''' + patterns = re.compile('.*\.xml') + +class PrioDir(Plugin, XMLDirectoryBacked): '''This is a generator that handles package assignments''' __name__ = 'PrioDir' __child__ = XMLSrc @@ -310,14 +317,14 @@ class PrioDir(Plugin, DirectoryBacked): def __init__(self, core, datastore): Plugin.__init__(self, core, datastore) try: - DirectoryBacked.__init__(self, self.data, self.core.fam) + XMLDirectoryBacked.__init__(self, self.data, self.core.fam) except OSError: self.logger.error("Failed to load %s indices" % (self.__name__)) raise PluginInitError def HandleEvent(self, event): '''Handle events and update dispatch table''' - DirectoryBacked.HandleEvent(self, event) + XMLDirectoryBacked.HandleEvent(self, event) for src in self.entries.values(): for itype, children in src.items.iteritems(): for child in children: diff --git a/src/lib/Server/Plugins/Base.py b/src/lib/Server/Plugins/Base.py index 11e066f63..2a849236f 100644 --- a/src/lib/Server/Plugins/Base.py +++ b/src/lib/Server/Plugins/Base.py @@ -5,7 +5,7 @@ import Bcfg2.Server.Plugin import copy import lxml.etree -class Base(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked): +class Base(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.XMLDirectoryBacked): '''This Structure is good for the pile of independent configs needed for most actual systems''' __name__ = 'Base' __version__ = '$Id$' @@ -17,7 +17,7 @@ class Base(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) self.fragements = {} try: - Bcfg2.Server.Plugin.DirectoryBacked.__init__(self, self.data, self.core.fam) + Bcfg2.Server.Plugin.XMLDirectoryBacked.__init__(self, self.data, self.core.fam) except OSError: self.logger.error("Failed to load Base repository") raise Bcfg2.Server.Plugin.PluginInitError diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py index 59b0dead4..597421699 100644 --- a/src/lib/Server/Plugins/Bundler.py +++ b/src/lib/Server/Plugins/Bundler.py @@ -3,7 +3,7 @@ __revision__ = '$Revision$' import copy, lxml.etree, Bcfg2.Server.Plugin -class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked): +class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.XMLDirectoryBacked): '''The bundler creates dependent clauses based on the bundle/translation scheme from bcfg1''' __name__ = 'Bundler' __version__ = '$Id$' @@ -13,7 +13,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.DirectoryBacked): def __init__(self, core, datastore): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) try: - Bcfg2.Server.Plugin.DirectoryBacked.__init__(self, self.data, self.core.fam) + Bcfg2.Server.Plugin.XMLDirectoryBacked.__init__(self, self.data, self.core.fam) except OSError: self.logger.error("Failed to load Bundle repository") raise Bcfg2.Server.Plugin.PluginInitError |