cas | 79 ++++++++++++++++++++++++++++++++++++---------------------------
cas.spec | 1
2 files changed, 46 insertions(+), 34 deletions(-)
New commits:
commit b20a2757b24840d03b5f200b993dcbd3cff22082
Author: Adam Stokes <adam(a)conans.battleaxe>
Date: Sun Dec 14 17:48:54 2008 -0500
- removed func requirement
- added code to handle processing the core on the machine cas
is ran from if architecture's match. otherwise we attempt to
use func and in worse case finish job without processing core
through crash
diff --git a/cas b/cas
index a4b15bb..32cc964 100755
--- a/cas
+++ b/cas
@@ -21,6 +21,8 @@ import ConfigParser
import shutil
import smtplib
+from subprocess import Popen, PIPE
+
from cas.network import Download
from cas.core import CoreBase, CoreException
from cas.util import UtilBase, dprint, cprint
@@ -147,40 +149,51 @@ class CasApplication(object):
debugKernel = os.path.abspath(debugKernel)
# setup crash file to finalize the processing of the core file
self.util.buildCrashFile(self.storagePath, corefile, debugKernel)
- # If func is installed we will pre-process the output from crash on
- # a random machine tied to the architecture of the debug file.
- # If no servers exists in your setup then this will return and
- # finish with just a location of the data.
- try:
- import func.overlord.client as fc
- # Pull the architecture from the elf file to match up with a
- # server providing this architecture
- debugKernelArch = self.util.debugKernelArch(debugKernel)
- cprint("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
- casProcessMachine = serverList[debugKernelArch][0]
- cprint("Machine %s found, processing crash output" %
(casProcessMachine,))
- cmd = os.path.join(self.storagePath,"crash")
- client = fc.Overlord(casProcessMachine)
- client_dict = client.command.run(cmd)
- # Only necessary for debugging why running of crash failed.
- # (sts, out, err) = client_dict[client_dict.keys()[0]]
+ # Pull the architecture from the elf file to match up with a
+ # server providing this architecture
+ debugKernelArch = self.util.debugKernelArch(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()
+ if not debugKernelArch == currentMachineArch:
+ # The machine running cas isn't capable of processing this core, lets
+ # attempt with Func. Assuming Func is installed and a server database
+ # is configured we attempt to process the core at another machine.
+ try:
+ import func.overlord.client as fc
+ cprint("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
+ casProcessMachine = serverList[debugKernelArch][0]
+ cprint("Machine %s found, processing crash output" %
(casProcessMachine,))
+ cmd = os.path.join(self.storagePath,"crash")
+ client = fc.Overlord(casProcessMachine)
+ client_dict = client.command.run(cmd)
+ # Only necessary for debugging why running of crash failed.
+ # (sts, out, err) = client_dict[client_dict.keys()[0]]
+ else:
+ cprint("No servers available for arch, please run cas-admin
-h " \
+ "for more information")
+ cprint("Attempting a local query.")
else:
- cprint("No servers available for arch, please run cas-admin -h
" \
- "for more information")
- cprint("Continueing without processing core.")
- else:
- cprint("No servers database found, please run cas-admin -h for
" \
- "more information")
- sys.exit(1)
- # TODO: Possibly handle this exception more gracefully?
- except ImportError:
- cprint("You need to install func (
http://fedorahosted.org/func if you
"\
- "wish to have the data processed automatically.")
+ cprint("No servers database found, please run cas-admin -h for
" \
+ "more information")
+ sys.exit(1)
+ # DONE: Possibly handle this exception more gracefully?
+ except ImportError:
+ cprint("Current running machine is not suitable for processing this
core " \
+ "and
http://fedorahosted.org/func is not installed/configured
properly.")
+ cprint("Finishing job without processing the core, please find a
suitable %s "\
+ "machine in order to view this core in crash." %
(debugKernelArch,))
+ else:
+ # The machine is suitable for processing the core through crash.
+ cmd = os.path.join(self.storagePath,"crash")
+ # TODO: capture any errors returned from crash when processing core.
+ cmdPipe = Popen([cmd],stdout=PIPE, stderr=PIPE)
crashOutFile = os.path.join(self.storagePath,"crash.out")
if os.path.isfile(crashOutFile):
cprint("Crash output processed, sending email to %s" %
(self.email,))
diff --git a/cas.spec b/cas.spec
index 8d7e14d..007d03f 100644
--- a/cas.spec
+++ b/cas.spec
@@ -13,7 +13,6 @@ BuildArch: noarch
Url:
http://fedorahosted.org/cas
BuildRequires: python-devel
Requires: python >= 2.4
-Requires: func
%description
CAS provides a support engineer the ability to configure an environment for