Commit fd9145e5 authored by Mac Newbold's avatar Mac Newbold

First round of changes for new shark names. We now can reserve, free,

and power control sharks correctly (a shelf at a time). We also feed the
new shark names to assign in the ptop file. Showgraph was also changed
to reflect db changes.
parent 4fa88f91
......@@ -32,7 +32,7 @@ $sth = $dbh->query($cmd);
if ( ($sth->numrows < 1) && ($UID != 0) && ($EUID != 0)) {
die("You are not a member of experiment '$eid' in project '$pid'.\n");
}
$cmd = "lock tables nodes read, reserved write";
$sth = $dbh->query($cmd)
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
......@@ -58,8 +58,21 @@ foreach my $n (@node_names) {
next;
} else {
# No one has reserved it, and it exists, so add it to my list
push(@vals,"('$n','$pid','$eid')");
push(@nodes,"$n");
if ($n =~ /(sh\d+)/ ) {
# its a shark - do the whole shelf if its not done already.
my $shelf = $1;
if ( ! (join(",",@nodes) =~ /,$shelf-\d,/)) {
# Shelf hasn't been done yet...
foreach my $n ( 1 .. 8 ) {
push(@vals,"('$shelf-$n','$pid','$eid')");
push(@nodes,"$shelf-$n");
}
}
} else {
# its not a shark - just add it in...
push(@vals,"('$n','$pid','$eid')");
push(@nodes,"$n");
}
}
}
}
......@@ -79,10 +92,22 @@ $cmd = "unlock tables";
$sth = $dbh->query($cmd)
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
my @sharks=();
if (!$error && @nodes) {
foreach $n ( @nodes ) {
system("$consetup $n") == 0 or
print STDERR "WARNING: $consetup $n failed!\n";
if ($n =~ /(sh\d+)/) {
# Its a shark - do the shelf if it hasn't been done yet
my $shelf = $1;
if (!(join(",",@sharks) =~ /\b$shelf\b/)) {
push (@sharks,$shelf);
system("$consetup $shelf") == 0 or
print STDERR "WARNING: $consetup $shelf failed!\n";
}
} else {
system("$consetup $n") == 0 or
print STDERR "WARNING: $consetup $n failed!\n";
}
}
}
......
......@@ -22,9 +22,26 @@ my $reloadpid="testbed";
my $reloadeid="reloading";
my $pid = shift;
my $eid = shift;
my @node_names=@ARGV;
my @node_names=();
my @freed_nodes=();
foreach my $n (@ARGV) {
if ($n =~ /(sh\d+)/ ) {
# its a shark - do the whole shelf if its not done already.
my $shelf = $1;
if ( ! (join(",",@node_names) =~ /,$shelf-\d,/)) {
# Shelf hasn't been done yet...
foreach my $n ( 1 .. 8 ) {
push(@node_names,"$shelf-$n");
}
}
} else {
# its not a shark - just add it in...
push(@node_names,"$n");
}
}
my $cmd = "";
my $sth = "";
......@@ -76,7 +93,7 @@ foreach my $n (@node_names) {
$i++;
@reload = $sth->fetchrow_array();
my ($node, $part, $image, $path) = @reload;
if (! defined($reloads{"$image $part $path"})) {
my @list = ($node);
$reloads{"$image $part $path"} = \@list;
......@@ -96,7 +113,7 @@ foreach my $n (@node_names) {
&& $error++);
}
if (! ($n =~ /^tbsh/)) { #If its not a shark
if (! ($n =~ /sh\d+/)) { #If its not a shark
# Find the control net interface for this node type
$sth =
$dbh->query("select control_net from node_types left join ".
......@@ -109,6 +126,12 @@ foreach my $n (@node_names) {
$sth = $dbh->query($cmd)
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++);
} else {
# it is a shark, so clear out the alias(es)
$cmd = "update interfaces set IPalias='' where node_id='$n'";
$sth = $dbh->query($cmd)
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++);
}
# Clean out all delays
......@@ -161,9 +184,21 @@ if ( @reloaded > 0 ) {
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
}
my @sharks=();
foreach $n ( @freed_nodes ) {
system("$consetup $n") == 0 or
print STDERR "WARNING: $consetup $n failed!\n";
if ($n =~ /(sh\d+)/) {
# Its a shark - do the shelf if it hasn't been done yet
my $shelf = $1;
if (!(join(",",@sharks) =~ /\b$shelf\b/)) {
push (@sharks,$shelf);
system("$consetup $shelf") == 0 or
print STDERR "WARNING: $consetup $shelf failed!\n";
}
} else {
system("$consetup $n") == 0 or
print STDERR "WARNING: $consetup $n failed!\n";
}
}
exit($error);
......@@ -15,11 +15,11 @@ my $node;
while (<>) {
if (!/^\|/ ) {next;}
if ( /^\|node_id/) {next;}
/^\|([a-zA-Z0-9-]*) *\|/;
/^\|([a-zA-Z0-9]*).*\|/;
$node=$1;
if ($node =~/tbpc|tbsh/) {
if ($node =~/^(tbpc|sh)/) {
print STDERR "Got '$node' \t" if $d && !defined ($nodes{$node});
$nodes{$node} = 1;
print STDERR "Got '$node' \t" if $d;
}
}
......@@ -27,23 +27,28 @@ print STDERR "\n" if $d;
my @list = sort keys %nodes;
foreach my $item (@list) {
print STDERR "From '$item'\t" if $d;
$item = "node_id='$item'";
print STDERR "To '$item'\n" if $d;
print STDERR "From '$item'\t" if $d > 1;
if ($item =~ /^sh/) { # If its a shark
$item = "node_id='$item-1'";
} else {
$item = "node_id='$item'";
}
print STDERR "To '$item'\n" if $d > 1;
}
my $cond = join (" or ",@list);
my $query = "select node_id,card,MAC from interfaces where $cond";
print STDERR "Using query '$query'\n" if $d;
print STDERR "\nUsing query '$query'\n\n" if $d;
my $sth = $dbh->query($query);
while (my @row = $sth->fetchrow()) {
if ( $row[0] =~ /tbpc/ ) {
$links{$row[0]."-".$row[1]} = $row[2];
print STDERR "Got '$row[0]'\t'$row[1]'\t'$row[2]'\n" if $d > 1;
if ( $row[0] =~ /^(sh\d+)-\d/ ) {
$links{$1} = $row[2];
} else {
$links{$row[0]} = $row[2];
$links{$row[0]."-".$row[1]} = $row[2];
}
}
......
#!/usr/local/bin/perl -w
if ($#ARGV >= 1) {
if ($#ARGV >= 1 || $#ARGV < 0) {
#Help mode
print "Usage: showgraph [display]\n";
print "\n";
......@@ -18,7 +18,8 @@ if ($#ARGV >= 1) {
print "in the actual database, and is always current.\n";
print "\n";
print "If you get an 'Unable to open display' message, give a display \n";
print "parameter on the command line, and it will attempt to open it.\n";
print "parameter (like 'myhost:0') on the command line, and it will \n";
print "attempt to open it.\n";
die("\n");
} else {
use Mysql;
......@@ -43,12 +44,17 @@ open(TMP,">$filename");
print TMP "graph: {\n orientation: left_to_right\n".
" title: \"Testbed Database Relational Graph - ".$date."\"\n";
print TMP " display_edge_labels: yes\n scaling: 0.40\n";
print TMP " height: 1000\n width: 500\n";
print TMP " priority_phase: yes\n straight_phase: yes\n";
print TMP " crossingweight: medianbary\n splines: yes\n";
print TMP " arrowmode: fixed\n";
# Adjust the scale here...
print TMP " display_edge_labels: yes\n scaling: 0.37\n";
# Use one of the following to control layout... whichever works better...
print TMP " crossingweight: medianbary\n splines: yes\n";
#print TMP " crossingweight: barymedian\n splines: yes\n";
my $sth ="";
my $cmd ="";
my @data=();
......@@ -88,7 +94,7 @@ foreach $col ( sort keys %tablecols) {
@tables= sort split('\.',$tablecols{$col});
foreach $tbl (sort @tables) {
if (@tables < 2 ||
$tbl=~/^delta_|proj_|dela|rel|nodes|log|exper|res|out|part|int/i ) {
$tbl=~/^delta_|proj_|dela|rel|nodes|log|exper|res|part|int/i ) {
print TMP " edge: { sourcename: \"$col\" ".
"targetname: \"$tbl\" }\n";
} else {
......
......@@ -89,17 +89,20 @@ if ($user ne "root") {
my @conds = ();
foreach $node (@machines) {
push(@conds,"\Lnode_id='$node'");
if ($node =~ /sh\d+/) { push(@conds,"\Lnode_id like '$node%'"); }
}
my $cmd =
"select uid, node_id from reserved as r left join experiments as e ".
"on r.eid = e.eid left join proj_memb as pm on pm.pid=e.pid where (".
join(" or ",@conds).") and uid='$user';";
$sth = $dbh->query($cmd);
#print "$cmd\n";
while ( @_ = $sth->fetchrow_array()) {
#print "Got '",join("'\t'",@_),"'\n";
push(@OkNodes, "\L$_[1]"); #make sure its lowercase
my $node = "\L$_[1]";
$node =~ s/(sh\d+)-\d/$1/;
push(@OkNodes, "$node");
}
}
......@@ -111,17 +114,22 @@ if ($user ne "root") {
foreach $node ( sort @machines) {
my $Approved = 0;
foreach $ok (sort @OkNodes) { if ($node eq $ok) { $Approved = 1; } }
if (!$Approved && ($user ne "root")) {
print "You are not authorized to control $node. Skipping...\n";
if (!$Approved && ($user ne "root")) {
if ($node =~ /(sh\d+)-\d/) {
print "$node: Sharks are controlled by shelf only. Use '$1'.\n";
} else {
print "You are not authorized to control $node. Skipping...\n";
}
$exitval++;
} else {
#print $snmpit, '-i',$IPList{$node},$op,$OutletList{$node},"\n";
$node =~ /(sh\d+)-(\d)/;
if ( ! defined ($IPList{$node}) ) {
print "Machine $node not found. Skipping...\n";
$exitval++;
} else {
my $cmd=join(" ",
($snmpit,'-v','-i',$IPList{$node},$op,$OutletList{$node}));
#print "calling $cmd\n";
open(OUT,$cmd." |");
while (<OUT>) {
if (/was outlet([OnfRebot]+)/) {
......
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