summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Cody <codeman@gentoo.org>2007-12-30 06:19:03 +0000
committerPreston Cody <codeman@gentoo.org>2007-12-30 06:19:03 +0000
commitda01a76bee1e6735c036baed76681dcfe9c3ca43 (patch)
tree844c7ee72ea90039813ed1004399d6ca4fd9bc98
parentadding in the DBI commands, commented out, to actually do stuff instead of fa... (diff)
downloadscire-da01a76bee1e6735c036baed76681dcfe9c3ca43.tar.gz
scire-da01a76bee1e6735c036baed76681dcfe9c3ca43.tar.bz2
scire-da01a76bee1e6735c036baed76681dcfe9c3ca43.zip
adding query for get_jobs from old server.
svn path=/branches/new-fu/; revision=282
-rwxr-xr-xserver/scireserver.pl28
1 files changed, 22 insertions, 6 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl
index 88f17a3..6dd9a8c 100755
--- a/server/scireserver.pl
+++ b/server/scireserver.pl
@@ -106,7 +106,7 @@ sub register_client {
#my @result = $sth->fetchrow_array();
#$status_id = $result[0];
};
- ($@) and print "ERROR Could not get status id: $DBI::errstr";
+ ($@) and print "ERROR Could not get status id: $DBI::errstr\n";
eval {
$query = 'LOCK TABLES `gacl_axo_seq` WRITE';
@@ -129,7 +129,7 @@ sub register_client {
debug("DEBUG: Query is $query");
#$dbh->do($query);
};
- ($@) and print "ERROR during fetching of id sequence: $DBI::errstr";
+ ($@) and print "ERROR during fetching of id sequence: $DBI::errstr\n";
eval {
$query = 'INSERT INFO `gacl_axo` (id,section_value,value,order_value,name,hidden VALUES (?,"clients",?,1,?,0)';
@@ -145,7 +145,7 @@ sub register_client {
#$sth = $dbh->prepare($query);
#$sth->execute($id,$digest,$hostname,$mac,$ip,$status_id);
};
- ($@) and print "ERROR Could not insert client with $query: $DBI::errstr";
+ ($@) and print "ERROR Could not insert client with $query: $DBI::errstr\n";
print "OK\n";
}
@@ -154,9 +154,10 @@ sub register_client {
#Identify the client by looking up the fingerprint in the database, and matching it up.
sub identify_client {
my $fingerprint = shift;
+ #Validate your inputs!
$fingerprint =~ s/"//g; #Clear the quotes.
$fingerprint =~ /^[A-Za-z0-9]+$/ or print "ERROR invalid fingerprint!\n";
- #Validate your inputs!
+
my $query = 'SELECT client_status.statusname FROM clients JOIN client_status on (clients.status = client_status.statusid) WHERE clients.digest=?';
debug("DEBUG: Query is $query");
#$sth = $dbh->prepare($query);
@@ -167,8 +168,23 @@ sub identify_client {
sub get_jobs {
my (@existing_jobs) = (@_);
#Validate your inputs!
-
- my $query;
+ foreach my $jobid (@existing_jobs) {
+ unless($jobid =~ /^\d$/) {
+ print "ERROR Invalid jobid given as input $jobid\n";
+ return undef;
+ }
+ }
+ my $query = <<'EndOfQuery'
+ SELECT jobs.jobid, jobs.priority, job_conditions.job_dependency, job_conditions.deploy_time, job_conditions.expiration_time, job_history.statusid
+ FROM jobs NATURAL JOIN jobs_clients NATURAL JOIN job_conditions NATURAL JOIN job_history
+ WHERE jobs_clients.clientid = %s
+ AND jobs.jobid = jobs_clients.jobid
+ AND (job_conditions.deploy_time < now())
+ AND (job_conditions.expiration_time > now())
+ AND job_history.statusid = '%s'
+ ORDER BY jobs.priority,jobs.created
+EndOfQuery
+
}
sub get_job {
my $job = shift;