cas cas-admin cas.spec
by Adam Stokes
cas | 2 +-
cas-admin | 30 +++++++++++++++++++++++++++++-
cas.spec | 5 ++++-
3 files changed, 34 insertions(+), 3 deletions(-)
New commits:
commit 4825433f55947aac57b593f1d1e9a3d4545ded3a
Author: adam stokes <ajs(a)redhat.com>
Date: Tue May 5 13:31:08 2009 -0400
support for purge data
diff --git a/cas b/cas
index d5a755a..989d6c3 100755
--- a/cas
+++ b/cas
@@ -160,7 +160,7 @@ class CasApplication(object):
# we want to allow for multiple cores under same identifier
# so we base the hierarchy /workDirectory/identifier/datetime
datenow = datetime.now()
- dateFormatted = datenow.strftime("%m.%d.%y.%I.%M.%S")
+ dateFormatted = datenow.strftime("%Y.%m.%d.%I.%M.%S")
self.storagePath = os.path.join(WORKDIRECTORY, self.identifier)
self.storagePath = os.path.join(self.storagePath, dateFormatted)
diff --git a/cas-admin b/cas-admin
index bc6a694..d4b197b 100755
--- a/cas-admin
+++ b/cas-admin
@@ -19,6 +19,8 @@ import ConfigParser
import optparse
import sys
import urlparse
+import datetime
+import calendar
from cas.core import CoreBase
from cas.util import UtilBase, Logging
@@ -38,6 +40,7 @@ RPMFILTER = config.get("settings","rpmFilter")
DEBUGS = config.get("settings","debugs")
DEBUGLEVEL = config.get("settings","debugLevel")
DATABASE = config.get("settings","database")
+WORKDIRECTORY = config.get("settings","workDirectory")
# read maintenance options
PURGELIMIT = config.get("maintenance","purgeLimit")
@@ -136,6 +139,30 @@ class CasServerHandler(object):
raise SystemExit(self.casLog.debug("Please install func (http://fedorahosted.org/func) for " \
"an automated machine arch population.\n"))
return
+
+class PurgeHandler(object):
+ def __init__(self, purgeDays, logger):
+ self.purgeDataDays = purgeDays
+ self.casLog = logger
+ self.util = UtilBase
+ self.todaysDate = datetime.date.today()
+
+ def run(self):
+ # create date of timedelta
+ cutOffDate = self.todaysDate - self.purgeDataDays
+ # Start of purging data
+ for root, dirs, files in os.walk(WORKDIRECTORY):
+ for d in dirs:
+ dirpath = os.path.join(root,d)
+ # pull out date from directory structure and trim it to
+ # (year, month, day)
+ searchDate = util.regexSearch('(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)', dirpath)
+ if searchDate:
+ (year, month, day) = searchDate.split('.')[:3]
+ # create our datetime object so we can do some arithmetic
+ dirDate = datetime.date(int(year), int(month), int(day))
+ if cutOffDate < dirDate:
+ rmtree(dirpath)
class CasAdminApplication(object):
def __init__(self, args):
@@ -179,8 +206,9 @@ class CasAdminApplication(object):
if not self.purgeDataDays:
self.purgeDataDays = PURGELIMIT
self.casLog.info("Beginning Purge going back %s days" % (self.purgeDataDays,))
+ purgeHandler = PurgeHandler(self.purgeDataDays, self.casLog).run()
else:
- sys.exit(0)
+ raise SystemExit("Purge canceled.")
if self.buildDB:
self.casLog.info("Starting CAS DB instance.")
diff --git a/cas.spec b/cas.spec
index 55aecd6..d6b1423 100644
--- a/cas.spec
+++ b/cas.spec
@@ -3,7 +3,7 @@
Name: cas
Summary: Tool to analyze and configure core file environment
Version: 0.14
-Release: 7%{?dist}
+Release: 8%{?dist}
Source0: https://fedorahosted.org/releases/c/a/cas/%{name}-%{version}.tar.gz
License: GPLv3+
Group: Development/Libraries
@@ -54,6 +54,9 @@ rm -rf ${RPM_BUILD_ROOT}
%doc AUTHORS LICENSE README PKG-INFO doc/*
%changelog
+* Tue May 5 2009 Adam Stokes <ajs at redhat dot com> - 0.14-8
+- support for purging old data
+
* Fri Apr 24 2009 Adam Stokes <ajs at redhat dot com> - 0.14-2
- Finalizing sqlite implementation
- added AUTHORS
15 years, 1 month
cas cas-admin
by Adam Stokes
cas | 2 +-
cas-admin | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 2faf59377aaf09f7f0b54b95ec24191c28a97ac5
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 18:09:40 2009 -0400
- add DEBUGLEVEL to logger instance
diff --git a/cas b/cas
index 9dde862..d5a755a 100755
--- a/cas
+++ b/cas
@@ -166,7 +166,7 @@ class CasApplication(object):
# build logger object to deal with logging per job and keep things
# clean and easy to debug
- self.casLog = Logging(self.storagePath, self.identifier)
+ self.casLog = Logging(self.storagePath, self.identifier, DEBUGLEVEL)
# Add job to database, this allows us to purge
# data based on job date creation then by other
diff --git a/cas-admin b/cas-admin
index e04c125..bc6a694 100755
--- a/cas-admin
+++ b/cas-admin
@@ -140,7 +140,7 @@ class CasServerHandler(object):
class CasAdminApplication(object):
def __init__(self, args):
self.parse_options(args)
- self.casLog = Logging("/var/log","cas-admin")
+ self.casLog = Logging("/var/log","cas-admin", DEBUGLEVEL)
def parse_options(self, args):
parser = optparse.OptionParser(usage="cas-admin [opts] args")
15 years, 1 month
cas cas-admin
by Adam Stokes
cas | 17 ++++++-----------
cas-admin | 10 ++++------
2 files changed, 10 insertions(+), 17 deletions(-)
New commits:
commit 294cdaa0bef11650177a9aa4d8db965415f6e5b7
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 18:02:00 2009 -0400
- re-worked exit on exception
diff --git a/cas b/cas
index ca5e457..9dde862 100755
--- a/cas
+++ b/cas
@@ -76,8 +76,7 @@ class CoreHandler(object):
if not os.path.isfile(self.filename):
# not a url in this case so tests for local existence
# TODO: add support to check remote hosts
- self.casLog.debug("Unable to find file %s" % (self.filename,))
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Unable to find file %s" % (self.filename,)))
if self.tool.isCorefile(self.filename):
# No need to proceed to extracting corefile since we assume
# this is already at the proper stage.
@@ -102,8 +101,7 @@ class CoreHandler(object):
self.filename = os.path.join(self.dst, coreBasename)
return self.filename
except CoreException, err:
- self.casLog.debug(err)
- sys.exit(1)
+ raise SystemExit(self.casLog.debug(err))
class TimestampHandler(object):
def __init__(self, corefile, logger, database):
@@ -119,15 +117,13 @@ class TimestampHandler(object):
try:
coreTimestamp = self.tool.timestamp(self.corefile)
except CoreException, err:
- self.casLog.debug(err)
- sys.exit(1)
+ raise SystemExit(self.casLog.debug(err))
# query timestamp table, return tuple debuginfoRPM, and path to
# debugKernel
timestamp_query = self.db.getTimestampDebug(coreTimestamp)
if timestamp_query:
return (timestamp_query)
- self.casLog.debug("Unable to match timestamp %s" % (coreTimestamp,))
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Unable to match timestamp %s" % (coreTimestamp,)))
class CasApplication(object):
def __init__(self, args):
@@ -296,9 +292,8 @@ class CasApplication(object):
"suitable for processing, please run cas-admin -h " \
"for more information")
else:
- self.casLog.info("No servers database found, please run cas-admin -h for " \
- "more information")
- sys.exit(1)
+ raise SystemExit(self.casLog.info("No servers database found, please run cas-admin -h for " \
+ "more information"))
except ImportError:
self.casLog.info("Current running machine is not suitable for processing this core " \
"and http://fedorahosted.org/func is not installed/configured properly.")
diff --git a/cas-admin b/cas-admin
index 193427e..e04c125 100755
--- a/cas-admin
+++ b/cas-admin
@@ -111,7 +111,7 @@ class CasServerHandler(object):
import func.overlord.client as fc
parent_func = fc.Overlord("*")
minions = parent_func.minions
- # TODO: add only servers that respond, purge the rest
+ # DONE: add only servers that respond, purge the rest
for i in minions:
scheme, netloc, path, query, frag = urlparse.urlsplit(i)
hostname, port = netloc.split(":")
@@ -133,9 +133,8 @@ class CasServerHandler(object):
hostname_count = hostname_count + 1
self.casLog.info("Server database built with %d server(s) added." % (hostname_count,))
except ImportError:
- self.casLog.debug("Please install func (http://fedorahosted.org/func) for " \
- "an automated machine arch population.\n")
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Please install func (http://fedorahosted.org/func) for " \
+ "an automated machine arch population.\n"))
return
class CasAdminApplication(object):
@@ -190,8 +189,7 @@ class CasAdminApplication(object):
self.casLog.info("Building CAS Server DB instance.")
serverHandler = CasServerHandler(self.casLog).run()
else:
- self.casLog.info("Missing options, please run with --help.")
- sys.exit(1)
+ raise SystemExit(self.casLog.info("Missing options, please run with --help."))
if __name__=="__main__":
app = CasAdminApplication(sys.argv[1:])
15 years, 1 month
lib/cas
by Adam Stokes
lib/cas/db.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit a23852a088ae4f6cd6b654f18168130372452240
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:56:45 2009 -0400
- make sure some sort of email is set in db whether passed
from cmd line or not
diff --git a/lib/cas/db.py b/lib/cas/db.py
index 9b46158..c41683b 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -109,8 +109,10 @@ class CasStorage(object):
"""
pass
- def addJob(self, identifier, date, email="noone(a)example.com"):
+ def addJob(self, identifier, date, email):
""" add job to db """
+ if email is None:
+ email = "cas@localhost"
values = (str(date), int(identifier), str(email))
self.cursor.execute('''INSERT into jobs (date,identifier,email)
values ("%s",%d, "%s")''' % values)
15 years, 1 month
cas
by Adam Stokes
cas | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 3316ae9a7a7873e00c9f96d684b85788bf0a1b4c
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:52:53 2009 -0400
- finally sendmail quit on failure to resolve mail server
diff --git a/cas b/cas
index 7092b4c..ca5e457 100755
--- a/cas
+++ b/cas
@@ -348,7 +348,8 @@ class CasApplication(object):
crashOutFH.close()
#mailServer.set_debuglevel(0)
mailServer.sendmail(self.email,self.email,msg)
- mailServer.quit(
+ finally:
+ mailServer.quit()
except smtplib.SMTPException, e:
self.casLog.debug("Unable to connect to mail server: %s (%s), no email " \
"results sent." % (SMTPHOST,str(e)))
15 years, 1 month
cas lib/cas
by Adam Stokes
cas | 7 +++++--
lib/cas/network.py | 4 +++-
2 files changed, 8 insertions(+), 3 deletions(-)
New commits:
commit 321bdcd09fa7a79d4696bc7aeffa69f0c4dd63a2
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:49:51 2009 -0400
- handle download exception on 404
diff --git a/cas b/cas
index 3075d90..7092b4c 100755
--- a/cas
+++ b/cas
@@ -24,7 +24,7 @@ import socket
from subprocess import Popen, PIPE
from datetime import datetime
-from cas.network import Download
+from cas.network import Download, CasNetworkException
from cas.core import CoreBase, CoreException
from cas.db import CasStorage, CasStorageException
from cas.util import UtilBase, Logging
@@ -69,7 +69,10 @@ class CoreHandler(object):
# filename is a url, process it with our download module
# this should return the the abspath to our processed directory
# and downloaded file
- self.filename = Download(self.filename, self.currentDirectory).get()
+ try:
+ self.filename = Download(self.filename, self.currentDirectory).get()
+ except CasNetworkException, e:
+ raise SystemExit(self.casLog.debug(e))
if not os.path.isfile(self.filename):
# not a url in this case so tests for local existence
# TODO: add support to check remote hosts
diff --git a/lib/cas/network.py b/lib/cas/network.py
index 3e36839..a14d9ff 100644
--- a/lib/cas/network.py
+++ b/lib/cas/network.py
@@ -16,6 +16,8 @@ import os
import urlparse
import urlgrabber.grabber as grabber
+class CasNetworkException(Exception): pass
+
class Download(object):
""" borrowed from anaconda's urlinstall method
"""
@@ -35,7 +37,7 @@ class Download(object):
try:
url = grabber.urlopen(self.url)
except grabber.URLGrabError, e:
- raise IOError (e.errno, e.strerror)
+ raise CasNetworkException(e.errno, e.strerror)
# check size
try:
15 years, 1 month
2 commits - web/index.html web/job_detail.html
by Adam Stokes
web/index.html | 4 ++--
web/job_detail.html | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
New commits:
commit 790e8447e1f4aaa99a11618d61211f33337a137c
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:35:08 2009 -0400
- add file upload widget, set form enctype
diff --git a/web/index.html b/web/index.html
index b9d5ad2..f59d914 100644
--- a/web/index.html
+++ b/web/index.html
@@ -2,7 +2,7 @@
<div id="content">
<h3>Core submission<h3>
<div id="form_submit">
- <form method="POST" action="job_submit.html">
+ <form method="POST" action="job_submit.html" enctype="multipart/form-data">
<table>
<tr>
<th> </th><th>Complete below form</th>
@@ -20,7 +20,7 @@
</tr>
<tr>
<td>Upload a File</td>
- <td>File upload section</td>
+ <td><input type="file" size="45" name="form_file"/></td>
</tr>
<tr>
<td>HTTP or FTP URL</td>
commit cef78335c9d2ec4f426f77fc72cdc3640e88a932
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:32:54 2009 -0400
- attempt to make logs more readable
diff --git a/web/job_detail.html b/web/job_detail.html
index eac2961..913771b 100644
--- a/web/job_detail.html
+++ b/web/job_detail.html
@@ -1,9 +1,11 @@
<& header.html &>
<div id="content">
<h3>Job Detail for <% $work_dir %>/<% $view_log %></h3>
+<ul>
% while (<DATA>) {
-<% $_ %><br/>
+<li><% $_ %></li>
% }
+</ul>
<& footer.html &>
<%init>
15 years, 1 month
cas
by Adam Stokes
cas | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
New commits:
commit d6545af9bcf05f71bb6d369fc10eec9e666da80b
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 17:13:18 2009 -0400
- better failure handling of smtp
diff --git a/cas b/cas
index 412667e..3075d90 100755
--- a/cas
+++ b/cas
@@ -19,6 +19,7 @@ import optparse
import os
import ConfigParser
import smtplib
+import socket
from subprocess import Popen, PIPE
from datetime import datetime
@@ -332,25 +333,23 @@ class CasApplication(object):
if os.path.isfile(crashOutFile) and self.email:
self.casLog.info("Crash output processed, sending email to %s" % (self.email,))
try:
- # Compose email msg of results
- msg = "Subject: CAS results for %s\r\n\n" % (self.identifier,)
- msg += "Location: %s\n" % (self.storagePath,)
- msg += "Server: %s\n" % (casProcessMachine,)
- msg += "Output data:\n"
- crashOutFH = open(crashOutFile,'r')
- msg += crashOutFH.read()
- crashOutFH.close()
+ mailServer = smtplib.SMTP(SMTPHOST)
try:
- # for some reason smtplib doesn't have proper exception handling
- # for name or service not known :(
- mailServer = smtplib.SMTP(SMTPHOST)
- except:
- self.casLog.debug("Unable to connect to mail server: %s, no email " \
- "results sent." % (SMTPHOST,))
- mailServer.set_debuglevel(0)
- mailServer.sendmail(self.email,self.email,msg)
- mailServer.quit()
+ # Compose email msg of results
+ msg = "Subject: CAS results for %s\r\n\n" % (self.identifier,)
+ msg += "Location: %s\n" % (self.storagePath,)
+ msg += "Server: %s\n" % (casProcessMachine,)
+ msg += "Output data:\n"
+ crashOutFH = open(crashOutFile,'r')
+ msg += crashOutFH.read()
+ crashOutFH.close()
+ #mailServer.set_debuglevel(0)
+ mailServer.sendmail(self.email,self.email,msg)
+ mailServer.quit(
except smtplib.SMTPException, e:
+ self.casLog.debug("Unable to connect to mail server: %s (%s), no email " \
+ "results sent." % (SMTPHOST,str(e)))
+ except (os.error, socket.error), e:
self.casLog.debug(e)
self.casLog.info("Job on %s complete and located in %s." % (self.filename,
self.storagePath))
15 years, 1 month
web/jobs.html
by Adam Stokes
web/jobs.html | 1 +
1 file changed, 1 insertion(+)
New commits:
commit f79e1217a6cbcc6df23fe5b5b5f585ab92625656
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 30 22:14:34 2009 -0400
- close table row
diff --git a/web/jobs.html b/web/jobs.html
index dd571f5..9f04734 100644
--- a/web/jobs.html
+++ b/web/jobs.html
@@ -14,6 +14,7 @@
<td><% $identify %></td>
<td><% $timestamp %></td>
<td><% $email %></td>
+</tr>
% }
</table>
</div>
15 years, 1 month
web/index.html web/job_detail.html web/jobs.html web/media
by Adam Stokes
web/index.html | 33 ++++++++++++++++++++++++++++++++-
web/job_detail.html | 13 ++++++-------
web/jobs.html | 2 +-
web/media/css/cas-web.css | 9 +++++++++
4 files changed, 48 insertions(+), 9 deletions(-)
New commits:
commit f3ff380b8d356d316cd58200131df2ada79da01f
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 30 22:08:19 2009 -0400
- job_detail properly reads workDirectory from config
and allows viewers to read logs via web-ui.
- laying groundwork for job submissions
diff --git a/web/index.html b/web/index.html
index 0922ad1..b9d5ad2 100644
--- a/web/index.html
+++ b/web/index.html
@@ -1,6 +1,37 @@
<& header.html &>
<div id="content">
<h3>Core submission<h3>
-
+<div id="form_submit">
+ <form method="POST" action="job_submit.html">
+ <table>
+ <tr>
+ <th> </th><th>Complete below form</th>
+ </tr>
+ <tr>
+ <td>Job Identifier</td>
+ <td><input type="text" size="25" name="form_identifier" />
+ </tr>
+ <tr>
+ <td>Submitter</td>
+ <td><input type="text" size="25" name="form_submitter" />
+ </tr>
+ <tr>
+ <td colspan="2" style="background-color: red; color: white;">Please choose a method for providing the core file</td>
+ </tr>
+ <tr>
+ <td>Upload a File</td>
+ <td>File upload section</td>
+ </tr>
+ <tr>
+ <td>HTTP or FTP URL</td>
+ <td><input type="text" size="45" name="form_url"/></td>
+ </tr>
+ <tr>
+ <td colspan="2"><input type="submit" value="Process Job" /></td>
+ </tr>
+ </table>
+
+ </form>
+</div>
</div>
<& footer.html &>
diff --git a/web/job_detail.html b/web/job_detail.html
index e39ce8a..eac2961 100644
--- a/web/job_detail.html
+++ b/web/job_detail.html
@@ -1,9 +1,8 @@
<& header.html &>
<div id="content">
-<h3>Job Detail</h3>
-% open LOG_DATA, "<$work_dir/$view_log" or die $!;
-% while (<LOG_DATA>) {
-<% $_ %>
+<h3>Job Detail for <% $work_dir %>/<% $view_log %></h3>
+% while (<DATA>) {
+<% $_ %><br/>
% }
<& footer.html &>
@@ -11,13 +10,13 @@
use Data::Dumper;
my $work_dir;
-open CONFIG, "</etc/cas.conf" or die $!;
-while (<CONFIG>) {
+open DATA, "</etc/cas.conf" or die $!;
+while (<DATA>) {
if (/^workDirectory=(.*)/) {
$work_dir = $1;
}
}
-close CONFIG;
+open DATA, "<$work_dir/$view_log" or die $!;
</%init>
<%args>
diff --git a/web/jobs.html b/web/jobs.html
index a648b33..dd571f5 100644
--- a/web/jobs.html
+++ b/web/jobs.html
@@ -9,7 +9,7 @@
% foreach my $item (@{$data}) {
% my ($id, $identify, $timestamp, $email) = @{$item};
<tr>
-<td><a href="/job_detail.html?view_log=<% $identify %>/<% $timestamp %>.log">view log</a></td>
+<td><a href="/job_detail.html?view_log=<% $identify %>/<% $timestamp %>/<% $identify %>.log">view log</a></td>
<td><% $id %></td>
<td><% $identify %></td>
<td><% $timestamp %></td>
diff --git a/web/media/css/cas-web.css b/web/media/css/cas-web.css
index 61a3278..d6880f3 100644
--- a/web/media/css/cas-web.css
+++ b/web/media/css/cas-web.css
@@ -1,3 +1,4 @@
+/* GLOBAL ATTRIBUTES */
body {
font-family: sans-serif;
margin: 0;
@@ -19,6 +20,8 @@ img {
border: 0;
}
+/* CUSTOM */
+
#header {
font-size: small;
padding: 5px;
@@ -41,3 +44,9 @@ img {
margin-left: auto;
margin-right: auto;
}
+
+/* FORM ELEMENTS */
+#form_submit {
+ font-size: small;
+ font-style: normal;
+}
15 years, 1 month