diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2009-03-11 18:08:37 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2009-03-11 18:09:38 -0400 |
commit | 5e94a41b283f6491fc5ca60f5262e29cab557147 (patch) | |
tree | 37a883cbe129f36cf242944d26cd375030316851 | |
parent | 765756bbf64afba2be4070f9b2e1e602046df1fd (diff) | |
download | cobbler-5e94a41b283f6491fc5ca60f5262e29cab557147.tar.gz cobbler-5e94a41b283f6491fc5ca60f5262e29cab557147.tar.xz cobbler-5e94a41b283f6491fc5ca60f5262e29cab557147.zip |
Updates to SCM tracker.
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | cobbler/modules/scm_track.py | 62 | ||||
-rw-r--r-- | cobbler/settings.py | 2 | ||||
-rw-r--r-- | installer_templates/settings.template | 9 | ||||
-rw-r--r-- | setup.py | 3 |
5 files changed, 77 insertions, 0 deletions
@@ -22,6 +22,7 @@ Cobbler CHANGELOG - (FEAT) web UI search feature - (FEAT) very simple "cobbler hardlink" command to optimize space in /var/www/cobbler - (FEAT) new "change" trigger that runs on all adds/edits/removes/syncs +- (FEAT) an SCM trigger that knows about /var/lib/cobbler kickstarts, snippets, and config directories, and audits them for changes - Tue Mar 3 2009 - 1.4.3 - (BUGF) fix OMAPI support's (note: deprecated) usage of subprocess diff --git a/cobbler/modules/scm_track.py b/cobbler/modules/scm_track.py new file mode 100644 index 00000000..dd9ef687 --- /dev/null +++ b/cobbler/modules/scm_track.py @@ -0,0 +1,62 @@ +import distutils.sysconfig +import sys +import os +import traceback +from cobbler.cexceptions import * +import os +import sub_process +import sys +#import xmlrpclib +import cobbler.module_loader as module_loader + +plib = distutils.sysconfig.get_python_lib() +mod_path="%s/cobbler" % plib +sys.path.insert(0, mod_path) + +def register(): + # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster. + # the return of this method indicates the trigger type + return "/var/lib/cobbler/triggers/change/*" + +def scall(args): + op = sub_process.Popen(args, shell=False, stdout=sub_process.PIPE, stderr=sub_process.PIPE) + op.communicate() + + +def run(api,args): + + + settings = api.settings() + + scm_track_enabled = str(settings.scm_track_enabled).lower() + mode = str(settings.scm_track_mode).lower() + + if scm_track_enabled not in [ "y", "yes", "1", "true" ]: + # feature disabled + return 0 + + if mode == "git": + + old_dir = os.getcwd() + os.chdir("/var/lib/cobbler") + if os.getcwd() != "/var/lib/cobbler": + raise "danger will robinson" + + if not os.path.exists("/var/lib/cobbler/.git"): + scall(["git","init"]) + + # FIXME: if we know the remote user of an XMLRPC call + # use them as the author + + scall(["git","add","config"]) + scall(["git","add","kickstarts"]) + scall(["git","add","snippets"]) + + scall(["git","commit","-m",'API update',"--author","'cobbler <root@localhost.localdomain>'"]) + + os.chdir(old_dir) + + return 0 + + else: + raise CX("currently unsupported SCM type: %s" % mode) diff --git a/cobbler/settings.py b/cobbler/settings.py index 2f2fddb3..ce49d9c8 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -101,6 +101,8 @@ DEFAULTS = { "restart_dhcp" : 1, "restart_xinetd" : 1, "run_install_triggers" : 1, + "scm_track_enabled" : 0, + "scm_track_mode" : "git", "server" : "127.0.0.1", "snippetsdir" : "/var/lib/cobbler/snippets", "tftpd_bin" : "/usr/sbin/in.tftpd", diff --git a/installer_templates/settings.template b/installer_templates/settings.template index d97f32c8..51457a64 100644 --- a/installer_templates/settings.template +++ b/installer_templates/settings.template @@ -311,6 +311,15 @@ register_new_installs: 0 # uses a logging trigger to audit install progress. run_install_triggers: 1 +# enables a trigger which version controls all changes to /var/lib/cobbler +# when add, edit, or sync events are performed. This can be used +# to revert to previous database versions, generate RSS feeds, or for +# other auditing or backup purposes. git is the recommend SCM +# for use with this feature. + +scm_track_enabled: 0 +scm_track_mode: "git" + # this is the address of the cobbler server -- as it is used # by systems during the install process, it must be the address # or hostname of the system as those systems can see the server. @@ -164,6 +164,9 @@ if __name__ == "__main__": # for --version support across distros (libpath, ['config/version']), + + # for version control tracking feature + (libpath, ['config/gitignore']), # bootloaders and syslinux support files (libpath, ['loaders/elilo-3.8-ia64.efi']), |