* 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.
This commit is contained in:
halex
2007-11-04 01:12:25 +00:00
parent 8fbf362ed1
commit 5f3b1681bd
6 changed files with 56 additions and 8 deletions
+3 -2
View File
@@ -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
+7
View File
@@ -0,0 +1,7 @@
{
"0" : { desc: "Installed Bongo.", url: "" },
"1" : { desc: "", url: "" },
"2" : { desc: "", url: "" },
"3" : { desc: "", url: "" },
"4" : { desc: "", url: "" }
}
+2 -1
View File
@@ -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;
+4
View File
@@ -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)
+35
View File
@@ -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
+5 -5
View File
@@ -16,16 +16,16 @@
<div tal:condition="success" style="text-align: center;">
<form method="post">
<input type="hidden" name="command" value="agentstatus" />
<table class="htable" cellspacing="0" style="margin-left: auto; margin-right: auto; width: 100%">
<table class="htable" cellspacing="0" style="margin-left: auto; margin-right: auto; width: 75%%">
<tr class="highlight hrow">
<th style="padding: 10px;">Enabled</th>
<th style="padding: 10px;">Agent Name</th>
<th style="padding: 10px;">Enabled</th>
</tr>
<tr tal:repeat="agent agentlist" tal:attributes="class string:highlight${repeat/agent/odd}">
<td style="height: 24px">
<input type="checkbox" tal:attributes="checked agent/enabled;name agent/name" />
<td><label tal:attributes="for agent/name" tal:content="agent/name">unknown agent</label></td>
<td style="height: 24px; width: 24px">
<input type="checkbox" tal:attributes="checked agent/enabled;name agent/name;id agent/name"/>
</td>
<td tal:content="agent/name">unknown agent</td>
</tr>
</table>
<br />