cas | 32 +++++++++++++++++++-------------
cas-admin | 9 +++++++--
cas.spec | 3 ++-
lib/cas/core.py | 2 +-
lib/cas/db.py | 11 ++++++-----
5 files changed, 35 insertions(+), 22 deletions(-)
New commits:
commit b010cac60401854ed7a458d83138b9e057f42a9f
Author: adam stokes <uzr(a)jak.rebo>
Date: Thu Oct 15 13:52:10 2009 -0400
- still ironing out ssh details :(
diff --git a/cas b/cas
index 3e3ade1..36d40c4 100755
--- a/cas
+++ b/cas
@@ -20,11 +20,12 @@ import os
import ConfigParser
import smtplib
import socket
+import paramiko
from cas.cas_subprocess import Popen, PIPE
from datetime import datetime
-from cas.network import Download, Executor, CasNetworkException
+from cas.network import Download, CasNetworkException
from cas.core import CoreBase, CoreException
from cas.db import CasStorage, CasStorageException
from cas.util import UtilBase, Logging
@@ -167,7 +168,7 @@ class CasApplication(object):
# so we base the hierarchy /workDirectory/identifier/datetime
datenow = datetime.now()
dateFormatted = datenow.strftime("%Y.%m.%d.%I.%M.%S")
- self.storagePath = os.path.join(WORKDIRECTORY, self.identifier)
+ self.storagePath = os.path.join(settings["WORKDIRECTORY"], self.identifier)
self.storagePath = os.path.join(self.storagePath, dateFormatted)
# build logger object to deal with logging per job and keep things
@@ -264,22 +265,27 @@ class CasApplication(object):
self.casLog.info("Crash file built, locating suitable %s system for " \
"processing" % (debugKernelArch,))
serverList = self.db.getServers()
+ ssh_obj = paramiko.SSHClient()
+ ssh_obj.load_host_keys(os.path.expanduser("~/.ssh/known_hosts"))
if serverList:
- for hostname, arch in serverList:
+ for hostname, arch, port in serverList:
if arch == debugKernelArch:
# TODO: Randomize server selection
- casProcessMachine = hostname
self.casLog.info("Machine %s found, processing " \
- "crash output" % (casProcessMachine,))
+ "crash output" % (hostname,))
cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
- # TODO: run command through paramiko
- results, err = Executor(hostname, settings["CASUSER"], cmd).run()
- if err:
- self.casLog.debug("Unable to perform results")
- else:
- self.casLog.info("No servers available for arch and current system not "\
- "suitable for processing, please run cas-admin -h " \
- "for more information")
+ try:
+ ssh_obj.connect(hostname, port=port, username=settings["CASUSER"])
+ except:
+ raise SystemExit(self.casLog.debug("Failed to connect to %s" % (hostname,)))
+ ssh_obj.exec_command(cmd)
+ if stderr:
+ self.casLog.debug(stderr)
+ break
+ else:
+ self.casLog.info("No servers available for arch and current system not "\
+ "suitable for processing, please run cas-admin -h " \
+ "for more information")
else:
raise SystemExit(self.casLog.info("No servers database found, please run cas-admin -h for " \
"more information"))
diff --git a/cas-admin b/cas-admin
index ec98ead..ca154a4 100755
--- a/cas-admin
+++ b/cas-admin
@@ -45,6 +45,11 @@ if config.has_section("settings"):
PURGELIMIT = config.get("maintenance","purgeLimit")
AUTOPURGE = config.getboolean("maintenance","autoPurge")
+# advance options
+BUFFERSIZE=None
+if config.has_option("advanced", "buffersize"):
+ BUFFERSIZE=config.get("advanced", "buffersize")
+
class CasDatabaseHandler(object):
def __init__(self, logger):
self.casLog = logger
@@ -87,7 +92,7 @@ class CasDatabaseHandler(object):
vmlinux = item.strip()
stamper = CoreBase()
debugKernel = os.path.normpath(vmlinux)
- timestamp = stamper.timestamp(debugKernel)
+ timestamp = stamper.timestamp(debugKernel, BUFFERSIZE)
# add rpm id, debug, timestamp to database
self.db.addTimestamp(id, debugKernel, timestamp)
# Cleanup extracted debugs
@@ -131,7 +136,7 @@ class CasServerHandler(object):
# clean up arch string
for i in stdout.readlines():
arch = i.strip()
- self.db.addServer(server, arch)
+ self.db.addServer(server, port, arch)
hostname_count = hostname_count + 1
self.casLog.info("Server database built with %d server(s) added." % (hostname_count,))
return
diff --git a/cas.spec b/cas.spec
index cc57342..733e717 100644
--- a/cas.spec
+++ b/cas.spec
@@ -49,9 +49,10 @@ rm -rf ${RPM_BUILD_ROOT}
%doc AUTHORS LICENSE README PKG-INFO doc/*
%changelog
-* Tue Sep 15 2009 Adam Stokes <ajs at redhat dot com> - 0.15-1
+* Thu Oct 15 2009 Adam Stokes <ajs at redhat dot com> - 0.15-1
- Require paramiko for all remote executions
- Rip out func code
+- Documentation update to include ssh setup
* Tue May 5 2009 Adam Stokes <ajs at redhat dot com> - 0.14-8
- support for purging old data
diff --git a/lib/cas/core.py b/lib/cas/core.py
index 010ad6f..d6a9bbe 100644
--- a/lib/cas/core.py
+++ b/lib/cas/core.py
@@ -93,7 +93,7 @@ class CoreBase(object):
return True
return False
- def timestamp(self, path, blksize):
+ def timestamp(self, path, blksize=None):
""" captures fingerprint from core
"""
match='Linux\sversion.*20\d{1,2}|#1\s.*20\d{1,2}'
diff --git a/lib/cas/db.py b/lib/cas/db.py
index c41683b..f88c37b 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -54,6 +54,7 @@ class CasStorage(object):
self.cursor.execute("""create table server (
server_id integer primary key autoincrement,
arch text,
+ port text,
hostname text)
""")
self.commit()
@@ -120,16 +121,16 @@ class CasStorage(object):
return
# SERVER METHODS
- def addServer(self, hostname, arch):
+ def addServer(self, hostname, port, arch):
""" add server/arch to db """
- values = (hostname, arch)
+ values = (hostname, port, 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)
+ self.cursor.execute('''INSERT into server (hostname, arch, port)
+ values ("%s","%s","%s")''' % values)
self.commit()
return
def getServers(self):
- self.cursor.execute('select hostname, arch from server')
+ self.cursor.execute('select hostname, port, arch from server')
return self.cursor.fetchall()