diff options
author | Daniel Joseph Barnhart Clark <dclark@pobox.com> | 2009-09-24 06:24:53 +0000 |
---|---|---|
committer | Daniel Joseph Barnhart Clark <dclark@pobox.com> | 2009-09-24 06:24:53 +0000 |
commit | d5182b5ca4c018087475121b540495967c32e3e0 (patch) | |
tree | 35c1cf368740ef975b341496f6e17a6222117009 /src/lib | |
parent | 7eb951a59f1d32225e245dc61d6195e977d85624 (diff) | |
download | bcfg2-d5182b5ca4c018087475121b540495967c32e3e0.tar.gz bcfg2-d5182b5ca4c018087475121b540495967c32e3e0.tar.bz2 bcfg2-d5182b5ca4c018087475121b540495967c32e3e0.zip |
Support for [http://fossil-scm.org Fossil] SCM Distributed Version Control System (DVCS)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5457 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Server/Plugins/Fossil.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Fossil.py b/src/lib/Server/Plugins/Fossil.py new file mode 100644 index 000000000..e50a8caff --- /dev/null +++ b/src/lib/Server/Plugins/Fossil.py @@ -0,0 +1,50 @@ +import os +from subprocess import Popen, PIPE +import Bcfg2.Server.Plugin + +# for debugging output only +import logging +logger = logging.getLogger('Bcfg2.Plugins.Fossil') + +class Fossil(Bcfg2.Server.Plugin.Plugin, + Bcfg2.Server.Plugin.Version): + name = 'Fossil' + __version__ = '$Id$' + __author__ = 'bcfg-dev@mcs.anl.gov' + + def __init__(self, core, datastore): + Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) + self.core = core + self.datastore = datastore + + # path to fossil file for bcfg2 repo + fossil_file = "%s/_FOSSIL_" % datastore + + # Read revision from bcfg2 repo + if os.path.isfile(fossil_file): + self.get_revision() + elif not os.path.isdir(datastore): + logger.error("%s is not a directory" % datastore) + raise Bcfg2.Server.Plugin.PluginInitError + else: + logger.error("%s is not a file" % fossil_file) + raise Bcfg2.Server.Plugin.PluginInitError + + logger.debug("Initialized fossil plugin with fossil file = %s" % fossil_file) + + def get_revision(self): + '''Read fossil revision information for the bcfg2 repository''' + try: + data = Popen("env LC_ALL=C fossil info", + shell=True, + cwd=self.datastore, + stdout=PIPE).stdout.readlines() + revline = [line.split(': ')[1].strip() for line in data if \ + line.split(': ')[0].strip() == 'checkout'][-1] + revision = revline.split(' ')[0] + except IndexError: + logger.error("Failed to read fossil info; disabling fossil support") + logger.error('''Ran command "fossil info" from directory "%s"''' % (self.datastore)) + logger.error("Got output: %s" % data) + raise Bcfg2.Server.Plugin.PluginInitError + return revision |