From 0ca22dfbc22d89d33f37ff1661f24e6ea6654499 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 21 Jan 2009 17:01:42 +0000 Subject: Remove old properties implementation and hardwiring git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5036 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugin.py | 34 ++-------------------------------- src/lib/Server/Plugins/Cfg.py | 6 +++--- src/lib/Server/Plugins/Probes.py | 2 +- src/lib/Server/Plugins/SGenshi.py | 11 ++--------- src/lib/Server/Plugins/TCheetah.py | 10 +++------- src/lib/Server/Plugins/TGenshi.py | 8 +++----- 6 files changed, 14 insertions(+), 57 deletions(-) diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index 6b8c33254..8d702d435 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -491,7 +491,7 @@ class Specificity: return False class SpecificData(object): - def __init__(self, name, _, specific, encoding): + def __init__(self, name, specific, encoding): self.name = name self.specific = specific @@ -506,11 +506,10 @@ class SpecificData(object): class EntrySet: '''Entry sets deal with the host- and group-specific entries''' ignore = re.compile("^(\.#.*|.*~|\\..*\\.(tmp|sw[px]))$") - def __init__(self, basename, path, props, entry_type, encoding): + def __init__(self, basename, path, entry_type, encoding): self.path = path self.entry_type = entry_type self.entries = {} - self.properties = props self.metadata = default_file_metadata.copy() self.infoxml = None self.encoding = encoding @@ -556,7 +555,6 @@ class EntrySet: logger.error("Could not process filename %s; ignoring" % fpath) return self.entries[event.filename] = self.entry_type(fpath, - self.properties, spec, self.encoding) self.entries[event.filename].handle_event(event) @@ -644,29 +642,11 @@ class EntrySet: raise PluginExecutionError -# GroupSpool plugin common code (for TGenshi, TCheetah, and Cfg) - -class TemplateProperties(SingleXMLFileBacked): - '''Class for Genshi properties''' - def Index(self): - '''Build data into an elementtree object for templating usage''' - try: - self.properties = lxml.etree.XML(self.data) - del self.data - except lxml.etree.XMLSyntaxError: - logger.error("Failed to parse properties.xml; disabling") - -class FakeProperties: - '''Dummy class used when properties dont exist''' - def __init__(self): - self.properties = lxml.etree.Element("Properties") - class GroupSpool(Plugin, Generator): '''The TGenshi generator implements a templating mechanism for configuration files''' name = 'GroupSpool' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' - use_props = False filename_pattern = "" es_child_cls = object es_cls = EntrySet @@ -681,15 +661,6 @@ class GroupSpool(Plugin, Generator): self.handles = {} self.AddDirectoryMonitor('') self.encoding = core.encoding - if self.use_props: - try: - self.properties = TemplateProperties( \ - '%s/../etc/properties.xml' % (self.data), self.core.fam) - except: - self.properties = FakeProperties() - self.logger.info("%s properties disabled" % self.name) - else: - self.properties = FakeProperties() def HandleEvent(self, event): '''Unified FAM event handler for DirShadow''' @@ -710,7 +681,6 @@ class GroupSpool(Plugin, Generator): dirpath = "".join([self.data, ident]) self.entries[ident] = self.es_cls(self.filename_pattern, dirpath, - self.properties, self.es_child_cls, self.encoding) self.Entries['ConfigFile'][ident] = self.entries[ident].bind_entry diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index 85ace20bc..f9a2f737d 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -49,8 +49,9 @@ class CfgMatcher: return self.basefile_reg.match(fname) class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet): - def __init__(self, basename, path, props, entry_type, encoding): - Bcfg2.Server.Plugin.EntrySet.__init__(self, basename, path, props, entry_type, encoding) + def __init__(self, basename, path, entry_type, encoding): + Bcfg2.Server.Plugin.EntrySet.__init__(self, basename, path, entry_type, + encoding) self.specific = CfgMatcher(path.split('/')[-1]) def sort_by_specific(self, one, other): @@ -131,7 +132,6 @@ class Cfg(Bcfg2.Server.Plugin.GroupSpool, name = 'Cfg' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' - use_props = False es_cls = CfgEntrySet es_child_cls = Bcfg2.Server.Plugin.SpecificData diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py index 6c7590da0..10b729fde 100644 --- a/src/lib/Server/Plugins/Probes.py +++ b/src/lib/Server/Plugins/Probes.py @@ -8,7 +8,7 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet): def __init__(self, path, fam, encoding, plugin_name): fpattern = '[0-9A-Za-z_\-]+' self.plugin_name = plugin_name - Bcfg2.Server.Plugin.EntrySet.__init__(self, fpattern, path, True, + Bcfg2.Server.Plugin.EntrySet.__init__(self, fpattern, path, Bcfg2.Server.Plugin.SpecificData, encoding) fam.AddMonitor(path, self) diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py index e7e0b94b8..93dc15e7b 100644 --- a/src/lib/Server/Plugins/SGenshi.py +++ b/src/lib/Server/Plugins/SGenshi.py @@ -9,8 +9,7 @@ logger = logging.getLogger('Bcfg2.Plugins.SGenshi') class SGenshiTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile): def get_xml_value(self, metadata): - stream = self.template.generate(metadata=metadata, - properties=self.properties.properties).filter( \ + stream = self.template.generate(metadata=metadata,).filter( \ Bcfg2.Server.Plugins.TGenshi.removecomment) data = stream.render('xml') return lxml.etree.XML(data) @@ -18,13 +17,7 @@ class SGenshiTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile): class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet): def __init__(self, path, fam, encoding): fpattern = '\S+\.xml' - try: - properties = Bcfg2.Server.Plugin.TemplateProperties( \ - '%s/../etc/properties.xml' % (path), fam) - except: - properties = Bcfg2.Server.Plugin.FakeProperties() - - Bcfg2.Server.Plugin.EntrySet.__init__(self, fpattern, path, properties, + Bcfg2.Server.Plugin.EntrySet.__init__(self, fpattern, path, SGenshiTemplateFile, encoding) fam.AddMonitor(path, self) diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index c2e632351..9806e5787 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -9,13 +9,11 @@ logger = logging.getLogger('Bcfg2.Plugins.TCheetah') class TemplateFile: '''Template file creates Cheetah template structures for the loaded file''' - def __init__(self, name, properties, specific, encoding): + def __init__(self, name, specific, encoding): self.name = name - self.properties = properties self.specific = specific self.encoding = encoding self.template = None - self.searchlist = {'properties': properties} def handle_event(self, event): '''Handle all fs events for this template''' @@ -24,9 +22,7 @@ class TemplateFile: try: s = {'useStackFrames': False} self.template = Cheetah.Template.Template(open(self.name).read(), - compilerSettings=s, - searchList = [self.searchlist]) - self.template.properties = self.properties.properties + compilerSettings=s) except Cheetah.Parser.ParseError, perror: logger.error("Cheetah parse error for file %s" % (self.name)) logger.error(perror.report()) @@ -62,4 +58,4 @@ class TCheetah(Bcfg2.Server.Plugin.GroupSpool): __author__ = 'bcfg-dev@mcs.anl.gov' filename_pattern = 'template' es_child_cls = TemplateFile - use_props = True + diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py index 1dfe2f3c5..40e65b877 100644 --- a/src/lib/Server/Plugins/TGenshi.py +++ b/src/lib/Server/Plugins/TGenshi.py @@ -23,9 +23,8 @@ def removecomment(stream): class TemplateFile: '''Template file creates Genshi template structures for the loaded file''' - def __init__(self, name, properties, specific, encoding): + def __init__(self, name, specific, encoding): self.name = name - self.properties = properties self.specific = specific self.encoding = encoding if self.specific.all: @@ -62,8 +61,8 @@ class TemplateFile: fname = entry.get('realname', entry.get('name')) try: stream = self.template.generate( \ - name=fname, metadata=metadata, path=self.name, - properties=self.properties).filter(removecomment) + name=fname, metadata=metadata, + path=self.name).filter(removecomment) if have_ntt: ttypes = [TextTemplate, NewTextTemplate] else: @@ -99,6 +98,5 @@ class TGenshi(Bcfg2.Server.Plugin.GroupSpool): name = 'TGenshi' __version__ = '$Id$' __author__ = 'jeff@ocjtech.us' - use_props = True filename_pattern = 'template\.(txt|newtxt|xml)' es_child_cls = TemplateFile -- cgit v1.2.3-1-g7c22