diff options
author | Jack Neely <jjneely@ncsu.edu> | 2011-03-03 15:41:10 -0500 |
---|---|---|
committer | Jack Neely <jjneely@ncsu.edu> | 2011-03-03 15:41:10 -0500 |
commit | 821a6d5c9244af924146c2e7d4caa0939885a84f (patch) | |
tree | 14d5d99bc7a60492361bbf600604865e52d361a1 | |
parent | 81fce09fb9671c652703c37a5f9b48d020a34307 (diff) | |
parent | 73a4e8648c501437b3b1f4bd95e9c4023da9b681 (diff) | |
download | bcfg2-821a6d5c9244af924146c2e7d4caa0939885a84f.tar.gz bcfg2-821a6d5c9244af924146c2e7d4caa0939885a84f.tar.bz2 bcfg2-821a6d5c9244af924146c2e7d4caa0939885a84f.zip |
Merge branch 'master' into yumng
25 files changed, 119 insertions, 82 deletions
diff --git a/doc/appendix/guides/fedora.txt b/doc/appendix/guides/fedora.txt index f32eaa8c6..4e3244eaa 100644 --- a/doc/appendix/guides/fedora.txt +++ b/doc/appendix/guides/fedora.txt @@ -252,9 +252,8 @@ Add a probe The next step for the client will be to have the proper arch group membership. For this, we will make use of the -:ref:`server-plugins-grouping-dynamic_groups` capabilities of -the Probes plugin. Add **Probes** to your plugins line in ``bcfg2.conf`` -and create the Probe: +:ref:`unsorted-dynamic_groups` capabilities of the Probes plugin. Add +**Probes** to your plugins line in ``bcfg2.conf`` and create the Probe: .. code-block:: sh diff --git a/doc/appendix/guides/ubuntu.txt b/doc/appendix/guides/ubuntu.txt index e22707f2c..24338c6d2 100644 --- a/doc/appendix/guides/ubuntu.txt +++ b/doc/appendix/guides/ubuntu.txt @@ -201,7 +201,7 @@ should look something like this The last thing we need is for the client to have the proper arch group membership. For this, we will make use of the -:ref:`server-plugins-grouping-dynamic_groups` capabilities of the Probes plugin. Add +:ref:`unsorted-dynamic_groups` capabilities of the Probes plugin. Add Probes to your plugins line in ``bcfg2.conf`` and create the Probe. .. code-block:: sh @@ -484,7 +484,7 @@ Now we run the client and see there are no more unmanaged entries! :: Dynamic (web) reports ===================== -See installation instructions at :ref:`server-reports-install` +See installation instructions at :ref:`appendix-guides-web-reports-install` Upstart ======= diff --git a/doc/client/tools.txt b/doc/client/tools.txt index 676feb175..d9a9b76f4 100644 --- a/doc/client/tools.txt +++ b/doc/client/tools.txt @@ -14,7 +14,7 @@ management. The POSIX tool also handles file system and permissions/groups operations. To write your own tool driver, to handle a new packaging format, or new -service architecture see :ref:`development-index-writingtooldrivers` +service architecture see :ref:`development-client-driver` When the Bcfg2 client is run, it attempts to instantiate each of these drivers. The succeeding list of drivers are printed as a debug message diff --git a/doc/getting_started/index.txt b/doc/getting_started/index.txt index 9661fcb89..b256edd2d 100644 --- a/doc/getting_started/index.txt +++ b/doc/getting_started/index.txt @@ -234,7 +234,7 @@ Next Steps Several other utilities can help from this point on: -:ref:`bcfg2-info <appendix-guides-using_bcfg2_info>` is a utility that +:ref:`bcfg2-info <server-bcfg2-info>` is a utility that instantiates a copy of the bcfg2 server core (minus the networking code) for examination. From this, you can directly query: diff --git a/doc/help/faq/general.txt b/doc/help/faq/general.txt index 0534e72d2..f8ecc9854 100644 --- a/doc/help/faq/general.txt +++ b/doc/help/faq/general.txt @@ -17,7 +17,7 @@ cubic feet of gas. Bcfg2 should run on any POSIX compatible operating system, however direct support for an operating system's package and service formats are limited -by the currently available :ref:`client-tools-index` (although new client +by the currently available :ref:`client-tools` (although new client tools are pretty easy to add). The following is an incomplete but more exact list of platforms on which Bcfg2 works. diff --git a/doc/server/configurationentries.txt b/doc/server/configurationentries.txt index 8741e56f5..6e6ab79f7 100644 --- a/doc/server/configurationentries.txt +++ b/doc/server/configurationentries.txt @@ -87,7 +87,7 @@ necessary for the Path type specified. | | | applies to only | | | | | YUMng) | | +-------------+----------------------+-----------------+--------------------------+ -| nonexistent | New | Specify a path | name | +| nonexistent | New | Specify a path | name, recursive | | | | that should not | | | | | exist | | +-------------+----------------------+-----------------+--------------------------+ diff --git a/doc/server/info.txt b/doc/server/info.txt index 0adf8ce51..231a83a52 100644 --- a/doc/server/info.txt +++ b/doc/server/info.txt @@ -79,10 +79,11 @@ specification. info.xml files ============== -``info.xml`` files add the ability to specify different sets of file -metadata on a group by group basis. These files are XML, and work -similarly to those used by :ref:`Rules <server-plugins-generators-rules>` -or :ref:`Pkgmgr <server-plugins-generators-pkgmgr>`. +``info.xml`` files add the ability to specify different +sets of file metadata on a group by group or host by host +basis. These files are XML, and work similarly to those used by +:ref:`Rules <server-plugins-generators-rules>` or :ref:`Pkgmgr +<server-plugins-generators-pkgmgr>`. The following specifies a different global set of permissions (root/sys/0651) than on clients in group webserver (root/root/0652) @@ -90,6 +91,9 @@ The following specifies a different global set of permissions .. code-block:: xml <FileInfo> + <Client name='foo.example.com'> + <Info owner='root' group='root' perms='0652'/> + </Client> <Group name='webserver'> <Info owner='root' group='root' perms='0652'/> </Group> diff --git a/doc/server/plugins/generators/nagiosgen.txt b/doc/server/plugins/generators/nagiosgen.txt index 8cd18ca4f..196f1e76b 100644 --- a/doc/server/plugins/generators/nagiosgen.txt +++ b/doc/server/plugins/generators/nagiosgen.txt @@ -8,7 +8,7 @@ NagiosGen This page describes the installation and use of the `NagiosGen`_ plugin. -.. _NagiosGen: http://trac.mcs.anl.gov/projects/bcfg2/browser/trunk/bcfg2/src/lib/Server/Plugins/NagiosGen.py +.. _NagiosGen: http://trac.mcs.anl.gov/projects/bcfg2/browser/src/lib/Server/Plugins/NagiosGen.py Update ``/etc/bcfg2.conf``, adding NagiosGen to plugins:: diff --git a/doc/server/plugins/generators/rules.txt b/doc/server/plugins/generators/rules.txt index fe60a24fd..cff78a8ee 100644 --- a/doc/server/plugins/generators/rules.txt +++ b/doc/server/plugins/generators/rules.txt @@ -119,7 +119,7 @@ Service Tag +------------+--------------------------+---------------------------------------+ | Name | Description | Values | +============+==========================+=======================================+ -| mode | Per Service Mode (New in | (manual|default|supervised|custom) | +| mode | Per Service Mode (New in | (manual|default|supervised) | | | 1.0) | | +------------+--------------------------+---------------------------------------+ | name | Service Name | String | @@ -129,10 +129,8 @@ Service Tag | | off). | | +------------+--------------------------+---------------------------------------+ | target | Service command for | String | -| | restart, modified | | -| | targets require | | -| | mode="custom" | | -| | (default: restart) | | +| | restart (default: | | +| | restart) | | +------------+--------------------------+---------------------------------------+ | type | Driver to use on the | (chkconfig|deb|rc-update|smf|upstart) | | | client to manage this | | @@ -165,11 +163,6 @@ Service mode descriptions * default and ensure service is running (or stopped) when verification is performed * deprecates supervised='true' -* custom - - * set non-default service command for restart (use in conjunction with - target attribute) - Client Tag ---------- @@ -251,14 +244,17 @@ hardlink nonexistent ^^^^^^^^^^^ -+------+--------------------+-------------+ -| Name | Description | Values | -+======+====================+=============+ -| name | Name of the | String | -| | (nonexistent) file | | -+------+--------------------+-------------+ -| type | Type of file | nonexistent | -+------+--------------------+-------------+ ++-----------+--------------------+-------------+ +| Name | Description | Values | ++===========+====================+=============+ +| name | Name of the | String | +| | (nonexistent) file | | ++-----------+--------------------+-------------+ +| type | Type of file | nonexistent | ++-----------+--------------------+-------------+ +| recursive | Recursively remove | true | +| | directory contents | | ++-----------+--------------------+-------------+ permissions ^^^^^^^^^^^ diff --git a/doc/server/plugins/grouping/metadata.txt b/doc/server/plugins/grouping/metadata.txt index f215e6cc5..1c915e2cf 100644 --- a/doc/server/plugins/grouping/metadata.txt +++ b/doc/server/plugins/grouping/metadata.txt @@ -105,7 +105,8 @@ Additionally, the following properties can be specified: | | resolution. | | +----------+----------------------------------------+----------------+ -For detailed information on client authentication see :ref:`authentication` +For detailed information on client authentication see +:ref:`appendix-guides-authentication` Metadata/groups.xml =================== diff --git a/doc/server/plugins/probes/current-kernel.txt b/doc/server/plugins/probes/current-kernel.txt index f057f189b..748b56ecc 100644 --- a/doc/server/plugins/probes/current-kernel.txt +++ b/doc/server/plugins/probes/current-kernel.txt @@ -9,7 +9,5 @@ Probe the currently running kernel. .. code-block:: sh - #!/bin/sh - # # PROBE_NAME : current-kernel echo `uname -r` diff --git a/doc/server/plugins/statistics/dbstats.txt b/doc/server/plugins/statistics/dbstats.txt index dd25fe9ab..7f59b1ce7 100644 --- a/doc/server/plugins/statistics/dbstats.txt +++ b/doc/server/plugins/statistics/dbstats.txt @@ -12,4 +12,4 @@ DBStats can be enabled by adding DBStats to the plugins line in plugins = Base,Bundler,Cfg,...,DBStats For more information on how to use DBStats to setup reporting, see -:ref:`server-reports-dynamic`. +:ref:`reports-dynamic`. diff --git a/doc/server/plugins/structures/bundler/index.txt b/doc/server/plugins/structures/bundler/index.txt index e5682ac00..0d0054a2c 100644 --- a/doc/server/plugins/structures/bundler/index.txt +++ b/doc/server/plugins/structures/bundler/index.txt @@ -105,13 +105,16 @@ how group entries can be used in bundles) Genshi templates ================ -Genshi templates are used by adding a Genshi xml-style template to the -Bundler directory with a ``.genshi`` file extension. Version 0.4 or newer -of genshi is required. +Genshi xml templates can be specified one of two ways: -.. important:: The ``.genshi`` file extension is required in order for the - server to know that the Bundle should be rendered using - Genshi. +1. Add an xml-style genshi template to the Bundler directory with a + ``.genshi`` and the associated namespace attribute. +2. Simply add the appropriate namespace attribute to your existing xml + bundle. + +The namespace attribute in this case should look like the following:: + + xmlns:py="http://genshi.edgewall.org/" Motivation ---------- diff --git a/doc/server/snapshots/index.txt b/doc/server/snapshots/index.txt index ca8af2663..13a9fe2c0 100644 --- a/doc/server/snapshots/index.txt +++ b/doc/server/snapshots/index.txt @@ -9,8 +9,8 @@ Bcfg2 Snapshots .. versionadded:: 1.0.0 This page describes the Snapshots plugin. This plugin is meant to replace -the older :ref:`server-reports-dynamic`. It stores various -aspects of a client's state when the client checks into the server. +the older :ref:`reports-dynamic`. It stores various aspects of a client's +state when the client checks into the server. Before you begin ================ diff --git a/doc/unsorted/howtos.txt b/doc/unsorted/howtos.txt index 31e41ab75..4347632f6 100644 --- a/doc/unsorted/howtos.txt +++ b/doc/unsorted/howtos.txt @@ -8,10 +8,10 @@ HOWTOs Here are several howtos that describe different aspects of Bcfg2 deployment -* :ref:`authentication` - a description of the Bcfg2 authentication infrastructure +* :ref:`appendix-guides-authentication` - a description of the Bcfg2 authentication infrastructure * AnnotatedExamples - a description of basic Bcfg2 specification operations * BuildingDebianPackages - How to build debian packages -* :ref:`unsorted-gentoo` - Issues specific to running Bcfg2 on Gentoo +* :ref:`appendix-guides-gentoo` - Issues specific to running Bcfg2 on Gentoo * :ref:`server-plugins-generators-tcheetah` - Howto use the TCheetah template plugin * :ref:`server-plugins-generators-hostbase` - How to use the Hostbase plugin and web interface * :ref:`server-plugins-probes-index` - How to use Probes to gather information from a client machine. diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py index 156186091..fe1ef6fdd 100644 --- a/src/lib/Client/Tools/APT.py +++ b/src/lib/Client/Tools/APT.py @@ -119,7 +119,7 @@ class APT(Bcfg2.Client.Tools.Tool): if bad: self.logger.debug("It is suggested that you either manage these " "files, revert the changes, or ignore false " - "failures):") + "failures:") self.logger.info("Package %s failed validation. Bad files are:" % \ entry.get('name')) self.logger.info(bad) diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py index d2611130c..c883fc17a 100644 --- a/src/lib/Client/Tools/POSIX.py +++ b/src/lib/Client/Tools/POSIX.py @@ -671,12 +671,36 @@ class POSIX(Bcfg2.Client.Tools.Tool): def Installnonexistent(self, entry): '''Remove nonexistent entries''' - try: - os.remove(entry.get('name')) - return True - except OSError: - self.logger.error('Failed to remove %s' % entry.get('name')) - return False + ename = entry.get('name') + if entry.get('recursive') in ['True', 'true']: + # ensure that configuration spec is consistent first + if [e for e in self.buildModlist() \ + if e.startswith(ename) and e != ename]: + self.logger.error('Not installing %s. One or more files ' + 'in this directory are specified in ' + 'your configuration.' % ename) + return False + try: + shutil.rmtree(ename) + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + else: + if os.path.isdir(ename): + try: + os.rmdir(ename) + return True + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + return False + try: + os.remove(ename) + return True + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + return False def Verifypermissions(self, entry, _): """Verify Path type='permissions' entry""" diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py index f0bc6bd05..96c7d9d28 100644 --- a/src/lib/Client/Tools/SMF.py +++ b/src/lib/Client/Tools/SMF.py @@ -66,6 +66,7 @@ class SMF(Bcfg2.Client.Tools.SvcTool): # Occurs when no lines are returned (service not installed) return False + entry.set('current_status', srvdata[0]) if entry.get('status') == 'on': return srvdata[0] == 'ON' else: diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py index 3b5a62d97..8db1683e4 100644 --- a/src/lib/Client/Tools/YUMng.py +++ b/src/lib/Client/Tools/YUMng.py @@ -358,7 +358,12 @@ class YUMng(Bcfg2.Client.Tools.PkgTool): for po in packages: d = {} for i in ['name', 'epoch', 'version', 'release', 'arch']: - d[i] = getattr(po, i) + if i == 'arch' and getattr(po, i) is None: + d[i] = 'noarch' + elif i == 'epoch' and getattr(po, i) is None: + d[i] = '0' + else: + d[i] = getattr(po, i) self.installed.setdefault(po.name, []).append(d) def VerifyPackage(self, entry, modlist, pinned_version=None): @@ -530,7 +535,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool): package_fail = True self.logger.debug("It is suggested that you either manage " "these files, revert the changes, or ignore " - "false failures):") + "false failures:") self.logger.debug(" Verify Problems:") for fn, probs in stat['verify'].items(): self.logger.debug(" %s" % fn) diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index 8a90e130c..b5120db71 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -335,9 +335,7 @@ class SvcTool(Tool): def restart_service(self, service): self.logger.debug('Restarting service %s' % service.get('name')) - restart_target = 'restart' - if service.get('mode', 'default') == 'custom': - restart_target = service.get('target', 'restart') + restart_target = service.get('target', 'restart') return self.cmd.run(self.get_svc_command(service, restart_target))[0] def check_service(self, service): @@ -353,7 +351,7 @@ class SvcTool(Tool): if entry.get('mode', 'default') == 'manual': continue # need to handle servicemode = (build|default) - # need to handle mode = (default|supervised|custom) + # need to handle mode = (default|supervised) if entry.get('status') == 'on': if self.setup['servicemode'] == 'build': rc = self.stop_service(entry) diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py index 47cd7e2c4..3f88fe26b 100644 --- a/src/lib/Server/Plugins/Bundler.py +++ b/src/lib/Server/Plugins/Bundler.py @@ -15,17 +15,22 @@ try: except: have_genshi = False + class BundleFile(Bcfg2.Server.Plugin.StructFile): + def get_xml_value(self, metadata): bundlename = self.name.split('/')[-1][:-4] bundle = lxml.etree.Element('Bundle', name=bundlename) [bundle.append(copy.deepcopy(item)) for item in self.Match(metadata)] return bundle + class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure, Bcfg2.Server.Plugin.XMLDirectoryBacked): - """The bundler creates dependent clauses based on the bundle/translation scheme from Bcfg1.""" + """The bundler creates dependent clauses based on the + bundle/translation scheme from Bcfg1. + """ name = 'Bundler' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -37,14 +42,26 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, self.encoding = core.encoding self.__child__ = self.template_dispatch try: - Bcfg2.Server.Plugin.XMLDirectoryBacked.__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 def template_dispatch(self, name): + bundle = lxml.etree.parse(name) + nsmap = bundle.getroot().nsmap if name.endswith('.xml'): - return BundleFile(name) + if have_genshi and \ + (nsmap == {'py': 'http://genshi.edgewall.org/'}): + # allow for genshi bundles with .xml extensions + spec = Bcfg2.Server.Plugin.Specificity() + return Bcfg2.Server.Plugins.SGenshi.SGenshiTemplateFile(name, + spec, + self.encoding) + else: + return BundleFile(name) elif name.endswith('.genshi'): if have_genshi: spec = Bcfg2.Server.Plugin.Specificity() diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index e22102ffa..f851b7914 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -174,23 +174,15 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet): metadata_updates.update(self.metadata) for attr in badattr: metadata_updates[attr] = new_entry.get(attr) - if self.infoxml: - infoxml = lxml.etree.Element('FileInfo') - infotag = lxml.etree.SubElement(infoxml, 'Info') - [infotag.attrib.__setitem__(attr, metadata_updates[attr]) \ - for attr in metadata_updates] - ofile = open(self.path + "/info.xml","w") - ofile.write(lxml.etree.tostring(infoxml, pretty_print=True)) - ofile.close() - if log: - logger.info("Wrote file %s" % (self.path + "/info.xml")) - else: - infofile = open(self.path + '/:info', 'w') - for x in metadata_updates.iteritems(): - infofile.write("%s: %s\n" % x) - infofile.close() - if log: - logger.info("Wrote file %s" % infofile.name) + infoxml = lxml.etree.Element('FileInfo') + infotag = lxml.etree.SubElement(infoxml, 'Info') + [infotag.attrib.__setitem__(attr, metadata_updates[attr]) \ + for attr in metadata_updates] + ofile = open(self.path + "/info.xml","w") + ofile.write(lxml.etree.tostring(infoxml, pretty_print=True)) + ofile.close() + if log: + logger.info("Wrote file %s" % (self.path + "/info.xml")) class Cfg(Bcfg2.Server.Plugin.GroupSpool, Bcfg2.Server.Plugin.PullTarget): diff --git a/src/lib/Server/Reports/settings.py b/src/lib/Server/Reports/settings.py index 9efe38552..66da7a8b1 100644 --- a/src/lib/Server/Reports/settings.py +++ b/src/lib/Server/Reports/settings.py @@ -81,7 +81,6 @@ SECRET_KEY = 'eb5+y%oy-qx*2+62vv=gtnnxg1yig_odu0se5$h0hh#pc*lmo7' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', - 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate index 3d5efb093..554e4f72b 100755 --- a/src/sbin/bcfg2-repo-validate +++ b/src/sbin/bcfg2-repo-validate @@ -94,7 +94,7 @@ if __name__ == '__main__': 'hardlink': ['name', 'to'], 'symlink': ['name', 'to'], 'ignore': ['name'], - 'nonexist': ['name'], + 'nonexistent': ['name'], 'permissions': ['name', 'owner', 'group', 'perms']} for rfile in rules_list: try: diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports index f3e60d89e..d83e45e7c 100755 --- a/src/sbin/bcfg2-reports +++ b/src/sbin/bcfg2-reports @@ -138,7 +138,7 @@ if expire != "": c_inst.save() elif '-h' in args: - print """Usage: python bcfg2-reports [option] ... + print """Usage: bcfg2-reports [option] ... Options and arguments (and corresponding environment variables): -a : shows all hosts, including expired hosts |