From a6b6871ecbc700229969f350b869bd19e785129d Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 15 Aug 2012 14:53:18 -0400 Subject: Removed deprecated plugins BB, Svcmgr, SGenshi --- doc/appendix/files/ntp.txt | 93 ++++++++++++++-------------- examples/bcfg2.confHostbase | 3 +- man/bcfg2-build-reports.8 | 2 +- man/bcfg2-info.8 | 2 +- man/bcfg2-lint.8 | 2 +- man/bcfg2-lint.conf.5 | 2 +- man/bcfg2-reports.8 | 2 +- man/bcfg2-server.8 | 2 +- man/bcfg2.conf.5 | 7 +-- schemas/bundle.xsd | 2 +- schemas/services.xsd | 33 ---------- solaris/prototype.bcfg2-server | 3 - src/lib/Bcfg2/Server/Admin/Init.py | 1 - src/lib/Bcfg2/Server/Admin/Pull.py | 2 +- src/lib/Bcfg2/Server/Admin/Viz.py | 2 +- src/lib/Bcfg2/Server/Lint/GroupNames.py | 12 ++-- src/lib/Bcfg2/Server/Lint/RequiredAttrs.py | 12 ++-- src/lib/Bcfg2/Server/Lint/Validate.py | 1 - src/lib/Bcfg2/Server/Plugins/BB.py | 85 -------------------------- src/lib/Bcfg2/Server/Plugins/Bundler.py | 57 ++++++++++++++++- src/lib/Bcfg2/Server/Plugins/SGenshi.py | 98 ------------------------------ src/lib/Bcfg2/Server/Plugins/Svcmgr.py | 10 --- src/lib/Bcfg2/Server/Plugins/__init__.py | 2 - src/sbin/bcfg2-info | 4 +- tools/manpagegen/bcfg2.conf.5.ronn | 6 -- 25 files changed, 127 insertions(+), 318 deletions(-) delete mode 100644 schemas/services.xsd delete mode 100644 src/lib/Bcfg2/Server/Plugins/BB.py delete mode 100644 src/lib/Bcfg2/Server/Plugins/SGenshi.py delete mode 100644 src/lib/Bcfg2/Server/Plugins/Svcmgr.py diff --git a/doc/appendix/files/ntp.txt b/doc/appendix/files/ntp.txt index 53b3347c8..38d5e2208 100644 --- a/doc/appendix/files/ntp.txt +++ b/doc/appendix/files/ntp.txt @@ -19,95 +19,92 @@ Package only ------------ Our example starts with the bare minimum configuration setup. We have -a client, a profile group, a list of packages, and a base configuration. +a client, a profile group, a list of packages, and an NTP bundle. ``Metadata/clients.xml``: .. code-block:: xml - - + + ``Metadata/groups.xml``: .. code-block:: xml - - + + + + -``Base/base.xml``: +``Bundler/ntp.xml``: .. code-block:: xml - - - - - + + + ``Pkgmgr/packages.xml``: .. code-block:: xml - + +(This can also be performed more elegantly with the +:ref:`server-plugins-generators-pacakges` plugin.) + Add service ----------- -Configure the service, and add it to the base. +Configure the service, and add it to Rules. -``Svcmgr/services.xml``: +``Rules/services.xml``: .. code-block:: xml - + -``Base/base.xml``: +``Bundler/ntp.xml``: .. code-block:: xml - - - - - - + + + + Add config file --------------- -Setup an ``etc/`` directory structure, and add it to the base.:: +Setup an ``etc/`` directory structure, and add it to the base:: # cat Cfg/etc/ntp.conf/ntp.conf server ntp1.utexas.edu ``Base/base.xml``: +``Bundler/ntp.xml``: + .. code-block:: xml - - - - - - - + + + + + Create a bundle --------------- -The above configuration layout works fine for a single service, but -that method of organization would quickly become a nightmare as you -approach the number of packages, services, and config files required -to represent a fully configured host. Bundles allow the grouping of -related configuration entries that are used to provide a single -service. This is done for several reasons: +Bundles allow the grouping of related configuration entries that are +used to provide a single service. This is done for several reasons: * Grouping related things in one place makes it easier to add those entries for multiple groups of clients @@ -128,10 +125,10 @@ logically grouped together. We use a bundle to accomplish this. .. code-block:: xml - - - - + + + + After this bundle is created, it must be associated with a group @@ -143,15 +140,15 @@ install this bundle. .. code-block:: xml - ... - - - - ... + ... + + + + ... -Once this bundle is created, a client reconfigure will install -these entries. If any are modified, then the *ntpd* service will -be restarted. If you only want ntp configurations to be updated (and +Once this bundle is created, a client reconfigure will install these +entries. If any are modified, then the *ntpd* service will be +restarted. If you only want ntp configurations to be updated (and nothing else), the bcfg2 client can be run with a ``-b `` option that will only update entries in the specified bundle. diff --git a/examples/bcfg2.confHostbase b/examples/bcfg2.confHostbase index b130cf4f7..c9420e34a 100644 --- a/examples/bcfg2.confHostbase +++ b/examples/bcfg2.confHostbase @@ -1,7 +1,6 @@ [server] repository = /var/lib/bcfg2 -structures = Bundler,Base -generators = SSHbase,Cfg,Pkgmgr,Svcmgr +plugins = Bundler,Rules,Metadata,SSHbase,Cfg [statistics] sendmailpath = /usr/sbin/sendmail diff --git a/man/bcfg2-build-reports.8 b/man/bcfg2-build-reports.8 index 7ece94c32..3c61e8356 100644 --- a/man/bcfg2-build-reports.8 +++ b/man/bcfg2-build-reports.8 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-BUILD\-REPORTS" "8" "June 2012" "" "" +.TH "BCFG2\-BUILD\-REPORTS" "8" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-build\-reports\fR \- Generate state reports for Bcfg2 clients diff --git a/man/bcfg2-info.8 b/man/bcfg2-info.8 index 12b6ae9c6..bb515079f 100644 --- a/man/bcfg2-info.8 +++ b/man/bcfg2-info.8 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-INFO" "8" "June 2012" "" "" +.TH "BCFG2\-INFO" "8" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-info\fR \- Creates a local version of the Bcfg2 server core for state observation diff --git a/man/bcfg2-lint.8 b/man/bcfg2-lint.8 index 02d472d22..7a5a69b7a 100644 --- a/man/bcfg2-lint.8 +++ b/man/bcfg2-lint.8 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-LINT" "8" "June 2012" "" "" +.TH "BCFG2\-LINT" "8" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-lint\fR \- Check Bcfg2 specification for validity, common mistakes, and style diff --git a/man/bcfg2-lint.conf.5 b/man/bcfg2-lint.conf.5 index 467a717b0..d23afa8dc 100644 --- a/man/bcfg2-lint.conf.5 +++ b/man/bcfg2-lint.conf.5 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-LINT\.CONF" "5" "June 2012" "" "" +.TH "BCFG2\-LINT\.CONF" "5" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-lint\.conf\fR \- configuration parameters for bcfg2\-lint diff --git a/man/bcfg2-reports.8 b/man/bcfg2-reports.8 index f1091eb31..b2c0cad43 100644 --- a/man/bcfg2-reports.8 +++ b/man/bcfg2-reports.8 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-REPORTS" "8" "June 2012" "" "" +.TH "BCFG2\-REPORTS" "8" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-reports\fR \- Query reporting system for client status diff --git a/man/bcfg2-server.8 b/man/bcfg2-server.8 index b1a3a7703..955f541c9 100644 --- a/man/bcfg2-server.8 +++ b/man/bcfg2-server.8 @@ -1,5 +1,5 @@ . -.TH "BCFG2\-SERVER" "8" "June 2012" "" "" +.TH "BCFG2\-SERVER" "8" "August 2012" "" "" . .SH "NAME" \fBbcfg2\-server\fR \- Server for client configuration specifications diff --git a/man/bcfg2.conf.5 b/man/bcfg2.conf.5 index 2cb387cad..b62d223c9 100644 --- a/man/bcfg2.conf.5 +++ b/man/bcfg2.conf.5 @@ -1,5 +1,5 @@ . -.TH "BCFG2\.CONF" "5" "June 2012" "" "" +.TH "BCFG2\.CONF" "5" "August 2012" "" "" . .SH "NAME" \fBbcfg2\.conf\fR \- configuration parameters for Bcfg2 @@ -49,7 +49,7 @@ This setting tells the server to listen on all available interfaces\. The defaul A comma\-delimited list of enabled server plugins\. Currently available plugins are: . .IP -\fBAccount\fR, \fBActions\fR, \fBBB\fR, \fBBase\fR, \fBBundler\fR, \fBBzr\fR, \fBCfg\fR, \fBCvs\fR, \fBDarcs\fR, \fBDBStats\fR, \fBDecisions\fR, \fBDeps\fR, \fBEditor\fR, \fBFossil\fR, \fBGit\fR, \fBGroupPatterns\fR, \fBHg\fR, \fBHostbase\fR, \fBMetadata\fR, \fBNagiosGen\fR, \fBOhai\fR, \fBPackages\fR, \fBPkgmgr\fR, \fBProbes\fR, \fBProperties\fR, \fBRules\fR, \fBSGenshi\fR, \fBSnapshots\fR, \fBSSHbase\fR, \fBSvn\fR, \fBSvn2\fR, \fBTCheetah\fR, \fBTGenshi\fR, \fBTrigger\fR +\fBAccount\fR, \fBActions\fR, \fBBase\fR, \fBBundler\fR, \fBBzr\fR, \fBCfg\fR, \fBCvs\fR, \fBDarcs\fR, \fBDBStats\fR, \fBDecisions\fR, \fBDeps\fR, \fBEditor\fR, \fBFossil\fR, \fBGit\fR, \fBGroupPatterns\fR, \fBHg\fR, \fBHostbase\fR, \fBMetadata\fR, \fBNagiosGen\fR, \fBOhai\fR, \fBPackages\fR, \fBPkgmgr\fR, \fBProbes\fR, \fBProperties\fR, \fBRules\fR, \fBSnapshots\fR, \fBSSHbase\fR, \fBSvn\fR, \fBSvn2\fR, \fBTCheetah\fR, \fBTGenshi\fR, \fBTrigger\fR . .IP Descriptions of each plugin can be found in their respective sections below\. @@ -78,9 +78,6 @@ The account plugin manages authentication data, including the following\. . .IP "" 0 . -.SS "BB Plugin" -The BB plugin maps users to machines and metadata to machines\. -. .SS "Base Plugin" A structure plugin that provides the ability to add lists of unrelated entries into client configuration entry inventories\. Base works much like Bundler in its file format\. This structure plugin is good for the pile of independent configs needed for most actual systems\. . diff --git a/schemas/bundle.xsd b/schemas/bundle.xsd index b72b174e2..6306b6da4 100644 --- a/schemas/bundle.xsd +++ b/schemas/bundle.xsd @@ -17,7 +17,7 @@ - + diff --git a/schemas/services.xsd b/schemas/services.xsd deleted file mode 100644 index b91e851d2..000000000 --- a/schemas/services.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - services schema for bcfg2 - Narayan Desai, Argonne National Laboratory - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/solaris/prototype.bcfg2-server b/solaris/prototype.bcfg2-server index ee9e3a3a7..590175329 100644 --- a/solaris/prototype.bcfg2-server +++ b/solaris/prototype.bcfg2-server @@ -24,7 +24,6 @@ f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Probes.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Decisions.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Rules.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Packages.py 0644 bin bin -f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/SGenshi.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/GroupPatterns.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/SSHbase.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Trigger.py 0644 bin bin @@ -32,7 +31,6 @@ f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/__init__.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Snapshots.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/TCheetah.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Account.py 0644 bin bin -f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/BB.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Cfg.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Statistics.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Metadata.py 0644 bin bin @@ -41,7 +39,6 @@ f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Pkgmgr.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Ohai.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Properties.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Editor.py 0644 bin bin -f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Svcmgr.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Bundler.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/NagiosGen.py 0644 bin bin f none lib/PYVERSION/site-packages/Bcfg2/Server/Plugins/Deps.py 0644 bin bin diff --git a/src/lib/Bcfg2/Server/Admin/Init.py b/src/lib/Bcfg2/Server/Admin/Init.py index cbcef3405..77c3c1ade 100644 --- a/src/lib/Bcfg2/Server/Admin/Init.py +++ b/src/lib/Bcfg2/Server/Admin/Init.py @@ -104,7 +104,6 @@ plugin_list = ['Account', 'SSHbase', 'SSLCA', 'Statistics', - 'Svcmgr', 'TCheetah', 'TGenshi'] diff --git a/src/lib/Bcfg2/Server/Admin/Pull.py b/src/lib/Bcfg2/Server/Admin/Pull.py index 816fd2ca7..70984c57d 100644 --- a/src/lib/Bcfg2/Server/Admin/Pull.py +++ b/src/lib/Bcfg2/Server/Admin/Pull.py @@ -27,7 +27,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore): "interactive", "-s", "stdin")) - allowed = ['Metadata', 'BB', "DBStats", "Statistics", "Cfg", "SSHbase"] + allowed = ['Metadata', "DBStats", "Statistics", "Cfg", "SSHbase"] def __init__(self, setup): Bcfg2.Server.Admin.MetadataCore.__init__(self, setup) diff --git a/src/lib/Bcfg2/Server/Admin/Viz.py b/src/lib/Bcfg2/Server/Admin/Viz.py index 2faa423c1..b190dd62a 100644 --- a/src/lib/Bcfg2/Server/Admin/Viz.py +++ b/src/lib/Bcfg2/Server/Admin/Viz.py @@ -35,7 +35,7 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): __plugin_blacklist__ = ['DBStats', 'Snapshots', 'Cfg', 'Pkgmgr', 'Packages', 'Rules', 'Account', 'Decisions', 'Deps', 'Git', 'Svn', 'Fossil', 'Bzr', 'Bundler', 'TGenshi', - 'SGenshi', 'Base'] + 'Base'] def __call__(self, args): Bcfg2.Server.Admin.MetadataCore.__call__(self, args) diff --git a/src/lib/Bcfg2/Server/Lint/GroupNames.py b/src/lib/Bcfg2/Server/Lint/GroupNames.py index 069d5d2a5..5df98a30e 100644 --- a/src/lib/Bcfg2/Server/Lint/GroupNames.py +++ b/src/lib/Bcfg2/Server/Lint/GroupNames.py @@ -1,9 +1,11 @@ import os import re import Bcfg2.Server.Lint -from Bcfg2.Server.Plugins.Bundler import have_genshi -if have_genshi: - from Bcfg2.Server.Plugins.SGenshi import SGenshiTemplateFile +try: + from Bcfg2.Server.Plugins.Bundler import BundleTemplateFile + has_genshi = True +except ImportError: + has_genshi = False class GroupNames(Bcfg2.Server.Lint.ServerPlugin): """ ensure that all named groups are valid group names """ @@ -37,8 +39,8 @@ class GroupNames(Bcfg2.Server.Lint.ServerPlugin): """ check bundles for BoundPath entries with missing attrs """ for bundle in self.core.plugins['Bundler'].entries.values(): if (self.HandlesFile(bundle.name) and - (not have_genshi or - not isinstance(bundle, SGenshiTemplateFile))): + (not has_genshi or + not isinstance(bundle, BundleTemplateFile))): self.check_entries(bundle.xdata.xpath("//Group"), bundle.name) diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py index b9a6dc2dc..fcb7c6c28 100644 --- a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py +++ b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py @@ -5,9 +5,11 @@ import Bcfg2.Server.Lint import Bcfg2.Client.Tools.POSIX import Bcfg2.Client.Tools.VCS from Bcfg2.Server.Plugins.Packages import Apt, Yum -from Bcfg2.Server.Plugins.Bundler import have_genshi -if have_genshi: - from Bcfg2.Server.Plugins.SGenshi import SGenshiTemplateFile +try: + from Bcfg2.Server.Plugins.Bundler import BundleTemplateFile + has_genshi = True +except ImportError: + has_genshi = False # format verifying functions def is_filename(val): @@ -157,8 +159,8 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin): if 'Bundler' in self.core.plugins: for bundle in self.core.plugins['Bundler'].entries.values(): if (self.HandlesFile(bundle.name) and - (not have_genshi or - not isinstance(bundle, SGenshiTemplateFile))): + (not has_genshi or + not isinstance(bundle, BundleTemplateFile))): try: xdata = lxml.etree.XML(bundle.data) except (lxml.etree.XMLSyntaxError, AttributeError): diff --git a/src/lib/Bcfg2/Server/Lint/Validate.py b/src/lib/Bcfg2/Server/Lint/Validate.py index 5499e75c2..b8bdb4755 100644 --- a/src/lib/Bcfg2/Server/Lint/Validate.py +++ b/src/lib/Bcfg2/Server/Lint/Validate.py @@ -22,7 +22,6 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin): "%s/Rules/*.xml":"%s/rules.xsd", "%s/Defaults/*.xml":"%s/defaults.xsd", "%s/etc/report-configuration.xml":"%s/report-configuration.xsd", - "%s/Svcmgr/*.xml":"%s/services.xsd", "%s/Deps/*.xml":"%s/deps.xsd", "%s/Decisions/*.xml":"%s/decisions.xsd", "%s/Packages/sources.xml":"%s/packages.xsd", diff --git a/src/lib/Bcfg2/Server/Plugins/BB.py b/src/lib/Bcfg2/Server/Plugins/BB.py deleted file mode 100644 index bd518ad19..000000000 --- a/src/lib/Bcfg2/Server/Plugins/BB.py +++ /dev/null @@ -1,85 +0,0 @@ -import lxml.etree -import Bcfg2.Server -import Bcfg2.Server.Plugin -import glob -import os -import socket - -#manage boot symlinks - #add statistics check to do build->boot mods - -#map profiles: first array is not empty we replace the -p with a determined profile. -logger = Bcfg2.Server.Plugin.logger - -class BBfile(Bcfg2.Server.Plugin.XMLFileBacked): - """Class for bb files.""" - def Index(self): - """Build data into an xml object.""" - - try: - self.data = lxml.etree.XML(self.data, - parser=Bcfg2.Server.XMLParser) - except lxml.etree.XMLSyntaxError: - Bcfg2.Server.Plugin.logger.error("Failed to parse %s" % self.name) - return - self.tftppath = self.data.get('tftp', '/tftpboot') - self.macs = {} - self.users = {} - self.actions = {} - self.bootlinks = [] - - for node in self.data.findall('Node'): - iface = node.find('Interface') - if iface != None: - mac = "01-%s" % (iface.get('mac'.replace(':','-').lower())) - self.actions[node.get('name')] = node.get('action') - self.bootlinks.append((mac, node.get('action'))) - try: - ip = socket.gethostbyname(node.get('name')) - except: - logger.error("failed host resolution for %s" % node.get('name')) - - self.macs[node.get('name')] = (iface.get('mac'), ip) - else: - logger.error("%s" % lxml.etree.tostring(node)) - self.users[node.get('name')] = node.get('user',"").split(':') - - def enforce_bootlinks(self): - for mac, target in self.bootlinks: - path = self.tftppath + '/' + mac - if not os.path.islink(path): - logger.error("Boot file %s not a link" % path) - if target != os.readlink(path): - try: - os.unlink(path) - os.symlink(target, path) - except: - logger.error("Failed to modify link %s" % path) - -class BBDirectoryBacked(Bcfg2.Server.Plugin.DirectoryBacked): - __child__ = BBfile - - -class BB(Bcfg2.Server.Plugin.Plugin, - Bcfg2.Server.Plugin.Connector): - """The BB plugin maps users to machines and metadata to machines.""" - name = 'BB' - deprecated = True - - def __init__(self, core, datastore): - Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) - Bcfg2.Server.Plugin.Connector.__init__(self) - self.store = BBDirectoryBacked(self.data, core.fam) - - def get_additional_data(self, metadata): - - users = {} - for user in self.store.entries['bb.xml'].users.get(metadata.hostname.split(".")[0], []): - pubkeys = [] - for fname in glob.glob('/home/%s/.ssh/*.pub'%user): - pubkeys.append(open(fname).read()) - - users[user] = pubkeys - - return dict([('users', users), - ('macs', self.store.entries['bb.xml'].macs)]) diff --git a/src/lib/Bcfg2/Server/Plugins/Bundler.py b/src/lib/Bcfg2/Server/Plugins/Bundler.py index 26fe1d822..c3c71eeed 100644 --- a/src/lib/Bcfg2/Server/Plugins/Bundler.py +++ b/src/lib/Bcfg2/Server/Plugins/Bundler.py @@ -12,7 +12,7 @@ import Bcfg2.Server.Lint try: import genshi.template.base - from Bcfg2.Server.Plugins.SGenshi import SGenshiTemplateFile + import Bcfg2.Server.Plugins.TGenshi have_genshi = True except: have_genshi = False @@ -26,6 +26,57 @@ class BundleFile(Bcfg2.Server.Plugin.StructFile): return bundle +if have_genshi: + class BundleTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile, + Bcfg2.Server.Plugin.StructFile): + def __init__(self, name, specific, encoding): + Bcfg2.Server.Plugins.TGenshi.TemplateFile.__init__(self, name, + specific, + encoding) + Bcfg2.Server.Plugin.StructFile.__init__(self, name) + + def get_xml_value(self, metadata): + if not hasattr(self, 'template'): + logger.error("No parsed template information for %s" % + self.name) + raise Bcfg2.Server.Plugin.PluginExecutionError + try: + stream = self.template.generate(metadata=metadata).filter( + Bcfg2.Server.Plugins.TGenshi.removecomment) + data = lxml.etree.XML(stream.render('xml', + strip_whitespace=False), + parser=Bcfg2.Server.XMLParser) + bundlename = os.path.splitext(os.path.basename(self.name))[0] + bundle = lxml.etree.Element('Bundle', name=bundlename) + for item in self.Match(metadata, data): + bundle.append(copy.deepcopy(item)) + return bundle + except LookupError: + lerror = sys.exc_info()[1] + logger.error('Genshi lookup error: %s' % lerror) + except genshi.template.TemplateError: + terror = sys.exc_info()[1] + logger.error('Genshi template error: %s' % terror) + raise + except genshi.input.ParseError: + perror = sys.exc_info()[1] + logger.error('Genshi parse error: %s' % perror) + raise + + def Match(self, metadata, xdata): + """Return matching fragments of parsed template.""" + rv = [] + for child in xdata.getchildren(): + rv.extend(self._match(child, metadata)) + logger.debug("File %s got %d match(es)" % (self.name, len(rv))) + return rv + + + class SGenshiTemplateFile(BundleTemplateFile): + # provided for backwards compat + pass + + class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure, Bcfg2.Server.Plugin.XMLDirectoryBacked): @@ -58,7 +109,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, nsmap['py'] == 'http://genshi.edgewall.org/')): if have_genshi: spec = Bcfg2.Server.Plugin.Specificity() - return SGenshiTemplateFile(name, spec, self.encoding) + return BundleTemplateFile(name, spec, self.encoding) else: raise Bcfg2.Server.Plugin.PluginExecutionError("Genshi not available: %s" % name) else: @@ -101,7 +152,7 @@ class BundlerLint(Bcfg2.Server.Lint.ServerPlugin): for bundle in self.core.plugins['Bundler'].entries.values(): if (self.HandlesFile(bundle.name) and (not have_genshi or - not isinstance(bundle, SGenshiTemplateFile))): + not isinstance(bundle, BundleTemplateFile))): self.bundle_names(bundle) @classmethod diff --git a/src/lib/Bcfg2/Server/Plugins/SGenshi.py b/src/lib/Bcfg2/Server/Plugins/SGenshi.py deleted file mode 100644 index 12c125c62..000000000 --- a/src/lib/Bcfg2/Server/Plugins/SGenshi.py +++ /dev/null @@ -1,98 +0,0 @@ -'''This module implements a templating generator based on Genshi''' - -import genshi.input -import genshi.template -import lxml.etree -import logging -import copy -import sys -import os.path -import Bcfg2.Server -import Bcfg2.Server.Plugin -import Bcfg2.Server.Plugins.TGenshi - -logger = logging.getLogger('Bcfg2.Plugins.SGenshi') - - -class SGenshiTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile, - Bcfg2.Server.Plugin.StructFile): - def __init__(self, name, specific, encoding): - Bcfg2.Server.Plugins.TGenshi.TemplateFile.__init__(self, name, - specific, encoding) - Bcfg2.Server.Plugin.StructFile.__init__(self, name) - - def get_xml_value(self, metadata): - if not hasattr(self, 'template'): - logger.error("No parsed template information for %s" % (self.name)) - raise Bcfg2.Server.Plugin.PluginExecutionError - try: - stream = self.template.generate(metadata=metadata).filter( \ - Bcfg2.Server.Plugins.TGenshi.removecomment) - data = lxml.etree.XML(stream.render('xml', strip_whitespace=False), - parser=Bcfg2.Server.XMLParser) - bundlename = os.path.splitext(os.path.basename(self.name))[0] - bundle = lxml.etree.Element('Bundle', name=bundlename) - for item in self.Match(metadata, data): - bundle.append(copy.deepcopy(item)) - return bundle - except LookupError: - lerror = sys.exc_info()[1] - logger.error('Genshi lookup error: %s' % lerror) - except genshi.template.TemplateError: - terror = sys.exc_info()[1] - logger.error('Genshi template error: %s' % terror) - raise - except genshi.input.ParseError: - perror = sys.exc_info()[1] - logger.error('Genshi parse error: %s' % perror) - raise - - def Match(self, metadata, xdata): - """Return matching fragments of parsed template.""" - rv = [] - for child in xdata.getchildren(): - rv.extend(self._match(child, metadata)) - logger.debug("File %s got %d match(es)" % (self.name, len(rv))) - return rv - -class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet): - - def __init__(self, path, fam, encoding): - fpattern = '\S+\.xml' - Bcfg2.Server.Plugin.EntrySet.__init__(self, fpattern, path, - SGenshiTemplateFile, encoding) - fam.AddMonitor(path, self) - - def HandleEvent(self, event): - '''passthrough event handler for old calling convention''' - if event.filename != self.path: - return self.handle_event(event) - - def BuildStructures(self, metadata): - """Build SGenshi structures.""" - ret = [] - for entry in self.get_matching(metadata): - try: - ret.append(entry.get_xml_value(metadata)) - except: - logger.error("SGenshi: Failed to template file %s" % entry.name) - return ret - - -class SGenshi(SGenshiEntrySet, - Bcfg2.Server.Plugin.Plugin, - Bcfg2.Server.Plugin.Structure): - """The SGenshi plugin provides templated structures.""" - name = 'SGenshi' - __author__ = 'bcfg-dev@mcs.anl.gov' - deprecated = True - - def __init__(self, core, datastore): - Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) - Bcfg2.Server.Plugin.Structure.__init__(self) - try: - SGenshiEntrySet.__init__(self, self.data, self.core.fam, core.encoding) - except: - logger.error("Failed to load %s repository; disabling %s" \ - % (self.name, self.name)) - raise Bcfg2.Server.Plugin.PluginInitError diff --git a/src/lib/Bcfg2/Server/Plugins/Svcmgr.py b/src/lib/Bcfg2/Server/Plugins/Svcmgr.py deleted file mode 100644 index f4232ad5c..000000000 --- a/src/lib/Bcfg2/Server/Plugins/Svcmgr.py +++ /dev/null @@ -1,10 +0,0 @@ -"""This generator provides service mappings.""" - -import Bcfg2.Server.Plugin - - -class Svcmgr(Bcfg2.Server.Plugin.PrioDir): - """This is a generator that handles service assignments.""" - name = 'Svcmgr' - __author__ = 'bcfg-dev@mcs.anl.gov' - deprecated = True diff --git a/src/lib/Bcfg2/Server/Plugins/__init__.py b/src/lib/Bcfg2/Server/Plugins/__init__.py index f9f1b4e52..b33eeba28 100644 --- a/src/lib/Bcfg2/Server/Plugins/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/__init__.py @@ -25,10 +25,8 @@ __all__ = [ 'SSHbase', 'Snapshots', 'Statistics', - 'Svcmgr', 'Svn', 'TCheetah', 'Trigger', - 'SGenshi', 'TGenshi', ] diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index d8dd4a3c8..1af4bd8da 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -30,7 +30,7 @@ import Bcfg2.Server.Plugins.Metadata import Bcfg2.Server.Plugin try: - import Bcfg2.Server.Plugins.SGenshi + from Bcfg2.Server.Plugins.Bundler import BundleTemplateFile has_genshi = True except ImportError: has_genshi = False @@ -420,7 +420,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore): bundle = self.plugins['Bundler'].entries[bname] if (has_genshi and isinstance(bundle, - Bcfg2.Server.Plugins.SGenshi.SGenshiTemplateFile)): + BundleTemplateFile)): stream = bundle.template.generate(metadata=metadata) print(stream.render("xml")) else: diff --git a/tools/manpagegen/bcfg2.conf.5.ronn b/tools/manpagegen/bcfg2.conf.5.ronn index d17bd48cf..544c4ccc7 100644 --- a/tools/manpagegen/bcfg2.conf.5.ronn +++ b/tools/manpagegen/bcfg2.conf.5.ronn @@ -66,7 +66,6 @@ specified in the `[server]` section of the configuration file. `Account`, `Actions`, - `BB`, `Base`, `Bundler`, `Bzr`, @@ -90,7 +89,6 @@ specified in the `[server]` section of the configuration file. `Probes`, `Properties`, `Rules`, - `SGenshi`, `Snapshots`, `SSHbase`, `Svn`, @@ -116,10 +114,6 @@ The account plugin manages authentication data, including the following. * `/etc/sudoers` * `/root/.ssh/authorized_keys` -### BB Plugin - -The BB plugin maps users to machines and metadata to machines. - ### Base Plugin A structure plugin that provides the ability to add lists of unrelated -- cgit v1.2.3-1-g7c22