MANIFEST.in | 1 +
cas | 29 +++++++++++++++++++----------
lib/cas/util.py | 36 ++++++++++++++++--------------------
setup.py | 15 ++++++++++++++-
snippets/log | 2 ++
snippets/memory | 3 +++
snippets/modules | 2 ++
snippets/sys | 3 +++
snippets/template | 9 +++++++++
snippets/traceback | 3 +++
10 files changed, 72 insertions(+), 31 deletions(-)
New commits:
commit 884f0515991bf2df2ca020d45f2343eb0a00d9e5
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 2 20:13:03 2009 -0400
- snippet support, all crash commands are now in /var/lib/snippets (Scott Dodson)
- Fix func timeout in remote calls (Scott Dodson)
diff --git a/MANIFEST.in b/MANIFEST.in
index a035605..508d8fc 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,4 @@ include cas-admin.1.gz
include LICENSE
include README
recursive-include doc *
+recursive-include snippets *
diff --git a/cas b/cas
index 0dac60c..aaef477 100755
--- a/cas
+++ b/cas
@@ -199,7 +199,7 @@ class CasApplication(object):
CRASH_32)
self.casLog.info("Current machine suitable for processing 32 bit core,
"\
"running crash.")
- cmd = os.path.join(self.storagePath,"crash")
+ cmd = "cd " + os.path.join(self.storagePath) + " &&
./crash -i crash.in > crash.out"
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
# pull status code to verify crash even ran to completeness
@@ -213,7 +213,7 @@ class CasApplication(object):
casProcessMachine = platform.uname()[1]
# The machine is suitable for processing the core through crash.
self.casLog.info("Current machine suitable for processing core, running
crash.")
- cmd = os.path.join(self.storagePath,"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()
@@ -228,6 +228,8 @@ class CasApplication(object):
# is configured we attempt to process the core at another machine.
try:
import func.overlord.client as fc
+ import func.jobthing as jobthing
+ from time import sleep
self.casLog.info("Crash file built, locating suitable %s system for
" \
"processing" % (debugKernelArch,))
if os.path.isfile(SERVERS):
@@ -238,13 +240,20 @@ class CasApplication(object):
casProcessMachine = serverList[debugKernelArch][0]
self.casLog.info("Machine %s found, processing " \
"crash output" %
(casProcessMachine,))
- cmd = os.path.join(self.storagePath,"crash")
- client = fc.Overlord(casProcessMachine)
- clientDict = client.command.run(cmd)
- # Only necessary for debugging why running of crash failed.
- sts, out, err = clientDict[clientDict.keys()[0]]
- if sts:
- self.casLog.debug(out.strip())
+ 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
" \
@@ -259,7 +268,7 @@ class CasApplication(object):
"and
http://fedorahosted.org/func is not installed/configured
properly.")
self.casLog.info("Finishing job without processing the core, please
find a suitable %s "\
"machine in order to view this core in crash." %
(debugKernelArch,))
- crashOutFile = os.path.join(self.storagePath,"crash.out")
+ crashOutFile = os.path.join(self.storagePath,"modules")
if os.path.isfile(crashOutFile) and self.extractKernelModules:
self.casLog.info("Extracting loaded kernels modules. This will " \
"take several minutes.")
diff --git a/lib/cas/util.py b/lib/cas/util.py
index cc4d834..b3cfe36 100755
--- a/lib/cas/util.py
+++ b/lib/cas/util.py
@@ -134,7 +134,8 @@ class UtilBase(object):
cmd = ["readelf", "-h", debug]
cmd2 = ["grep", "Machine"]
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
- pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE, stderr=PIPE).communicate()
+ pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE,
+ stderr=PIPE).communicate()
machine, sts = pipe2
for k, v in supportArch.iteritems():
if k in machine:
@@ -143,24 +144,19 @@ class UtilBase(object):
def buildCrashFile(self, dst, vmcore, debug, file_in="crash.in",
crash_bin="/usr/bin/crash"):
- """ build crash file with predefined debug
- commands
+ """ build crash and crash.in file with output from the snippets in
+ /var/lib/cas/snippets
"""
- # Optional commands can be placed here, for example,
- # kmem -f, sys -c
- # please note some commands like the ones above take a looong time to
- # run and can possibly timeout the xmlrpc server provided with func
- crashInputCmds = ['bt -a >>', 'sys >>',
- 'log >>', 'mod >>']
- crashOutputPath = os.path.join(dst, "crash.out")
- # test for output file existance
- if os.path.isfile(crashOutputPath):
- os.remove(crashOutputPath)
- # alter list to append the output path of the crash.out file
- # e.g. bt -a >> /cores/processed/123/crash.out\n
- crashInputCmds = [item+crashOutputPath+"\n" for item in
crashInputCmds]
- # append the crash exit command since this doesn't give any additional
- # output and doesn't need alteration
+ # TODO: We should provide the environment variables mentioned in the
+ # template snippet, CAS_ARCH, CAS_KERNEL, CAS_SIZE, and whatever else
+ # makse sense so scripts can opt in based on the environmentals
+ dir_listing=[]
+ crashInputCmds=[]
+ for root, dirs, files in os.walk("/var/lib/cas/snippets/"):
+ for name in files:
+ dir_listing.append(os.path.join(root, name))
+ for a in dir_listing:
+ crashInputCmds.append(Popen(a, stdout=PIPE).communicate()[0])
crashInputCmds.append("exit\n")
# Build crash input file
@@ -170,8 +166,8 @@ class UtilBase(object):
crashInputFH.close()
vmcorePath = os.path.join(dst, vmcore)
- crashCmd = "#!/bin/sh\n%s %s %s -s < %s\n" % (crash_bin, vmcorePath,
- debug, crashInputPath)
+ crashCmd = "#!/bin/sh\n%s %s %s $*\n" % (crash_bin, vmcorePath,
+ debug )
crashExe = os.path.join(dst,"crash")
fh = open(crashExe,"w")
fh.write(crashCmd)
diff --git a/setup.py b/setup.py
index 06cffd6..c8ef395 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,11 @@
"""
from distutils.core import setup
+
+libpath = "/var/lib/cas"
+snippetpath = libpath + "/snippets"
+
+
setup(
name = 'cas',
version = '0.13',
@@ -13,6 +18,14 @@ setup(
packages = ['cas',],
scripts = ['cas','cas-admin'],
package_dir = {'': 'lib',},
+
data_files = [ ('/etc', ['cas.conf']),
- ('/usr/share/man/man1',
['cas.1.gz','cas-admin.1.gz']) ]
+ # cas commands we'll ship
+ (snippetpath, ['snippets/sys']),
+ (snippetpath, ['snippets/log']),
+ (snippetpath, ['snippets/memory']),
+ (snippetpath, ['snippets/traceback']),
+ (snippetpath, ['snippets/template']),
+ (snippetpath, ['snippets/modules']),
+ ('/usr/share/man/man1',
['cas.1.gz','cas-admin.1.gz']) ]
)
diff --git a/snippets/log b/snippets/log
new file mode 100644
index 0000000..fd13de5
--- /dev/null
+++ b/snippets/log
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "log >> log"
diff --git a/snippets/memory b/snippets/memory
new file mode 100644
index 0000000..86885b4
--- /dev/null
+++ b/snippets/memory
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "kmem >> memory"
+echo "kmem -f >> memory"
diff --git a/snippets/modules b/snippets/modules
new file mode 100644
index 0000000..cae6c79
--- /dev/null
+++ b/snippets/modules
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "mod >> modules"
diff --git a/snippets/sys b/snippets/sys
new file mode 100644
index 0000000..179d1e7
--- /dev/null
+++ b/snippets/sys
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "sys >> sys"
+echo "sys -c >> sys"
diff --git a/snippets/template b/snippets/template
new file mode 100644
index 0000000..855ccca
--- /dev/null
+++ b/snippets/template
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Environmentals set by CAS
+# CAS_ARCH = Architecture of the given core
+# CAS_KERNEL = uname -r
+#
+#
+# if ( CAS_ARCH eq 'x86_64' )
+# echo "sys -c >> template"
+# fi
diff --git a/snippets/traceback b/snippets/traceback
new file mode 100644
index 0000000..2af2f78
--- /dev/null
+++ b/snippets/traceback
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "bt >> traceback"
+echo "bt -a >> traceback"