Select Git revision
nsgenilib.py.in
Forked from
emulab / emulab-devel
Source project has a limited visibility.
step4_newids.pl 15.45 KiB
#!/usr/bin/perl -w
#
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file 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 Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use English;
use lib "/usr/testbed/lib";
use libdb;
use libtestbed;
#
# Untaint the path
#
$ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
my %new_osids = ();
my %new_imageids = ();
my $index = 100;
#
# See if a table has been changed by looking for the existence of a field.
#
sub TableChanged($$)
{
my ($table, $slot) = @_;
my $describe_result =
DBQueryFatal("describe $table $slot");
return $describe_result->numrows;
}
DBQueryFatal("drop table if exists ".
" temp_images, temp_os_info, temp_o2i, ".
" temp_osid_map, temp_partitions, temp_nodes, ".
" temp_attributes, temp_cur_reloads, temp_sched_reloads");
DBQueryFatal("create table temp_os_info like os_info");
DBQueryFatal("create table temp_images like images");
DBQueryFatal("create table temp_o2i (".
" `osid` int(8) unsigned NOT NULL default '0',".
" `type` varchar(30) NOT NULL default '', ".
" `imageid` int(8) unsigned NOT NULL default '0', ".
" PRIMARY KEY (`osid`,`type`) ".
" ) ENGINE=MyISAM DEFAULT CHARSET=latin1");
DBQueryFatal("create table temp_osid_map (".
" `osid` int(8) unsigned NOT NULL default '0',".
" `btime` datetime NOT NULL default '1000-01-01 00:00:00', ".
" `etime` datetime NOT NULL default '9999-12-31 23:59:59', ".
" `nextosid` int(8) unsigned NOT NULL default '0', ".