summaryrefslogtreecommitdiffstats
path: root/scripts/watcher.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-03-19 18:56:59 -0400
committerJim Meyering <jim@meyering.net>2007-03-19 18:56:59 -0400
commit6d6082d62d7e5fdc4014455a09316de9e36b6786 (patch)
treeaa484d1d2ed01f9fbcb39b372e9f26f7e35e67ba /scripts/watcher.py
parent3797448bd957a39f43432d3399a5e2482cec533a (diff)
downloadthird_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.tar.gz
third_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.tar.xz
third_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.zip
Most of these diffs come from directory reorg/cleanup, though the main feature here is the start of a better --import command that creates significantly shorter paths and can work more reliably on mounted DVD images (losetup or otherwise). Detection of kickstarts based on paths needs to be augmented by additional means for this to really work. However, changes going in here (and still more to come) result in cleaner names for imported profiles, and substantially shorter kernel option command lines, which is needed to keep under the 255 limit. There is also some work here going in to template out all of the files for PXE, reducing the amount of code in action_sync and also making PXE setups much more customizable (menu choices, titles, random parameters, ipappend 2, etc) without patching the source. "tree" on import is also attached now to the distro, not the profile. So, whew, that's a lot.
Diffstat (limited to 'scripts/watcher.py')
-rwxr-xr-xscripts/watcher.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/watcher.py b/scripts/watcher.py
new file mode 100755
index 0000000..1074458
--- /dev/null
+++ b/scripts/watcher.py
@@ -0,0 +1,63 @@
+# cobbler mod_python handler for observing kickstart activity
+#
+# Copyright 2007, Red Hat, Inc
+# Michael DeHaan <mdehaan@redhat.com>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import time
+from mod_python import apache
+
+def outputfilter(filter):
+
+
+ # extract important info
+ request = filter.req
+ connection = request.connection
+ (address,port) = connection.remote_addr
+
+ # open the logfile (directory be set writeable by installer)
+ logfile = open("/var/log/cobbler/kicklog/%s" % address,"a+")
+
+ log_it = True
+ if request.the_request.find("cobbler_track") == -1 and request.the_request.find("ctr/") == -1":
+ log_it = False
+
+ if log_it:
+ # write the timestamp
+ t = time.localtime()
+ seconds = str(time.mktime(t))
+ logfile.write(seconds)
+ logfile.write("\t")
+ timestr = str(time.asctime(t))
+ logfile.write(timestr)
+ logfile.write("\t")
+
+ # write the IP address of the client
+ logfile.write(address)
+ logfile.write("\t")
+
+ # write the filename being requested
+ logfile.write(request.the_request)
+ # logfile.write(request.filename)
+ logfile.write("\n")
+
+ # if requesting this file, don't return it
+ if request.the_request.find("watcher.py") != -1:
+ filter.close()
+ return
+
+ # pass-through filter
+ s = filter.read()
+ while s:
+ filter.write(s)
+ s = filter.read()
+ if s is None:
+ filter.close()
+ logfile.close()
+