delvnodes.pl 909 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/perl -w
use English;
use Errno;

use lib "/usr/testbed/lib";
use libdb;
use libtestbed;

DBQueryFatal("lock tables reserved write, nodes write");

my $query_result =
    DBQueryFatal("select nodes.node_id from nodes ".
		 "left join reserved on nodes.node_id=reserved.node_id ".
		 "where reserved.node_id is null and ".
		 "      (nodes.type='pcvm' or nodes.type='pcplab')");

while (my ($vnodeid) = $query_result->fetchrow_array()) {
    DBQueryWarn("delete from reserved where node_id='$vnodeid'");
    DBQueryWarn("delete from nodes where node_id='$vnodeid'");
}

DBQueryFatal("unlock tables");

$query_result->dataseek(0);

while (my ($vnodeid) = $query_result->fetchrow_array()) {
    DBQueryWarn("delete from node_hostkeys where node_id='$vnodeid'");
    DBQueryWarn("delete from node_status where node_id='$vnodeid'");
    DBQueryWarn("delete from node_rusage where node_id='$vnodeid'");
}