cas-admin | 17 +++++------------
cas.spec | 17 +++++++++++++++--
caslib/db.py | 14 ++++++++++++++
overseer/command.py | 47 ++++++++++++++++++++---------------------------
4 files changed, 54 insertions(+), 41 deletions(-)
New commits:
commit c9bafde81c7672b292cdaf10c6e07fec0c79a801
Author: adam stokes <astokes(a)fedoraproject.org>
Date: Mon May 3 20:50:02 2010 -0400
function
diff --git a/cas-admin b/cas-admin
index b61e2c8..eb83c2c 100755
--- a/cas-admin
+++ b/cas-admin
@@ -33,6 +33,7 @@ import ConfigParser
import optparse
import datetime
import paramiko
+import tempfile
from caslib.core import CoreBase, casexecute
from caslib.util import UtilBase, genprint
@@ -68,26 +69,18 @@ def queryLocalRpms(path):
Arguments:
- `path`: filesystem location of debug kernels
"""
- localRpms = []
# Uses emacs regex -- see `man find`
cmd = "find -L %s -iregex %s" % (settings["KERNELS"],
settings["RPMFILTER"])
results = casexecute(cmd, True)
- count = 0
- for rpm in results.split():
- localRpms.append(rpm)
- genprint("(found) %-5d kernels(s)" % (count,))
- count = count + 1
- dst = os.path.join(settings["DEBUGS"], str(count))
- if not os.path.isdir(dst):
- os.makedirs(dst)
-
- for rpm in localRpms:
- rpm_IN_DB = session.query(RPM).filter_by(rpmPath=rpm)
+ dst = tempfile.mkdtemp(prefix='cas-')
+ for rpm in results.split():
+ rpm_IN_DB = session.query(RPM).filter_by(rpmPath=rpm).first()
if not rpm_IN_DB:
# add RPM to database
rpm_record = RPM(rpm)
session.add(rpm_record)
+ session.commit()
rpmTool = RPMBase()
genprint("(extracting) %-50s" % (os.path.basename(rpm),))
results = rpmTool.extract(rpm, dst)
diff --git a/cas.spec b/cas.spec
index f712db5..ef9b4eb 100644
--- a/cas.spec
+++ b/cas.spec
@@ -6,7 +6,7 @@ Version: 0.18
Release: 0%{?dist}
Source0:
https://fedorahosted.org/releases/c/a/cas/%{name}-%{version}.tar.gz
License: GPLv3+
-Group: Development/Libraries
+Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url:
http://fedorahosted.org/cas
@@ -27,6 +27,15 @@ CAS provides a user the ability to configure an environment for core
analysis
quickly. All the hassles of matching kernel versions and machine architecture
types to core dumps are automatically detected and processed.
+%package admin
+Summary: Administrative frontend to CAS
+Group: Applications/System
+Requires: cas = %{version}-%{release}
+
+%description admin
+Administrative frontend to CAS database. Provides the ability to update
+the database instance with newly added kernel debug information and timestamps.
+
%prep
%setup -q
@@ -45,7 +54,6 @@ rm -rf ${RPM_BUILD_ROOT}
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/cas.conf
%{_bindir}/cas
-%{_bindir}/cas-admin
%{python_sitelib}/*
%{_mandir}/man1/*
%{_mandir}/man5/*
@@ -54,8 +62,13 @@ rm -rf ${RPM_BUILD_ROOT}
%config(noreplace) %{_var}/lib/cas/snippets/*
%doc AUTHORS LICENSE README PKG-INFO doc/*
+%files admin
+%defattr(-,root,root,-)
+%{_bindir}/cas-admin
+
%changelog
* Mon May 3 2010 Adam Stokes <ajs at redhat dot com> - 0.18
+- Split packages into admin/user
- Rewrote database interface using sqlalchemy
- Reworked cas-admin to interface with new database format
diff --git a/caslib/db.py b/caslib/db.py
index 8321fa3..aa42497 100644
--- a/caslib/db.py
+++ b/caslib/db.py
@@ -30,6 +30,20 @@ class RPM(Base):
def __repr__(self):
return "<RPM('%s')>" % (self.rpmPath,)
+class Job(Base):
+ __tablename__ = 'jobs'
+ jobId = Column(Integer, primary_key=True)
+ email = Column(String(40))
+ vmcore = Column(String(255))
+
+ def __init__(self, jobId, email, vmcore):
+ self.jobId = jobId
+ self.email = email
+ self.vmcore = vmcore
+
+ def __repr__(self):
+ return "<Job('%s','%s','%s')>" %
(self.jobId, self.email, self.vmcore)
+
class Timestamp(Base):
__tablename__ = 'timestamps'
stampId = Column(Integer, primary_key=True)
diff --git a/overseer/command.py b/overseer/command.py
old mode 100644
new mode 100755
index a750669..9f9d454
--- a/overseer/command.py
+++ b/overseer/command.py
@@ -1,49 +1,42 @@
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+#!/usr/bin/python
+# command
+# Overseer command for returning json data via RESTful calls
+# Copyright (C) 2010 Adam Stokes
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <
http://www.gnu.org/licenses/>.
import cherrypy
import simplejson as json
import ConfigParser
from datetime import datetime
import urlgrabber.grabber as grabber
-from caslib.db import CasStorage
+from caslib.db import *
class Admin:
pass
class Delegate:
- def __init__(self):
- cfg = ConfigParser.ConfigParser()
- cfg.read("/etc/cas.conf")
- db_file = cfg.get("settings", "database")
- self.db = CasStorage(db_file)
-
@cherrypy.expose
def index(self):
- """ Catchall call; returns current running jobs
"""
- return json.dumps(self.db.getAllJobs())
+ """ Ability to create/query jobs """
+ return
@cherrypy.expose
def create(self, vmcore, email):
""" Create job """
datenow = datetime.now()
dateFormatted = datenow.strftime("%Y.%m.%d.%I.%M.%S")
- try:
- grabber(vmcore)
- except grabber.URLGrabError, e:
- return json.dumps(e)
- self.db.addJob(id, dateFormatted, email)
- return json.dumps(id)
@cherrypy.expose
def status(self, id):