cas lib/cas
by Adam Stokes
cas | 54 ++++++++++++++++++++++++++++++++++++++--------------
lib/cas/db.py | 23 +++++++++-------------
lib/cas/rpmutils.py | 5 ----
lib/cas/util.py | 4 +--
4 files changed, 52 insertions(+), 34 deletions(-)
New commits:
commit b307882854ae52a263db582e61701e90faf9c122
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 16 21:20:35 2009 -0400
- change method to getElfArch for better reading (Flavio Leitner)
- space saver which checks if a local debug exist rather than
going through the process of extracting it from debuginfo (Flavio
Leitner)
diff --git a/cas b/cas
index 62af77c..7362d80 100755
--- a/cas
+++ b/cas
@@ -169,6 +169,11 @@ class CasApplication(object):
# clean and easy to debug
self.casLog = Logging(self.storagePath, self.identifier)
+ # Add job to database, this allows us to purge
+ # data based on job date creation then by other
+ # means. (i.e. identifier == a bugzilla #)
+ self.db.addJob(self.identifier, dateFormatted)
+
def run(self):
# setup directory structure
if not os.path.isdir(self.storagePath):
@@ -178,23 +183,45 @@ class CasApplication(object):
corefile = CoreHandler(self.filename, self.storagePath, self.casLog, self.db).run()
self.casLog.info("Corefile prepared, processing %s" % (corefile,))
debuginfo, debugKernel = TimestampHandler(corefile, self.casLog, self.db).run()
- filterString = "*/%s" % (debugKernel,)
- self.casLog.info("Extracting debug kernel with filter %s" % (filterString,))
- self.rpmTool.extract(debuginfo, self.storagePath,
- filter=filterString,
- return_results=False)
- # define absolute path to debugkernel
- debugKernel = os.path.abspath(debugKernel)
- # setup crash file to finalize the processing of the core file
- self.util.buildCrashFile(self.storagePath, corefile, debugKernel)
- # Pull the architecture from the elf file to match up with a
- # server providing this architecture
- debugKernelArch = self.util.debugKernelArch(debugKernel)
+ # change to destination directory
+ if not os.path.isdir(self.storagePath):
+ os.makedirs(self.storagePath)
+ os.chdir(self.storagePath)
+
+ corefileArch = self.util.getElfArch(self.filename)
+ self.casLog.debug("core arch %s" % (corefileArch,))
+
# Read current machine arch to see if we can bypass func and proceed
# with processing the core on the current machine
currentMachineArch = Popen(["uname","-m"], stdout=PIPE, stderr=PIPE)
currentMachineArch = currentMachineArch.stdout.read().strip()
+ self.casLog.debug("local machine arch %s" % (currentMachineArch,))
+
+ # check if an installed vmlinux can be used (symlink to save space)
+ local_vmlinux = "/%s" % debugKernel
+ if currentMachineArch == corefileArch and os.path.isfile(local_vmlinux):
+ self.casLog.info("Using local debug kernel")
+ os.symlink(local_vmlinux, "%s/%s" %
+ (self.storagePath, "vmlinux"))
+ # define absolute path to debugkernel
+ debugKernel = os.path.abspath("vmlinux")
+ else:
+ filterString = "*/%s" % (debugKernel,)
+ self.casLog.info("Extracting debug kernel with filter %s" % (filterString,))
+ self.rpmTool.extract(debuginfo, self.storagePath,
+ filter=filterString,
+ return_results=False)
+ # define absolute path to debugkernel
+ debugKernel = os.path.abspath(debugKernel)
+
+ self.casLog.info("checking debug kernel %s" % (debugKernel,))
+
+ # setup crash file to finalize the processing of the core file
+ self.util.buildCrashFile(self.storagePath, corefile, debugKernel)
+ # Pull the architecture from the elf file to match up with a
+ # server providing this architecture
+ debugKernelArch = self.util.getElfArch(debugKernel)
# Check if we have installed crash 32bit on system
if debugKernelArch == "i686" and CRASH_32 is not None:
# 32bit crash on same system.
@@ -329,8 +356,7 @@ class CasApplication(object):
if __name__=="__main__":
# Before we start the database has to exist.
if not os.path.isfile(DATABASE):
- raise("No Database exist, please run cas-admin --help for more information.")
- sys.exit(1)
+ raise SystemExit("No Database exist, please run cas-admin --help for more information.")
# Begin CAS
app = CasApplication(sys.argv[1:])
sys.exit(app.run())
diff --git a/lib/cas/db.py b/lib/cas/db.py
index efe8567..01706eb 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -7,7 +7,7 @@ else:
try:
import sqlite
except ImportError:
- raise SystemExit("Unable to determine sqlite, please make sure it is installed.")
+ raise SystemExit('Unable to determine sqlite, please make sure it is installed.')
class CasStorageException(Exception): pass
@@ -33,14 +33,12 @@ class CasStorage(object):
return
def buildTable(self):
- self.cursor.execute("""create table cas_jobs (
+ # We want to add jobs to a database just in case
+ # there is no structured form of purging old data.
+ self.cursor.execute("""create table jobs (
job_id integer primary key autoincrement,
- date text,
- submitter text,
- corepath text,
- debug_id integer,
- server_id integer,
- iterations integer)
+ identifier integer,
+ date text)
""")
self.cursor.execute("""create table debuginfo (
debug_id integer primary key autoincrement,
@@ -99,12 +97,11 @@ class CasStorage(object):
"""
pass
- def addJob(self, submitter, corepath, debug_id, server_id):
+ def addJob(self, identifier, date):
""" add job to db """
- values = (date, submitter, corepath, debug_id, server_id, 0)
- self.cursor.execute('''INSERT into cas_jobs (date,submitter,
- corepath, debug_id, server_id, iterations)
- values ("%s","%s","%s",%d,%d,%d)''' % values)
+ values = (date, identifier)
+ self.cursor.execute('''INSERT into jobs (date,identifier)
+ values ("%s",%d)''' % values)
return
# SERVER METHODS
diff --git a/lib/cas/rpmutils.py b/lib/cas/rpmutils.py
index 5a1c65f..170fcf4 100644
--- a/lib/cas/rpmutils.py
+++ b/lib/cas/rpmutils.py
@@ -40,11 +40,6 @@ class RPMBase(object):
self.cpio_args = "-imudv"
self.filter_results = []
- # change to destination directory
- if not os.path.isdir(self.dst):
- os.makedirs(self.dst)
- os.chdir(self.dst)
-
# pipe to handle extraction, e.g. rpm2cpio kernel.rpm | cpio -imud */vmlinux
p1 = Popen([self.rpm2cpio, self.rpm], stdout=PIPE)
p2 = Popen([self.cpio,self.cpio_args,self.filter], stdin=p1.stdout,
diff --git a/lib/cas/util.py b/lib/cas/util.py
index b3cfe36..fb7bad1 100644
--- a/lib/cas/util.py
+++ b/lib/cas/util.py
@@ -119,8 +119,8 @@ class UtilBase(object):
raise UtilException("%s : Unable to locate/load file." % (fname,))
return out
- def debugKernelArch(self, debug):
- """ determine machine type for debug kernel
+ def getElfArch(self, debug):
+ """ determine machine type for ELF file
"""
supportArch = {"IBM S/390":"s390x",
"Intel 80386":"i686",
15 years, 1 month
lib/cas
by Adam Stokes
lib/cas/db.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
New commits:
commit f2511cbeee719d86a9518cf1722161df843ff900
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 16 20:28:19 2009 -0400
- fixed exception
diff --git a/lib/cas/db.py b/lib/cas/db.py
index 8bd7ca8..efe8567 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -7,8 +7,7 @@ else:
try:
import sqlite
except ImportError:
- raise("Unable to determine sqlite, please make sure it is installed.")
- sys.exit(1)
+ raise SystemExit("Unable to determine sqlite, please make sure it is installed.")
class CasStorageException(Exception): pass
15 years, 1 month
[PATCH] Create a symlink to a local vmlinux if possible.
by Flavio Leitner
If the local machine and vmcore have the same arch and there
is a local debug kernel installed then it is possible to just
symlink to crash workdir instead of uncompress another copy.
This should save some disk space.
Signed-off-by: Flavio Leitner <fleitner(a)redhat.com>
---
cas | 40 +++++++++++++++++++++++++++++++---------
lib/cas/rpmutils.py | 5 -----
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/cas b/cas
index ab4da65..1d21f3f 100755
--- a/cas
+++ b/cas
@@ -175,23 +175,45 @@ class CasApplication(object):
corefile = CoreHandler(self.filename, self.storagePath, self.casLog).run()
self.casLog.info("Corefile prepared, processing %s" % (corefile,))
debuginfo, debugKernel = TimestampHandler(corefile, self.casLog).run()
- filterString = "*/%s" % (debugKernel,)
- self.casLog.info("Extracting debug kernel with filter %s" % (filterString,))
- self.rpmTool.extract(debuginfo, self.storagePath,
+
+ # change to destination directory
+ if not os.path.isdir(self.storagePath):
+ os.makedirs(self.storagePath)
+ os.chdir(self.storagePath)
+
+ corefileArch = self.util.getElfArch(self.filename)
+ self.casLog.debug("core arch %s" % (corefileArch))
+
+ # Read current machine arch to see if we can bypass func and proceed
+ # with processing the core on the current machine
+ currentMachineArch = Popen(["uname","-m"], stdout=PIPE, stderr=PIPE)
+ currentMachineArch = currentMachineArch.stdout.read().strip()
+ self.casLog.debug("local machine arch %s" % (currentMachineArch))
+
+ # check if an installed vmlinux can be used (symlink to save space)
+ local_vmlinux = "/%s" % debugKernel
+ if currentMachineArch == corefileArch and os.path.isfile(local_vmlinux):
+ self.casLog.info("Using local debug kernel");
+ os.symlink(local_vmlinux, "%s/%s" %
+ (self.storagePath, "vmlinux"))
+ # define absolute path to debugkernel
+ debugKernel = os.path.abspath("vmlinux")
+ else:
+ filterString = "*/%s" % (debugKernel,)
+ self.casLog.info("Extracting debug kernel with filter %s" % (filterString,))
+ self.rpmTool.extract(debuginfo, self.storagePath,
filter=filterString,
return_results=False)
+ # define absolute path to debugkernel
+ debugKernel = os.path.abspath(debugKernel)
+
+ self.casLog.info(("checking debug kernel %s" % debugKernel));
- # define absolute path to debugkernel
- debugKernel = os.path.abspath(debugKernel)
# setup crash file to finalize the processing of the core file
self.util.buildCrashFile(self.storagePath, corefile, debugKernel)
# Pull the architecture from the elf file to match up with a
# server providing this architecture
debugKernelArch = self.util.getElfArch(debugKernel)
- # Read current machine arch to see if we can bypass func and proceed
- # with processing the core on the current machine
- currentMachineArch = Popen(["uname","-m"], stdout=PIPE, stderr=PIPE)
- currentMachineArch = currentMachineArch.stdout.read().strip()
# Check if we have installed crash 32bit on system
if debugKernelArch == "i686" and CRASH_32 is not None:
# DONE: re-write crash output library to take into account
diff --git a/lib/cas/rpmutils.py b/lib/cas/rpmutils.py
index 5a1c65f..170fcf4 100644
--- a/lib/cas/rpmutils.py
+++ b/lib/cas/rpmutils.py
@@ -40,11 +40,6 @@ class RPMBase(object):
self.cpio_args = "-imudv"
self.filter_results = []
- # change to destination directory
- if not os.path.isdir(self.dst):
- os.makedirs(self.dst)
- os.chdir(self.dst)
-
# pipe to handle extraction, e.g. rpm2cpio kernel.rpm | cpio -imud */vmlinux
p1 = Popen([self.rpm2cpio, self.rpm], stdout=PIPE)
p2 = Popen([self.cpio,self.cpio_args,self.filter], stdin=p1.stdout,
--
1.6.2.3
15 years, 1 month
[PATCH] Renamed function util.debugKernelArch to util.getElfArch
by Flavio Leitner
This patch renames function util.debugKernelArch() to a more generic
name util.getElfArch()
Signed-off-by: Flavio Leitner <fleitner(a)redhat.com>
---
cas | 2 +-
lib/cas/util.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cas b/cas
index 319ca7b..ab4da65 100755
--- a/cas
+++ b/cas
@@ -187,7 +187,7 @@ class CasApplication(object):
self.util.buildCrashFile(self.storagePath, corefile, debugKernel)
# Pull the architecture from the elf file to match up with a
# server providing this architecture
- debugKernelArch = self.util.debugKernelArch(debugKernel)
+ debugKernelArch = self.util.getElfArch(debugKernel)
# Read current machine arch to see if we can bypass func and proceed
# with processing the core on the current machine
currentMachineArch = Popen(["uname","-m"], stdout=PIPE, stderr=PIPE)
diff --git a/lib/cas/util.py b/lib/cas/util.py
index cc4d834..c0e4ed7 100755
--- a/lib/cas/util.py
+++ b/lib/cas/util.py
@@ -119,8 +119,8 @@ class UtilBase(object):
raise UtilException("%s : Unable to locate/load file." % (fname,))
return out
- def debugKernelArch(self, debug):
- """ determine machine type for debug kernel
+ def getElfArch(self, debug):
+ """ determine machine type for ELF file
"""
supportArch = {"IBM S/390":"s390x",
"Intel 80386":"i686",
--
1.6.2.3
15 years, 1 month
cas cas-admin cas.spec lib/cas
by Adam Stokes
cas | 66 +++++++++++++++++++++++++++++++---------------------------
cas-admin | 14 +++++++-----
cas.spec | 2 -
lib/cas/db.py | 11 +++++++--
4 files changed, 54 insertions(+), 39 deletions(-)
New commits:
commit 5a32be9fd6057510a490aa6728b3dbad272e4d78
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 21:35:38 2009 -0400
- work started on integrating main app with sqlite backend
diff --git a/cas b/cas
index aaef477..62af77c 100755
--- a/cas
+++ b/cas
@@ -25,6 +25,7 @@ from datetime import datetime
from cas.network import Download
from cas.core import CoreBase, CoreException
+from cas.db import CasStorage, CasStorageException
from cas.util import UtilBase, Logging
from cas.rpmutils import RPMBase
@@ -53,13 +54,14 @@ if config.has_option("advanced", "crash_32"):
CRASH_32=config.get("advanced", "crash_32")
class CoreHandler(object):
- def __init__(self, filename, dst, logger):
+ def __init__(self, filename, dst, logger, database):
self.filename = filename
self.basename = os.path.basename(self.filename)
self.dst = dst
self.currentDirectory = os.path.realpath(os.curdir)
self.casLog = logger
self.tool = CoreBase()
+ self.db = database
def run(self):
if(self.filename.startswith("http") or self.filename.startswith("ftp")):
@@ -101,16 +103,16 @@ class CoreHandler(object):
sys.exit(1)
class TimestampHandler(object):
- def __init__(self, corefile, logger):
+ def __init__(self, corefile, logger, database):
self.corefile = corefile
self.casLog = logger
self.util = UtilBase()
self.tool = CoreBase()
+ self.db = database
def run(self):
# dig through the buildstamp database and attempt to match it with the
# one found in the core
- rpmDB = self.util.load(RPMS)
try:
coreTimestamp = self.tool.timestamp(self.corefile)
except CoreException, err:
@@ -129,6 +131,8 @@ class CasApplication(object):
self.parse_options(args)
self.util = UtilBase()
self.rpmTool = RPMBase()
+ self.db = CasStorage(DATABASE)
+ self.db.connect()
def parse_options(self, args):
# build option - arguement list in the form of
@@ -171,9 +175,9 @@ class CasApplication(object):
os.makedirs(self.storagePath)
self.casLog.info("Starting job at %s" % (self.storagePath,))
# begin core extraction analysis
- corefile = CoreHandler(self.filename, self.storagePath, self.casLog).run()
+ corefile = CoreHandler(self.filename, self.storagePath, self.casLog, self.db).run()
self.casLog.info("Corefile prepared, processing %s" % (corefile,))
- debuginfo, debugKernel = TimestampHandler(corefile, self.casLog).run()
+ debuginfo, debugKernel = TimestampHandler(corefile, self.casLog, self.db).run()
filterString = "*/%s" % (debugKernel,)
self.casLog.info("Extracting debug kernel with filter %s" % (filterString,))
self.rpmTool.extract(debuginfo, self.storagePath,
@@ -193,7 +197,6 @@ class CasApplication(object):
currentMachineArch = currentMachineArch.stdout.read().strip()
# Check if we have installed crash 32bit on system
if debugKernelArch == "i686" and CRASH_32 is not None:
- # DONE: re-write crash output library to take into account
# 32bit crash on same system.
self.util.buildCrashFile(self.storagePath, corefile, debugKernel,
CRASH_32)
@@ -214,7 +217,6 @@ class CasApplication(object):
# The machine is suitable for processing the core through crash.
self.casLog.info("Current machine suitable for processing core, running crash.")
cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
- # DONE: capture any errors returned from crash when processing core.
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
# pull status code to verify crash even ran to completeness
@@ -232,28 +234,29 @@ class CasApplication(object):
from time import sleep
self.casLog.info("Crash file built, locating suitable %s system for " \
"processing" % (debugKernelArch,))
- if os.path.isfile(SERVERS):
- serverList = self.util.load(SERVERS)
- if serverList.has_key(debugKernelArch):
- # TODO: Randomize server selection
- # TODO: Verify remote server is reachable
- casProcessMachine = serverList[debugKernelArch][0]
- self.casLog.info("Machine %s found, processing " \
- "crash output" % (casProcessMachine,))
- cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
- client = fc.Overlord(casProcessMachine,async=True)
- job_id = client.command.run(cmd)
- while True:
- status = client.job_status(job_id)
- (code, results) = status
- if code == jobthing.JOB_ID_RUNNING:
- print "task is running..."
- elif code == jobthing.JOB_ID_PARTIAL:
- print "task is running..."
- elif code == jobthing.JOB_ID_FINISHED:
- print "task complete, results = %s" % results
- break
- sleep(5)
+ serverList = self.db.getServers()
+ if serverList:
+ for hostname, arch in serverList:
+ if arch == debugKernelArch:
+ # TODO: Randomize server selection
+ # TODO: Verify remote server is reachable
+ casProcessMachine = serverList[debugKernelArch][0]
+ self.casLog.info("Machine %s found, processing " \
+ "crash output" % (casProcessMachine,))
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
+ client = fc.Overlord(casProcessMachine,async=True)
+ job_id = client.command.run(cmd)
+ while True:
+ status = client.job_status(job_id)
+ (code, results) = status
+ if code == jobthing.JOB_ID_RUNNING:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_PARTIAL:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_FINISHED:
+ print "task complete, results = %s" % results
+ break
+ sleep(5)
else:
self.casLog.info("No servers available for arch and current system not "\
"suitable for processing, please run cas-admin -h " \
@@ -262,7 +265,6 @@ class CasApplication(object):
self.casLog.info("No servers database found, please run cas-admin -h for " \
"more information")
sys.exit(1)
- # DONE: Possibly handle this exception more gracefully?
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.")
@@ -325,6 +327,10 @@ class CasApplication(object):
return
if __name__=="__main__":
+ # Before we start the database has to exist.
+ if not os.path.isfile(DATABASE):
+ raise("No Database exist, please run cas-admin --help for more information.")
+ sys.exit(1)
# Begin CAS
app = CasApplication(sys.argv[1:])
sys.exit(app.run())
diff --git a/cas-admin b/cas-admin
index 424e0ed..544da46 100755
--- a/cas-admin
+++ b/cas-admin
@@ -92,6 +92,14 @@ class CasServerHandler(object):
def __init__(self, logger):
self.casLog = logger
self.util = UtilBase()
+ # setup database connection
+ self.first_run = False
+ if not os.path.isfile(DATABASE):
+ self.first_run = True
+ self.db = CasStorage(DATABASE)
+ self.db.connect()
+ if self.first_run:
+ self.db.buildTable()
def run(self):
try:
@@ -117,12 +125,8 @@ class CasServerHandler(object):
self.casLog.debug(err)
# clean up arch string
arch = arch.strip()
- if serverList.has_key(arch):
- serverList[arch].append(hostname)
- else:
- serverList[arch] = [hostname]
+ self.db.addServer(hostname, arch)
hostname_count = hostname_count + 1
- self.util.save(serverList, SERVERS)
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 " \
diff --git a/cas.spec b/cas.spec
index 9422a8c..a7d93e4 100644
--- a/cas.spec
+++ b/cas.spec
@@ -12,7 +12,7 @@ BuildArch: noarch
Url: http://fedorahosted.org/cas
BuildRequires: python-devel
%if 0%{?rhel}
-Requires: python-sqlite2 crash
+Requires: python-sqlite crash
%else
Requires: crash
%endif
diff --git a/lib/cas/db.py b/lib/cas/db.py
index 50ba62d..8bd7ca8 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -91,8 +91,7 @@ class CasStorage(object):
def getJobById(self, id):
""" single job """
- id = (id,)
- self.cursor.execute('SELECT * FROM cas_jobs where id=%d' % id)
+ self.cursor.execute('SELECT * FROM cas_jobs where id=%d' % (id,))
return self.cursor.fetchone()
def getJobRange(self, days):
@@ -113,6 +112,12 @@ class CasStorage(object):
def addServer(self, hostname, arch):
""" add server/arch to db """
values = (hostname, arch)
- self.cursor.execute('''INSERT into server (hostname, arch)
+ self.cursor.execute('select * from server where hostname"%s"' % (hostname,))
+ if not self.cursor.fetchone():
+ self.cursor.execute('''INSERT into server (hostname, arch)
values ("%s","%s")''' % values)
return
+
+ def getServers(self):
+ self.cursor.execute('select * from server')
+ return self.cursor.fetchall()
diff --git a/lib/cas/util.py b/lib/cas/util.py
old mode 100755
new mode 100644
15 years, 1 month
cas-admin lib/cas
by Adam Stokes
cas-admin | 2 +-
lib/cas/db.py | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
New commits:
commit 0acf99af4012eb5bdf49449a854b238c62aad0ed
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 19:25:51 2009 -0400
- server/arch addition
diff --git a/cas-admin b/cas-admin
index 267148d..424e0ed 100755
--- a/cas-admin
+++ b/cas-admin
@@ -73,7 +73,7 @@ class CasDatabaseHandler(object):
# temporary storage path in form of DEBUGS/COUNT
dst = os.path.join(DEBUGS, str(count))
rpmTool = RPMBase()
- self.casLog.status("(extracting) %-50s" % (rpm))
+ self.casLog.status("(extracting) %-50s" % (os.path.basename(rpm),))
results = rpmTool.extract(rpm, dst)
# Sort through extracted debug for each type
# e.g. hugemem, PAE, smp, largesmp
diff --git a/lib/cas/db.py b/lib/cas/db.py
index 4091149..50ba62d 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -53,6 +53,11 @@ class CasStorage(object):
timestamp text,
debug_id integer)
""")
+ self.cursor.execute("""create table server (
+ server_id integer primary key autoincrement,
+ arch text,
+ hostname text)
+ """)
self.commit()
return
@@ -103,3 +108,11 @@ class CasStorage(object):
corepath, debug_id, server_id, iterations)
values ("%s","%s","%s",%d,%d,%d)''' % values)
return
+
+ # SERVER METHODS
+ def addServer(self, hostname, arch):
+ """ add server/arch to db """
+ values = (hostname, arch)
+ self.cursor.execute('''INSERT into server (hostname, arch)
+ values ("%s","%s")''' % values)
+ return
15 years, 1 month
cas-admin lib/cas
by Adam Stokes
cas-admin | 1 -
lib/cas/db.py | 18 +++++++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
New commits:
commit b4e4e8783a74f780faa7ce45473a9d177b6584ce
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 13:00:52 2009 -0400
- first successful run using new sqlite backend and population of kernel
information
diff --git a/cas-admin b/cas-admin
index df77a24..267148d 100755
--- a/cas-admin
+++ b/cas-admin
@@ -84,7 +84,6 @@ class CasDatabaseHandler(object):
timestamp = stamper.timestamp(debugKernel)
# add rpm id, debug, timestamp to database
self.db.addTimestamp(id, debugKernel, timestamp)
- self.util.save(self.rpmDB, RPMS)
# Cleanup extracted debugs
rmtree(dst)
return
diff --git a/lib/cas/db.py b/lib/cas/db.py
index 41b487d..4091149 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -59,9 +59,9 @@ class CasStorage(object):
# DEBUGINFO METHODS
def addDebuginfoRPM(self, debuginfo):
debuginfo = (debuginfo,)
- self.cursor.execute("SELECT * from debuginfo where rpm=%s" % debuginfo)
+ self.cursor.execute('SELECT * from debuginfo where rpm="%s"' % debuginfo)
if not self.cursor.fetchone():
- self.cursor.execute("INSERT into debuginfo('rpm') values(%s)" % debuginfo)
+ self.cursor.execute('INSERT into debuginfo(rpm) values("%s")' % debuginfo)
self.commit()
return
@@ -73,21 +73,21 @@ class CasStorage(object):
def addTimestamp(self, id, debug, timestamp):
""" build relation to debuginfo rpm and add debug path, timestamp """
values = (id, debug, timestamp)
- self.cursor.execute("""INSERT into timestamp ('debug_id','debugpath',
- 'timestamp') values(%d,%s,%s)""" % values)
+ self.cursor.execute('''INSERT into timestamp (debug_id,debugpath,
+ timestamp) values(%d,"%s","%s")''' % values)
self.commit()
return
# JOB METHODS
def getAllJobs(self):
""" all jobs """
- self.cursor.execute("SELECT * FROM cas_jobs")
+ self.cursor.execute('SELECT * FROM cas_jobs')
return self.cursor.fetchall()
def getJobById(self, id):
""" single job """
id = (id,)
- self.cursor.execute("SELECT * FROM cas_jobs where id=%d" % id)
+ self.cursor.execute('SELECT * FROM cas_jobs where id=%d' % id)
return self.cursor.fetchone()
def getJobRange(self, days):
@@ -99,7 +99,7 @@ class CasStorage(object):
def addJob(self, submitter, corepath, debug_id, server_id):
""" add job to db """
values = (date, submitter, corepath, debug_id, server_id, 0)
- self.cursor.execute("""INSERT into cas_jobs ('date','submitter',
- 'corepath', debug_id, server_id, iterations)
- values (%s,%s,%s,%d,%d,%d)""" % values)
+ self.cursor.execute('''INSERT into cas_jobs (date,submitter,
+ corepath, debug_id, server_id, iterations)
+ values ("%s","%s","%s",%d,%d,%d)''' % values)
return
15 years, 1 month
lib/cas
by Adam Stokes
lib/cas/db.py | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
New commits:
commit bf25f454a7a98c0b08aa88f52cf2812e4f5b57b4
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 12:31:14 2009 -0400
- awesome we have to use the unsecured way to query the db because of
sqlite in 2.4 :\
diff --git a/lib/cas/db.py b/lib/cas/db.py
index b71757a..41b487d 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -34,18 +34,34 @@ class CasStorage(object):
return
def buildTable(self):
- self.cursor.execute("create table cas_jobs (job_id integer primary key autoincrement, date text, submitter text, corepath text, debug_id integer, server_id integer, iterations integer)")
- self.cursor.execute("create table debuginfo (debug_id integer primary key autoincrement, rpm text)")
- self.cursor.execute("create table timestamp (timestamp_id integer primary key autoincrement, debugpath text, timestamp text, debug_id integer)")
+ self.cursor.execute("""create table cas_jobs (
+ job_id integer primary key autoincrement,
+ date text,
+ submitter text,
+ corepath text,
+ debug_id integer,
+ server_id integer,
+ iterations integer)
+ """)
+ self.cursor.execute("""create table debuginfo (
+ debug_id integer primary key autoincrement,
+ rpm text)
+ """)
+ self.cursor.execute("""create table timestamp (
+ timestamp_id integer primary key autoincrement,
+ debugpath text,
+ timestamp text,
+ debug_id integer)
+ """)
self.commit()
return
# DEBUGINFO METHODS
def addDebuginfoRPM(self, debuginfo):
debuginfo = (debuginfo,)
- self.cursor.execute("SELECT * from debuginfo where rpm=?", debuginfo)
+ self.cursor.execute("SELECT * from debuginfo where rpm=%s" % debuginfo)
if not self.cursor.fetchone():
- self.cursor.execute("INSERT into debuginfo('rpm') values(?)", debuginfo)
+ self.cursor.execute("INSERT into debuginfo('rpm') values(%s)" % debuginfo)
self.commit()
return
@@ -58,7 +74,7 @@ class CasStorage(object):
""" build relation to debuginfo rpm and add debug path, timestamp """
values = (id, debug, timestamp)
self.cursor.execute("""INSERT into timestamp ('debug_id','debugpath',
- 'timestamp') values(?,?,?)""", values)
+ 'timestamp') values(%d,%s,%s)""" % values)
self.commit()
return
@@ -71,7 +87,7 @@ class CasStorage(object):
def getJobById(self, id):
""" single job """
id = (id,)
- self.cursor.execute("SELECT * FROM cas_jobs where id=?", id)
+ self.cursor.execute("SELECT * FROM cas_jobs where id=%d" % id)
return self.cursor.fetchone()
def getJobRange(self, days):
@@ -85,5 +101,5 @@ class CasStorage(object):
values = (date, submitter, corepath, debug_id, server_id, 0)
self.cursor.execute("""INSERT into cas_jobs ('date','submitter',
'corepath', debug_id, server_id, iterations)
- values (?,?,?,?,?,?)""", values)
+ values (%s,%s,%s,%d,%d,%d)""" % values)
return
15 years, 1 month
lib/cas
by Adam Stokes
lib/cas/db.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 7da308189f98b834aa6f368c5b0a36c606750deb
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 12:16:57 2009 -0400
- tuples for data entry
diff --git a/lib/cas/db.py b/lib/cas/db.py
index e68a2f2..b71757a 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -42,6 +42,7 @@ class CasStorage(object):
# DEBUGINFO METHODS
def addDebuginfoRPM(self, debuginfo):
+ debuginfo = (debuginfo,)
self.cursor.execute("SELECT * from debuginfo where rpm=?", debuginfo)
if not self.cursor.fetchone():
self.cursor.execute("INSERT into debuginfo('rpm') values(?)", debuginfo)
@@ -55,8 +56,9 @@ class CasStorage(object):
# TIMESTAMP METHODS
def addTimestamp(self, id, debug, timestamp):
""" build relation to debuginfo rpm and add debug path, timestamp """
+ values = (id, debug, timestamp)
self.cursor.execute("""INSERT into timestamp ('debug_id','debugpath',
- 'timestamp') values(?,?,?)""", id, debug, timestamp)
+ 'timestamp') values(?,?,?)""", values)
self.commit()
return
@@ -68,6 +70,7 @@ class CasStorage(object):
def getJobById(self, id):
""" single job """
+ id = (id,)
self.cursor.execute("SELECT * FROM cas_jobs where id=?", id)
return self.cursor.fetchone()
@@ -79,7 +82,8 @@ class CasStorage(object):
def addJob(self, submitter, corepath, debug_id, server_id):
""" add job to db """
+ values = (date, submitter, corepath, debug_id, server_id, 0)
self.cursor.execute("""INSERT into cas_jobs ('date','submitter',
'corepath', debug_id, server_id, iterations)
- values (?,?,?,?,?,?)""", date, submitter, corepath, debug_id, server_id, 0)
+ values (?,?,?,?,?,?)""", values)
return
15 years, 1 month
cas-admin cas.conf lib/cas setup.py
by Adam Stokes
cas-admin | 18 +++++++++++++-----
cas.conf | 6 +++---
lib/cas/db.py | 9 ++++++---
setup.py | 2 +-
4 files changed, 23 insertions(+), 12 deletions(-)
New commits:
commit 06f05d72f1c028207c1a290f42a694428dd0fa67
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 12:10:43 2009 -0400
- db module needs some more work, in the selection areas.
diff --git a/cas-admin b/cas-admin
index b2d5f84..df77a24 100755
--- a/cas-admin
+++ b/cas-admin
@@ -48,8 +48,13 @@ class CasDatabaseHandler(object):
self.casLog = logger
self.util = UtilBase()
# setup database connection
+ self.first_run = False
+ if not os.path.isfile(DATABASE):
+ self.first_run = True
self.db = CasStorage(DATABASE)
self.db.connect()
+ if self.first_run:
+ self.db.buildTable()
def run(self):
# Uses emacs regex -- see `man find`
@@ -134,11 +139,14 @@ class CasAdminApplication(object):
def parse_options(self, args):
parser = optparse.OptionParser(usage="cas-admin [opts] args")
parser.add_option("-b","--build", dest="buildDB",
- help="Build CAS DB", action="store_true", default=False)
+ help="Build CAS DB", action="store_true",
+ default=False)
parser.add_option("-s","--server", dest="server_init",
- help="Build SERVER DB", action="store_true", default=False)
+ help="Build SERVER DB", action="store_true",
+ default=False)
parser.add_option("-p","--purge", dest="purgeData",
- help="Purge files", action="store_true", default=False)
+ help="Purge files default 90 days, customize with -d",
+ action="store_true", default=False)
parser.add_option("-d","--days", dest="purgeDataDays",
help="Set how many days back to purge data")
(self.opts, args) = parser.parse_args()
@@ -153,8 +161,8 @@ class CasAdminApplication(object):
"""
if os.getuid() is not 0:
raise RuntimeError, "You must be root(0), instead you are id(%d)" % (os.getuid())
- if not os.path.isdir(os.path.dirname(RPMS)):
- os.makedirs(RPMS)
+ if not os.path.isdir(os.path.dirname(DATABASE)):
+ os.makedirs(os.path.dirname(DATABASE))
if not os.path.isdir(DEBUGS):
os.makedirs(DEBUGS)
diff --git a/cas.conf b/cas.conf
index 2b17e34..ed1117d 100644
--- a/cas.conf
+++ b/cas.conf
@@ -25,6 +25,9 @@ workDirectory=/cores
# Provides job results via email
mailServer=mail.example.com
+# database connection info
+database=/var/db/cas/cas.db
+
[maintenance]
# Time in days to keep jobs and its associated files
purgeLimit=90
@@ -33,9 +36,6 @@ purgeLimit=90
# whenever cas-admin is run
autoPurge=False
-# database connection info
-database='/var/db/cas/cas.db'
-
[advanced]
# if running a x86_64 system and wish to analyze 32bit
# cores, define the location of 32bit crash binary
diff --git a/lib/cas/db.py b/lib/cas/db.py
index b0478a6..e68a2f2 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -2,10 +2,13 @@ import os
import sys
if sys.version_info[:2] > (2,4):
+ import sqlite3 as sqlite
+else:
try:
- import sqlite3 as sqlite
- except ImportError:
import sqlite
+ except ImportError:
+ raise("Unable to determine sqlite, please make sure it is installed.")
+ sys.exit(1)
class CasStorageException(Exception): pass
@@ -39,7 +42,7 @@ class CasStorage(object):
# DEBUGINFO METHODS
def addDebuginfoRPM(self, debuginfo):
- self.cursor.execute("SELECT * from debuginfo where debuginfo=?", debuginfo)
+ self.cursor.execute("SELECT * from debuginfo where rpm=?", debuginfo)
if not self.cursor.fetchone():
self.cursor.execute("INSERT into debuginfo('rpm') values(?)", debuginfo)
self.commit()
diff --git a/setup.py b/setup.py
index c8ef395..5f8b134 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ snippetpath = libpath + "/snippets"
setup(
name = 'cas',
- version = '0.13',
+ version = '0.14',
author = 'Adam Stokes',
author_email = 'ajs(a)redhat.com',
url = "http://fedorahosted.org/cas",
15 years, 1 month