Commit ec6f8f3f authored by Leigh Stoller's avatar Leigh Stoller

Rename node_reservations to project_reservations; better name and I

need node_reservations for, well, node_reservations.
parent d590eb18
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2015 University of Utah and the Flux Group.
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -3664,7 +3664,7 @@ sub CheckPreReserve($$)
my $type = $self->type();
my $node_id = $self->node_id();
DBQueryWarn("lock tables node_reservations write, nodes write")
DBQueryWarn("lock tables project_reservations write, nodes write")
or return undef;
#
......@@ -3673,8 +3673,8 @@ sub CheckPreReserve($$)
#
my $query_result =
DBQueryWarn("select reserved_pid,count,active from nodes ".
"left join node_reservations on ".
" node_reservations.pid=nodes.reserved_pid ".
"left join project_reservations on ".
" project_reservations.pid=nodes.reserved_pid ".
"where nodes.node_id='$node_id'");
goto done
......@@ -3700,7 +3700,7 @@ sub CheckPreReserve($$)
# Find only active unfilled reservations.
$query_result =
DBQueryWarn("select pid,count from node_reservations ".
DBQueryWarn("select pid,count from project_reservations ".
"where active=1 and count>0 and ".
" (types is null or ".
" FIND_IN_SET('$type', types)) ".
......@@ -3716,7 +3716,7 @@ sub CheckPreReserve($$)
if (DBQueryWarn("update nodes set reserved_pid='$pid' ".
"where node_id='$node_id'")) {
DBQueryWarn("update node_reservations set count=count-1 ".
DBQueryWarn("update project_reservations set count=count-1 ".
"where pid='$pid'");
$result = $pid;
......
......@@ -3025,26 +3025,6 @@ CREATE TABLE `node_licensekeys` (
PRIMARY KEY (`node_id`,`keytype`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `node_reservations`
--
DROP TABLE IF EXISTS `node_reservations`;
CREATE TABLE `node_reservations` (
`pid` varchar(48) NOT NULL default '',
`pid_idx` mediumint(8) unsigned NOT NULL default '0',
`priority` smallint(5) NOT NULL default '0',
`count` smallint(5) NOT NULL default '0',
`types` varchar(128) default NULL,
`creator` varchar(8) NOT NULL default '',
`creator_idx` mediumint(8) unsigned NOT NULL default '0',
`created` datetime default NULL,
`start` datetime default NULL,
`end` datetime default NULL,
`active` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`pid_idx`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `node_rusage`
--
......@@ -3997,6 +3977,26 @@ CREATE TABLE `project_quotas` (
UNIQUE KEY `qpid` (`pid`,`quota_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `project_reservations`
--
DROP TABLE IF EXISTS `project_reservations`;
CREATE TABLE `project_reservations` (
`pid` varchar(48) NOT NULL default '',
`pid_idx` mediumint(8) unsigned NOT NULL default '0',
`priority` smallint(5) NOT NULL default '0',
`count` smallint(5) NOT NULL default '0',
`types` varchar(128) default NULL,
`creator` varchar(8) NOT NULL default '',
`creator_idx` mediumint(8) unsigned NOT NULL default '0',
`created` datetime default NULL,
`start` datetime default NULL,
`end` datetime default NULL,
`active` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`pid_idx`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `project_stats`
--
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBTableExists("project_reservations")) {
DBQueryFatal("rename table node_reservations to project_reservations");
}
return 0;
}
# Local Variables:
# mode:perl
# End:
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -235,7 +235,7 @@ $EUID = 0;
# Then the project table itself, plus a few other bits and pieces
#
DBQueryFatal("delete FROM last_reservation where pid_idx='$pid_idx'");
DBQueryFatal("delete FROM node_reservations where pid_idx='$pid_idx'");
DBQueryFatal("delete FROM project_reservations where pid_idx='$pid_idx'");
DBQueryFatal("delete FROM nodetypeXpid_permissions where pid_idx='$pid_idx'");
DBQueryFatal("delete FROM project_stats where pid_idx='$pid_idx'");
DBQueryFatal("delete FROM group_stats where pid_idx='$pid_idx'");
......
......@@ -183,7 +183,7 @@ else {
#
if ($list) {
my $query_result =
DBQueryFatal("select *,(count>0) as needed from node_reservations ".
DBQueryFatal("select *,(count>0) as needed from project_reservations ".
"order by needed desc, priority desc, created asc");
if ($query_result->numrows) {
......@@ -261,7 +261,7 @@ if ($info) {
if ($nodes_result && $nodes_result->numrows);
my $query_result =
DBQueryFatal("select * from node_reservations ".
DBQueryFatal("select * from project_reservations ".
"where pid_idx='$pid_idx'");
if ($query_result->numrows) {
......@@ -331,7 +331,7 @@ if ($UID) {
# Clear and exit.
#
if ($clear) {
DBQueryFatal("delete from node_reservations where pid_idx='$pid_idx'");
DBQueryFatal("delete from project_reservations where pid_idx='$pid_idx'");
if ($revoke) {
DBQueryFatal("update nodes set reserved_pid=null ".
"where reserved_pid='$pid'");
......@@ -363,7 +363,7 @@ if (defined($typelist)) {
# Lets say that a current request is an error. delete and recreate.
#
my $query_result =
DBQueryFatal("select * from node_reservations where pid_idx='$pid_idx'");
DBQueryFatal("select * from project_reservations where pid_idx='$pid_idx'");
if ($query_result->numrows) {
fatal("Already have a reservation request for $pid, please clear it first");
......@@ -384,7 +384,7 @@ if ($endtime) {
my $tmp = str2time($endtime);
$endarg = ",end=FROM_UNIXTIME($tmp)";
}
DBQueryFatal("insert into node_reservations set ".
DBQueryFatal("insert into project_reservations set ".
" pid='$pid', pid_idx='$pid_idx', count='$count', ".
" creator='$uid', creator_idx='$uid_idx', ".
" created=now(),active=0 $typearg $startarg $endarg");
......@@ -408,10 +408,10 @@ sub StartReservation($)
my ($pid) = @_;
DBQueryFatal("lock tables nodes write, node_types read, ".
" node_reservations write, reserved read");
" project_reservations write, reserved read");
my $query_result =
DBQueryFatal("select * from node_reservations where pid='$pid'");
DBQueryFatal("select * from project_reservations where pid='$pid'");
if (!$query_result->numrows) {
fatal("No reservation defined for project");
}
......@@ -521,7 +521,7 @@ sub StartReservation($)
$count -= $current;
$count = 0 if ($count < 0);
DBQueryFatal("update node_reservations set ".
DBQueryFatal("update project_reservations set ".
" count='$count',active=1 ".
"where pid='$pid'");
DBQueryFatal("unlock tables");
......
#!/usr/bin/perl -w
#
# Copyright (c) 2003-2014 University of Utah and the Flux Group.
# Copyright (c) 2003-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -86,7 +86,7 @@ usage()
# Look for active pre reserves that need to be terminated.
#
my $query_result =
DBQueryFatal("select * from node_reservations ".
DBQueryFatal("select * from project_reservations ".
"where end is not null and ".
" UNIX_TIMESTAMP(now()) > UNIX_TIMESTAMP(end)");
......@@ -117,7 +117,7 @@ while (my $row = $query_result->fetchrow_hashref()) {
# Look for inactive pre reserves that need to be activated.
#
$query_result =
DBQueryFatal("select * from node_reservations ".
DBQueryFatal("select * from project_reservations ".
"where active=0 and start is not null and ".
" UNIX_TIMESTAMP(now()) >= UNIX_TIMESTAMP(start) ".
"order by priority desc, created asc");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment