Commit 0510282c authored by Christopher Alfeld's avatar Christopher Alfeld

Added:

tb-set-node-rpms
tb-set-node-startup
tb-set-node-cmdline

Also fixed bug with LAN loss in handle_os
parent ea3bf332
......@@ -168,6 +168,42 @@ if ($#ERRORS != -1) {
exit(1);
}
## 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\"");
$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\"");
$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\"");
$sth->execute;
$sth->finish;
}
# Let's do some output
# We allow running this on an IR file that has already been handle_os'ed
# it simply overwrites in that case.
......
......@@ -105,7 +105,7 @@ sub ir_read {
} else {
if ($contents{$cursec . '_'} eq 'dir') {
close FILE;
die "ERROR: (ir_read) Found data outside of section ($line)";
die "ERROR: (ir_read) Found data outside of section ($_)";
}
$curcontents .= join(' ',@line) . "\n";
}
......
......@@ -5,6 +5,9 @@
# TB commands handled:
# set-hardware
# set-link-loss
# set-node-cmdline
# set-node-rpms
# set-node-startup
#
# Configure variables
......@@ -91,6 +94,9 @@ open(TBCMD,$tbcmdfile) || do {
# hwtype is indexed by node and contains the type
# linkloss is indexed by src:dst and contains the loss rate
$cmdlines = ();
$startups = ();
$rpms = ();
while (<TBCMD>) {
chop;
@line = split;
......@@ -127,7 +133,7 @@ while (<TBCMD>) {
}
# linkloss(src:dst) = loss
$linkloss{$line[1]} = $line[2];
} elsif ($line[1] eq "tb-set-lan-loss") {
} elsif ($line[0] eq "tb-set-lan-loss") {
if ($#line != 2) {
push(@ERRORS,"Syntax: tb-set-lan-loss lan loss_rate");
} else {
......@@ -144,7 +150,38 @@ while (<TBCMD>) {
# lanloss(lan) = loss
$lanloss{$line[1]} = $line[2];
}
} elsif ($line[0] eq "tb-set-node-cmdline") {
if ($#line < 2) {
push(@ERRORS,"Syntax: tb-set-node-cmdline node cmdline");
next;
}
if (! defined($nodes{$line[1]})) {
push(@ERRORS,"$line[1] is not a valid node.");
next;
}
$cmdlines{$line[1]} = join(" ",@line[2..$#line]);
} elsif ($line[0] eq "tb-set-node-rpms") {
if ($#line < 2) {
push(@ERRORS,"Syntax: tb-set-node-rpms node rpms...");
next;
}
if (! defined($nodes{$line[1]})) {
push(@ERRORS,"$line[1] is not a valid node.");
next;
}
$rpms{$line[1]} = join(" ",@line[2..$#line]);
} elsif ($line[0] eq "tb-set-node-startup") {
if ($#line < 2) {
push(@ERRORS,"Syntax: tb-set-node-startup node startup");
next;
}
if (! defined($nodes{$line[1]})) {
push(@ERRORS,"$line[1] is not a valid node.");
next;
}
$startups{$line[1]} = join(" ",@line[2..$#line]);
}
}
close(TBCMD);
......@@ -211,3 +248,39 @@ if ($#newlans != -1) {
}
&ir_write($irfile);
# Add new sections
open(IRFILE,">> $irfile") || do {
print STDERR "Could not open $irfile\n";
exit(1);
};
print IRFILE "START rpms\n";
foreach $node (keys(%nodes)) {
if (defined($rpms{$node})) {
print IRFILE "$node $rpms{$node}\n";
} else {
print IRFILE "$node\n";
}
}
print IRFILE "END rpms\n";
print IRFILE "START startup\n";
foreach $node (keys(%nodes)) {
if (defined($startups{$node})) {
print IRFILE "$node $startups{$node}\n";
} else {
print IRFILE "$node\n";
}
}
print IRFILE "END startup\n";
print IRFILE "START cmdline\n";
foreach $node (keys(%nodes)) {
if (defined($cmdlines{$node})) {
print IRFILE "$node $cmdlines{$node}\n";
} else {
print IRFILE "$node\n";
}
}
print IRFILE "END cmdline\n";
close IRFILE;
......@@ -78,10 +78,18 @@ proc tb-set-lan-loss {lan rate} {
global TBCMD nodeid_map prefix
puts $TBCMD "tb-set-lan-loss $prefix-$nodeid_map($lan) $rate"
}
# The following commands are not clearly defined and probably will be
# changed or removed
proc tb-set-node-deltas {node deltas} {}
proc tb-set-node-cmdline {node cmdline} {
global TBCMD nodeid_map
puts $TBCMD "tb-set-node-cmdline $nodeid_map($node) $cmdline"
}
proc tb-set-node-rpms {node args} {
global TBCMD nodeid_map
puts $TBCMD "tb-set-node-rpms $nodeid_map($node) $args"
}
proc tb-set-node-startup {node cmd} {
global TBCMD nodeid_map
puts $TBCMD "tb-set-node-startup $nodeid_map($node) $cmd"
}
# Show that we have loaded
set TB_COMPACT 1
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