cas-admin | 66 ++++++++++++++++++++++++++++++++++-------------------------
cas.spec | 2 -
caslib/db.py | 52 ++++++++++------------------------------------
3 files changed, 52 insertions(+), 68 deletions(-)
New commits:
commit 5aa2c4583d1cfd8986b01c3a7d10ee72debe7d43
Author: adam stokes <astokes(a)fedoraproject.org>
Date: Thu May 13 14:50:11 2010 -0400
support both RPM and extracted debugs
diff --git a/cas-admin b/cas-admin
index fcaac9d..36b2136 100755
--- a/cas-admin
+++ b/cas-admin
@@ -19,8 +19,13 @@
""" cas-admin - fingerprinting utility for cas
"""
import sys
-if sys.version_info[:2] < (2,6):
- raise SystemExit("Python >= 2.6 required")
+
+try:
+ from multiprocessing import Process, Queue, current_process, cpu_count, Lock
+except ImportError:
+ raise SystemExit('Unable to import multiprocessing module. This is shipped
by' \
+ 'default in Python 2.6 and above. If using Python 2.4/2.5 a'
\
+ 'backport is available at
http://pypi.python.org/pypi/multiprocessing')
try:
from caslib.db import *
# Setup session for db interaction
@@ -35,9 +40,8 @@ import optparse
import datetime
import paramiko
import tempfile
-from multiprocessing import Process, Queue, current_process, cpu_count, Lock
-from caslib.core import casexecute, coreTimestamp
+from caslib.core import casexecute, coreTimestamp, coreIsCorefile
from caslib.util import Utility, genprint
from caslib.rpmutils import extractDebug
from caslib import error_messages as _e
@@ -70,30 +74,38 @@ util = Utility()
PROCESSES = cpu_count()
def queryWorker(input):
""" worker function to process rpm debugs """
- for rpm, dst in iter(input.get, 'STOP'):
+ for debug, dst in iter(input.get, 'STOP'):
session = Session()
- rpm_IN_DB = session.query(RPM).filter_by(rpmPath=rpm).first()
+ debug_IN_DB = session.query(Debug).filter_by(debugPath=debug).first()
session.close()
- if not rpm_IN_DB:
+ if not debug_IN_DB:
# add RPM to database
session = Session()
- rpm_record = RPM(rpm)
- session.add(rpm_record)
+ debug_record = Debug(debug)
+ session.add(debug_record)
session.commit()
- genprint("(extracting) %-50s" % (os.path.basename(rpm),))
- tmpkernel = extractDebug(rpm, dst)
- # Sort through extracted debug for each type
- # e.g. hugemem, PAE, smp, largesmp
- for item in tmpkernel:
- vmlinux = item.strip()
- debugKernel = os.path.normpath(vmlinux)
- timestamp = coreTimestamp(debugKernel, BUFFERSIZE)
- # add rpm id, debug, timestamp to database
+ if not coreIsCorefile(debug):
+ genprint("(extracting) %-50s" % (os.path.basename(debug),))
+ tmpkernel = extractDebug(debug, dst)
+ # Sort through extracted debug for each type
+ # e.g. hugemem, PAE, smp, largesmp
+ for item in tmpkernel:
+ vmlinux = item.strip()
+ debugKernel = os.path.normpath(vmlinux)
+ timestamp = coreTimestamp(debugKernel, BUFFERSIZE)
+ # add id, debug, timestamp to database
+ timestamp_record = Timestamp(timestamp,
+ debugKernel,
+ debug_record.debugId)
+ session.add(timestamp_record)
+ # commit to database
+ session.commit()
+ elif coreIsCorefile(debug):
+ timestamp = coreTimestamp(debug, BUFFERSIZE)
timestamp_record = Timestamp(timestamp,
- debugKernel,
- rpm_record.rpmId)
+ debug,
+ debug_record.debugId)
session.add(timestamp_record)
- # commit to database
session.commit()
session.close()
@@ -108,15 +120,15 @@ def queryLocalRpms():
cmd = "find -L %s -regextype %s" % (settings["KERNELS"],
settings["REGEXTYPE"])
if "RPMFILTER" in settings:
- for i in settings["RPMFILTER"].split():
- cmd = cmd + " \( -iregex %s \) " % (i,)
+ for i in settings["RPMFILTER"].split(','):
+ cmd = cmd + " \( -iregex %s \) , " % (i,)
# append any file/dir exclusions
if "REGEXEXCLUDEDIR" in settings:
- for i in settings["REGEXEXCLUDEDIR"].split():
- cmd = cmd + " \( -not -path %i \) " % (i,)
+ for i in settings["REGEXEXCLUDEDIR"].split(','):
+ cmd = cmd + " \( -not -path %s \) " % (i,)
if "REGEXEXCLUDEFILE" in settings:
- for i in settings["REGEXEXCLUDEFILE"].split():
- cmd = cmd + " \( -not -name %i \) " % (i,)
+ for i in settings["REGEXEXCLUDEFILE"].split(','):
+ cmd = cmd + " \( -not -name %s \) " % (i,)
results, err = casexecute(cmd, True)
dst = tempfile.mkdtemp(prefix='cas-')
for rpm in results.split():
diff --git a/cas.spec b/cas.spec
index 7deb8b0..dc3abe3 100644
--- a/cas.spec
+++ b/cas.spec
@@ -11,7 +11,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url:
http://fedorahosted.org/cas
BuildRequires: python-devel
-%if 0%{?rhel}
+%if 0%{?rhel} <= 5
Requires: python-sqlite
%endif
Requires: python-paramiko
diff --git a/caslib/db.py b/caslib/db.py
index a3c5f2b..e3d490a 100644
--- a/caslib/db.py
+++ b/caslib/db.py
@@ -38,16 +38,16 @@ class Core(Base):
def __repr__(self):
return "<Core('%s','%s')>" % (self.coreFile,
self.coreHash)
-class RPM(Base):
- __tablename__ = 'rpms'
- rpmId = Column(Integer, primary_key=True)
- rpmPath = Column(String(255))
+class Debug(Base):
+ __tablename__ = 'debugs'
+ debugId = Column(Integer, primary_key=True)
+ debugPath = Column(String(255))
- def __init__(self, rpmPath):
- self.rpmPath = rpmPath
+ def __init__(self, debugPath):
+ self.debugPath = debugPath
def __repr__(self):
- return "<RPM('%s')>" % (self.rpmPath,)
+ return "<Debug('%s')>" % (self.debugPath,)
class Job(Base):
__tablename__ = 'jobs'
@@ -72,52 +72,24 @@ class Job(Base):
self.vmcore,
self.path,
self.msg)
-class JobArchive(Base):
- """ Primarily for tracking """
- __tablename__ = 'jobarchive'
- jobId = Column(Integer, primary_key=True)
- identifier = Column(String(100))
- email = Column(String(40))
- vmcore = Column(String(255))
- path = Column(String(255))
- msg = Column(String(255))
- created = Column(DateTime)
- ipaddr = Column(Integer)
-
- def __init__(self, identifier, email, vmcore, ipaddr, path=None, msg=None):
- self.identifier = identifier
- self.email = email
- self.vmcore = vmcore
- self.path = path
- self.msg = msg
- self.ipaddr = ipaddr
-
- def __repr__(self):
- return
"<Job('%s','%s','%s','%s','%s')>"
% (self.identifier,
- self.email,
- self.vmcore,
- self.path,
- self.msg,
- self.ipaddr)
-
class Timestamp(Base):
__tablename__ = 'timestamps'
stampId = Column(Integer, primary_key=True)
stampKey = Column(String(255))
debugPath = Column(String(255))
- rpmId = Column(Integer, ForeignKey("rpms.rpmId"))
+ debugId = Column(Integer, ForeignKey("debugs.debugId"))
- rpm = relationship(RPM, backref=backref('timestamps'))
+ debug = relationship(Debug, backref=backref('timestamps'))
- def __init__(self, stampKey, debugPath, rpmId):
+ def __init__(self, stampKey, debugPath, debugId):
self.stampKey = stampKey
self.debugPath = debugPath
- self.rpmId = rpmId
+ self.debugId = debugId
def __repr__(self):
return "<Timestamp('%s','%s','%s')>" %
(self.stampKey,
self.debugPath,
- self.rpmId)
+ self.debugId)
class Server(Base):
__tablename__ = 'servers'