cas.spec | 9 +++++++--
caslib/db.py | 2 +-
overseer/command.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
restful/restful.pl | 33 ---------------------------------
4 files changed, 58 insertions(+), 36 deletions(-)
New commits:
commit 3272de9f6be2e34b1a393a45a092414f10678ad6
Author: adam stokes <astokes(a)fedoraproject.org>
Date: Mon Apr 26 14:28:42 2010 -0400
pushing out cherrypy handler
diff --git a/cas.spec b/cas.spec
index c77f6a4..7d7cef9 100644
--- a/cas.spec
+++ b/cas.spec
@@ -12,10 +12,15 @@ BuildArch: noarch
Url:
http://fedorahosted.org/cas
BuildRequires: python-devel
%if 0%{?rhel}
-Requires: python-sqlite crash python-paramiko xz
+Requires: python-sqlite python-paramiko
%else
-Requires: crash python-paramiko xz
+Requires: python-paramiko
%endif
+Requires: xz
+Requires: crash
+Requires: python-cherrypy
+Requires: simplejson
+Requires: urlgrabber
%description
CAS provides a user the ability to configure an environment for core analysis
diff --git a/caslib/db.py b/caslib/db.py
index f88c37b..43582b2 100644
--- a/caslib/db.py
+++ b/caslib/db.py
@@ -95,7 +95,7 @@ class CasStorage(object):
# JOB METHODS
def getAllJobs(self):
- """ all jobs """
+ """ return all current running jobs """
self.cursor.execute('SELECT * FROM jobs')
return self.cursor.fetchall()
diff --git a/overseer/__init__.py b/overseer/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/overseer/command.py b/overseer/command.py
new file mode 100644
index 0000000..84d2e9d
--- /dev/null
+++ b/overseer/command.py
@@ -0,0 +1,50 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+
+import cherrypy
+import simplejson as json
+import ConfigParser
+import datetime
+import urlgrabber.grabber as grabber
+from caslib.db import CasStorage
+
+class Delegate:
+ def __init__(self):
+ cfg = ConfigParser.ConfigParser()
+ cfg.read("/etc/cas.conf")
+ db_file = cfg.get("settings", "database")
+ self.db = CasStorage(db_file)
+
+ @cherrypy.expose
+ def index(self):
+ """ Catchall call; returns current running jobs
"""
+ return json.dumps(self.db.getAllJobs())
+
+ @cherrypy.expose
+ def create(self, vmcore, email):
+ """ Create job """
+ datenow = datetime.now()
+ dateFormatted = datenow.strftime("%Y.%m.%d.%I.%M.%S")
+ try:
+ grabber(vmcore)
+ except grabber.URLGrabError, e:
+ return json.dumps(e)
+ self.db.addJob(id, dateFormatted, email)
+ return json.dumps(id)
+
+ @cherrypy.expose
+ def status(self, id):
+ """ Return job status """
+ pass
+
+cherrypy.quickstart(Delegate())
commit e2db183679a65df51f487b5091d04e98c5833e8f
Author: adam stokes <astokes(a)fedoraproject.org>
Date: Mon Apr 26 14:02:14 2010 -0400
rm restful
diff --git a/restful/restful.pl b/restful/restful.pl
deleted file mode 100755
index a62bee9..0000000
--- a/restful/restful.pl
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/perl
-use 5.010;
-use strict;
-use warnings;
-use CGI qw(:standard);
-use JSON;
-use Config::IniFiles;
-use Data::Dumper;
-
-# setup json
-my $json = JSON->new->allow_nonref;
-
-# location of CAS configuration file
-my $cas_conf = "/etc/cas.conf";
-
-# load configuration
-my $cfg = new Config::IniFiles( -file => $cas_conf ) or die "Can not load
config";
-
-# start access to web service
-my %actions = map {$_=>1} param('action');
-
-if ($actions{jobs}) {
- print header('application/json');
- job();
-}
-
-print header();
-
-sub job {
- my @t_array = qw(hi test name wtf);
- print $json->to_json(\@t_array);
- exit 0;
-}