From 5f3b1681bd90904207ea8aef03d9df87dd5f09da Mon Sep 17 00:00:00 2001 From: halex Date: Sun, 4 Nov 2007 01:12:25 +0000 Subject: [PATCH] * Added new Hawkeye collection in store via bongo-config and a 'history' document. * Modified tar command to support multiple directories - it's a bit hacky though, so FIXME if you get a chance. * Unbreak enable/disable agents template. * Added EventHistory function. --- src/apps/config/Bongo.rules | 5 ++-- src/apps/config/hawkeye/history | 7 +++++ src/apps/config/store.c | 3 ++- src/www/bongo/hawkeye/AgentView.py | 4 +++ src/www/bongo/hawkeye/HawkeyeHandler.py | 35 +++++++++++++++++++++++++ src/www/hawkeye/server/index.tpl | 10 +++---- 6 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/apps/config/hawkeye/history diff --git a/src/apps/config/Bongo.rules b/src/apps/config/Bongo.rules index 57481fb..4671d30 100644 --- a/src/apps/config/Bongo.rules +++ b/src/apps/config/Bongo.rules @@ -10,7 +10,8 @@ conf_defaults = \ src/apps/config/config/manager \ src/apps/config/config/pop3 \ src/apps/config/config/queue \ - src/apps/config/config/smtp + src/apps/config/config/smtp \ + src/apps/config/hawkeye/history bongo_config_SOURCES = \ $(conf_defaults) \ @@ -38,7 +39,7 @@ conf_DATA = \ src/apps/config/default.set src/apps/config/default.set: $(conf_defaults) - @(cd $(top_srcdir)/src/apps/config && tardir=config && $(am__tar)) > $@ + (cd $(top_srcdir)/src/apps/config && tar chof - config hawkeye) > $@ src/apps/config/all: bongo-config src/apps/config/clean: clean diff --git a/src/apps/config/hawkeye/history b/src/apps/config/hawkeye/history new file mode 100644 index 0000000..bb1f131 --- /dev/null +++ b/src/apps/config/hawkeye/history @@ -0,0 +1,7 @@ +{ + "0" : { desc: "Installed Bongo.", url: "" }, + "1" : { desc: "", url: "" }, + "2" : { desc: "", url: "" }, + "3" : { desc: "", url: "" }, + "4" : { desc: "", url: "" } +} diff --git a/src/apps/config/store.c b/src/apps/config/store.c index db379a2..156d5b0 100644 --- a/src/apps/config/store.c +++ b/src/apps/config/store.c @@ -68,7 +68,8 @@ ImportSystemBackupFile(StoreClient *client, const char *path) continue; } - if (blocksize > 0 && !strncmp(filename, "config/", 7)) { + /* now, do everything else that isn't a directory and contains data */ + if (blocksize > 0 && filename[len-1] != '/') { char fullpath[110]; char *delim; diff --git a/src/www/bongo/hawkeye/AgentView.py b/src/www/bongo/hawkeye/AgentView.py index 40cd99c..ec7acb9 100644 --- a/src/www/bongo/hawkeye/AgentView.py +++ b/src/www/bongo/hawkeye/AgentView.py @@ -242,6 +242,10 @@ class AgentHandler(HawkeyeHandler): if doneop: self.SetVariable("opsuccess", 1) doneop = 0 + + # Setup action history + store = self.EventHistory(req, "Modified agent " + agentdefs[agentname]["label"], "agents/" + agentname) + else: self.SetVariable("opsuccess", 0) diff --git a/src/www/bongo/hawkeye/HawkeyeHandler.py b/src/www/bongo/hawkeye/HawkeyeHandler.py index 92548a3..ba41807 100644 --- a/src/www/bongo/hawkeye/HawkeyeHandler.py +++ b/src/www/bongo/hawkeye/HawkeyeHandler.py @@ -54,6 +54,41 @@ class HawkeyeHandler: store.Quit() return False + def EventHistory(self, req, desc, path): + config = {} + store = None + decoder = simplejson.JSONDecoder() + try: + store = StoreClient(req.session["credUser"], req.session["credUser"], authPassword=req.session["credPass"]) + store.Store("_system") + + # Fetch old data (if any) + datafile = store.Read("/hawkeye/history") + data = decoder.decode(datafile) + + # Now, move everything down one. + data["4"] = data["3"] + data["3"] = data["2"] + data["2"] = data["1"] + data["1"] = data["0"] + + # Put in new data in first slot + data["0"] = { 'desc' : desc, 'url' : path } + + # Save new data + datafile = encoder.encode(data) + store.Replace("/hawkeye/history", datafile) + + # Finish up + if store: + store.Quit() + return True + except Exception, e: + self.SetVariable("error", "Unable to set history: %s" % str(e)) + if store: + store.Quit() + return False + def NeedsAuth(self, rp): return True diff --git a/src/www/hawkeye/server/index.tpl b/src/www/hawkeye/server/index.tpl index 48816b9..9f0cae9 100644 --- a/src/www/hawkeye/server/index.tpl +++ b/src/www/hawkeye/server/index.tpl @@ -16,16 +16,16 @@
- +
- + - + -
Enabled Agent NameEnabled
- + + unknown agent