Commit 9a449cbc authored by Mac Newbold's avatar Mac Newbold

No longer used by anything... just cruft lying around. Moved to attic...

parent 21273c58
#
# Insert Copyright Here.
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = tbsetup/ir
include $(OBJDIR)/Makeconf
LIB_STUFF = libir.tcl libir.pm
LIBEXEC_STUFF = assign_wrapper handle_os handle_ip postassign extract_tb
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(LIB_STUFF) $(LIBEXEC_STUFF)
include $(TESTBED_SRCDIR)/GNUmakerules
install: $(addprefix $(INSTALL_LIBDIR)/ir/, $(LIB_STUFF)) \
$(addprefix $(INSTALL_LIBEXECDIR)/ir/, $(LIBEXEC_STUFF))
$(INSTALL_LIBDIR)/ir/%: %
@echo "Installing $<"
-mkdir -p $(INSTALL_LIBDIR)/ir
$(INSTALL) $< $@
$(INSTALL_LIBEXECDIR)/ir/%: %
@echo "Installing $<"
-mkdir -p $(INSTALL_LIBEXECDIR)/ir
$(INSTALL) $< $@
clean:
#!/usr/bin/perl -w
# This handles all the OS TB commands:
# set-node-os
# Yet to do:
# Any sort of delta support
#
# Configure variables
#
my $IRLIB = "@prefix@/lib/ir";
my $DBNAME = "@TBDBNAME@";
push(@INC, $IRLIB);
require libir;
if ($#ARGV != 0) {
print STDERR "Syntax: $0 ir_file\n";
exit 1;
}
$irfile = $ARGV[0];
use DBI;
$driver = "mysql";
$dbh = DBI->connect("DBI:$driver:database=$DBNAME;host=localhost")
|| die "Could not connect to DB.\n";
# List of ERROR messages
@ERRORS = ();
# read IR file
eval {&ir_read($irfile)};
if ($@) {
print STDERR "Could not read $irfile ($@)\n";
exit(1);
}
# Load the node types and grab the default OS from the database
# %nodetype is indexed by virtual node id and contains the type
# %ostype is indexed by type and contains the default OS
# $delayos is the delay os, currently assumed to be os of PC's
# XXX - Should grab this from the DB eventually
$delayos = "FBSD40-STD";
$delaytype = "pc600";
$raw = eval {&ir_get("/topology/nodes")};
if ($@) {
print STDERR "Could not load /topology/nodes.\n";
exit(1);
}
foreach (split("\n",$raw)) {
@info = split;
$node = $info[0];
$type = $info[1];
$nodetype{$node} = $type;
if (! defined($ostype{$type})) {
$sth = $dbh->prepare("SELECT osid from node_types ".
"where type=\"$type\"");
$rr = $sth->execute;
if ($rr == 0) {
push(@ERRORS,"Invalid type $type");
$ostype{$type} = "INVALID";
} else {
@result = $sth->fetchrow_array;
$ostype{$type} = $result[0];
}
$sth->finish;
}
}
# Load the nodemap and set up an initial os table
# nodemap is indexed by virtual node id and contains the physical node id
# os is indexed by physical node id and contains the osid
$raw = eval {&ir_get("/virtual/nodes")};
if ($@) {
print STDERR "Could not load /virtual/nodes. Run assign first.\n";
exit(1);
}
foreach (split("\n",$raw)) {
($virtual,$physical) = split;
$nodemap{$virtual} = $physical;
if (!defined($nodetype{$virtual})) {
# assume to be a delay node.
$os{$physical} = $delayos;
$nodetype{$virtual} = $delaytype;
} else {
$os{$physical} = $ostype{$nodetype{$virtual}};
}
}
#
# Read in the osid section. We overwrite the default for any node listed
# in the osid section.
#
if (! &ir_exists("/osid")) {
print STDERR "IR incomplete: No /osid.\n";
exit(1);
}
foreach (split("\n",&ir_get("/osid"))) {
my ($node,$osid) = /^([^ ]+)(.*)$/;
$osid =~ s/^ //;
$os{$nodemap{$node}} = $osid;
}
#
# Now verify that the OSID is valid and appropriate for the node type.
#
# os_path is indexed by physical node id and contains the path.
#
foreach my $virt (keys(%nodemap)) {
my $phys = $nodemap{$virt};
my $osid = $os{$phys};
$sth = $dbh->prepare("SELECT machinetype,path FROM os_info ".
"where osid = \"$osid\"");
$rr = $sth->execute;
if ($rr == 0) {
# Bad OSID
$sth->finish;
push(@ERRORS,"Unknown OSID: $osid");
next;
}
@result = $sth->fetchrow_array;
$sth->finish;
$valid_type = $result[0];
if ($nodetype{$virt} ne $valid_type) {
push(@ERRORS, "Node $virt is type $nodetype{$virt}, ".
"but $osid is for $valid_type.\n");
next;
}
$os{$phys} = $osid;
if (defined($result[1])) {
$os_path{$phys} = $result[1];
}
else {
$os_path{$phys} = "";
}
}
# Check if we're good so far
if ($#ERRORS != -1) {
foreach (@ERRORS) {
print STDERR $_ . "\n";
}
exit(1);
}
#
# Now update the nodes table in DB.
#
foreach my $virt (keys(%nodemap)) {
my $phys = $nodemap{$virt};
my $osid = $os{$phys};
my $path = $os_path{$phys};
$sth = $dbh->prepare("UPDATE nodes set def_boot_osid = \"$osid\", ".
"def_boot_path = \"$path\" ".
"where node_id = \"$phys\"");
$sth->execute;
$sth->finish;
}
## Handle cmdline/startup/etc.
if (! &ir_exists("/cmdline")) {
print STDERR "IR incomplete: No /cmdline.\n";
exit(1);
}
foreach (split("\n",&ir_get("/cmdline"))) {
($node,$cmdline) = /^([^ ]+)(.*)$/;
$cmdline =~ s/^ //;
$sth = $dbh->prepare("UPDATE nodes set def_boot_cmd_line = \"$cmdline\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
if (! &ir_exists("/startup")) {
print STDERR "IR incomplete: No /startup.\n";
exit(1);
}
foreach (split("\n",&ir_get("/startup"))) {
($node,$cmdline) = /^([^ ]+)(.*)$/;
$cmdline =~ s/^ //;
$sth = $dbh->prepare("UPDATE nodes set startupcmd = \"$cmdline\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
if (! &ir_exists("/rpms")) {
print STDERR "IR incomplete: No /rpms.\n";
exit(1);
}
foreach (split("\n",&ir_get("/rpms"))) {
($node,$rpms) = /^([^ ]+)(.*)$/;
$rpms =~ s/^ //;
$rpms =~ s/ /:/g;
$sth = $dbh->prepare("UPDATE nodes set rpms = \"$rpms\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
if (! &ir_exists("/tarfiles")) {
print STDERR "IR incomplete: No /tarfiles.\n";
exit(1);
}
foreach (split("\n",&ir_get("/tarfiles"))) {
my $tarfiles = "";
($node,$dirsandfiles) = /^([^ ]+)(.*)$/;
$dirsandfiles =~ s/^ //;
@line = split(" ", $dirsandfiles);
while (@line) {
$dir = shift(@line);
$tar = shift(@line);
if ($tarfiles eq "") {
$tarfiles = "$dir $tar";
}
else {
$tarfiles = "$tarfiles:$dir $tar";
}
}
$sth = $dbh->prepare("UPDATE nodes set tarballs = \"$tarfiles\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
if (! &ir_exists("/deltas")) {
print STDERR "IR incomplete: No /deltas.\n";
exit(1);
}
foreach (split("\n",&ir_get("/deltas"))) {
($node,$deltas) = /^([^ ]+)(.*)$/;
$deltas =~ s/^ //;
$deltas =~ s/ /:/g;
$sth = $dbh->prepare("UPDATE nodes set deltas = \"$deltas\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
foreach (values(%nodemap)) {
$node = $_;
$sth = $dbh->prepare("UPDATE nodes set ready=0,startstatus = \"none\" ".
"where node_id = \"$node\"");
$sth->execute;
$sth->finish;
}
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