diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-01-15 03:11:16 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-01-15 03:11:16 +0000 |
commit | da1065ef071514f97d6bfbe104bd1040503da4aa (patch) | |
tree | b148ce4c4facc7e6dcfd4f8ef961b33f94e30df2 | |
parent | 6b0fd34ab8c5e4f76835eb5d59a57ec3337cbeb0 (diff) | |
download | bcfg2-da1065ef071514f97d6bfbe104bd1040503da4aa.tar.gz bcfg2-da1065ef071514f97d6bfbe104bd1040503da4aa.tar.bz2 bcfg2-da1065ef071514f97d6bfbe104bd1040503da4aa.zip |
add GBundler plugin (like SGenshi, but works like Bundler)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5025 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | doc/1.0-roadmap | 1 | ||||
-rw-r--r-- | doc/plugin-roles | 3 | ||||
-rw-r--r-- | src/lib/Server/Core.py | 14 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Bundler.py | 2 | ||||
-rw-r--r-- | src/lib/Server/Plugins/GBundler.py | 38 | ||||
-rw-r--r-- | src/lib/Server/Plugins/SGenshi.py | 3 | ||||
-rw-r--r-- | src/lib/Server/Plugins/__init__.py | 4 |
7 files changed, 56 insertions, 9 deletions
diff --git a/doc/1.0-roadmap b/doc/1.0-roadmap index dc2236879..d6dc4cefc 100644 --- a/doc/1.0-roadmap +++ b/doc/1.0-roadmap @@ -10,3 +10,4 @@ server. ** Version Control Backend ** Clean up client/server statistics data format ** Multithreaded server (sync from Cobalt) +** properties switch to connector plugin diff --git a/doc/plugin-roles b/doc/plugin-roles index cc96717b7..c23b2a236 100644 --- a/doc/plugin-roles +++ b/doc/plugin-roles @@ -33,6 +33,8 @@ This documents available plugin roles. * Structure ** Produce a list of configuration entries that should be included in client configurations +** Each structure plugin is produces a list of structures +** Core verifies that each bundle listed has been constructed * Structure Validation ** Validate a client entry list's internal consistency, modifying if needed * Generator @@ -81,3 +83,4 @@ bcfg2.conf. 5) Notes * Need to fix host specific probe behavior (with basenames) +* Need to ensure bundle accumulation occurs with connector groups
\ No newline at end of file diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index a99af4aa9..74839c25e 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -1,5 +1,5 @@ '''Bcfg2.Server.Core provides the runtime support for bcfg2 modules''' -__revision__ = '$Revision: 5014 $' +__revision__ = '$Revision$' from ConfigParser import ConfigParser, NoSectionError, NoOptionError c = ConfigParser() @@ -117,9 +117,15 @@ class Core(object): def GetStructures(self, metadata): '''Get all structures for client specified by metadata''' - return reduce(lambda x, y:x+y, - [struct.BuildStructures(metadata) for struct \ - in self.structures], []) + structures = reduce(lambda x, y:x+y, + [struct.BuildStructures(metadata) for struct \ + in self.structures], []) + sbundles = [b.get('name') for b in structures if b.tag == 'Bundle'] + missing = [b for b in metadata.bundles if b not in sbundles] + if missing: + logger.error("Client %s configuration missing bundles: %s" \ + % (metadata.hostname, ':'.join(missing))) + return structures def BindStructure(self, structure, metadata): '''Bind a complete structure''' diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py index fe73ab453..8c89d041f 100644 --- a/src/lib/Server/Plugins/Bundler.py +++ b/src/lib/Server/Plugins/Bundler.py @@ -26,8 +26,6 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, bundleset = [] for bundlename in metadata.bundles: if not ("%s.xml" % bundlename) in self.entries: - self.logger.error("Client %s requested nonexistent bundle %s" % \ - (metadata.hostname, bundlename)) continue bundle = lxml.etree.Element('Bundle', name=bundlename) [bundle.append(copy.deepcopy(item)) diff --git a/src/lib/Server/Plugins/GBundler.py b/src/lib/Server/Plugins/GBundler.py new file mode 100644 index 000000000..309f04b3e --- /dev/null +++ b/src/lib/Server/Plugins/GBundler.py @@ -0,0 +1,38 @@ + +import logging, re +import SGenshi + +pattern = '(.*/)?(\S+)\.xml(\.((H_(?P<hostname>\S+))|' +pattern += '(G(?P<prio>\d+)_(?P<group>\S+))))?$' + +matcher = re.compile(pattern) + +logger = logging.getLogger('GBundler') + +class GBundlerEntrySet(SGenshi.SGenshiEntrySet): + def BuildStructures(self, metadata): + '''Build SGenshi structures''' + ret = [] + found = [] + build = [] + matching = self.get_matching(metadata) + matching.sort(lambda x,y: cmp(x.specific, y.specific)) + for entry in matching[:]: + rem = matcher.match(entry.name) + bname = rem.group(2) + if bname in metadata.bundles and bname not in found: + found.append(bname) + build.append(entry) + + for entry in build: + try: + ret.append(entry.get_xml_value(metadata)) + except genshi.template.TemplateError, terror: + logger.error('Genshi template error: %s' % terror) + logger.error("GBundler: Failed to template file %s" % entry.name) + return ret + +class GBundler(GBundlerEntrySet, SGenshi.SGenshi): + name = 'GBundler' + __version__ = '$Revision: $' + diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py index a4b811f21..e7e0b94b8 100644 --- a/src/lib/Server/Plugins/SGenshi.py +++ b/src/lib/Server/Plugins/SGenshi.py @@ -58,7 +58,8 @@ class SGenshi(SGenshiEntrySet, try: SGenshiEntrySet.__init__(self, self.data, self.core.fam, core.encoding) except: - logger.error("Failed to load SGenshi repository; disabling SGenshi") + logger.error("Failed to load %s repository; disabling %s" \ + % (self.name, self.name)) raise Bcfg2.Server.Plugin.PluginInitError diff --git a/src/lib/Server/Plugins/__init__.py b/src/lib/Server/Plugins/__init__.py index ffab21b9a..22b16a7a0 100644 --- a/src/lib/Server/Plugins/__init__.py +++ b/src/lib/Server/Plugins/__init__.py @@ -1,7 +1,7 @@ '''imports for Bcfg2.Server.Plugins''' __revision__ = '$Revision$' -__all__ = ['Account', 'Base', 'Bundler', 'Cfg', 'Decisions', 'Hostbase', - 'Metadata', 'NagiosGen', 'Probes', +__all__ = ['Account', 'Base', 'Bundler', 'Cfg', 'Decisions', 'GBundler', + 'Hostbase', 'Metadata', 'NagiosGen', 'Probes', 'Pkgmgr', 'Rules', 'SSHbase', 'Statistics', 'Svcmgr', 'TCheetah', 'SGenshi', 'TGenshi', 'Vhost'] |