Commit 052a4b0e authored by Christopher Alfeld's avatar Christopher Alfeld

Fixed to use new class/type stuff.

parent 58247bf1
......@@ -5,12 +5,6 @@
# Switch interface speed - In Mbps
$switch_speed = 100;
# Switch types - include all node types that are switches
%switch_types = (
'cisco6509', 1,
'intel510t', 1
);
# Omit types - Include all types of node that will never be used.
%omit_types = (
'APC', 1,
......@@ -25,6 +19,19 @@ my $dbh = DBI->connect("DBI:mysql:database=$TBDB;host=localhost");
@switches=();
%used_switches=();
# Read class/type maps
$sth = $dbh->prepare("select class,type,delay_capacity from node_types");
$sth->execute;
while (($class,$type,$delaycapacity) = $sth->fetchrow_array) {
$classes{$type} = $class;
$nodetypes{$type} = $delaycapacity
}
$sth->finish;
# switches can't delay
$nodetypes{"switch"} = 0;
# Find available nodes
$sth = $dbh->prepare("select a.node_id,a.type from" .
" nodes as a left join reserved as b" .
......@@ -40,25 +47,14 @@ while (($node,$type) = $sth->fetchrow_array) {
$nodes{"sh$shelf"} = "shark-shelf";
}
} else {
if (defined($switch_types{$type})) {
$type = "switch";
if ($classes{$type} eq "switch") {
push(@switches,$node);
}
$nodes{$node} = $type;
$nodetypes{$type} = 1;
}
}
$sth->finish;
foreach $type (keys(%nodetypes)) {
$sth = $dbh->prepare("SELECT delay_capacity" .
" from node_types where type = \"$type\"");
$sth->execute;
($delaycapacity) = $sth->fetchrow_array;
$nodetypes{$type} = $delaycapacity;
$sth->finish;
}
$nodetypes{"switch"} = 0;
$sharklinks = "";
foreach $node (keys(%nodes)) {
......@@ -66,10 +62,14 @@ foreach $node (keys(%nodes)) {
print "node $node shark-shelf:1\n";
$sharklinks .= "link link-$node $node:$node/eth0 cisco 100 1\n";
} else {
$text = "node $node $nodes{$node}:1";
$delay_capacity = $nodetypes{$nodes{$node}};
if ($delay_capacity > 0) {
$text .= " delay:$delay_capacity";
if ($classes{$nodes{$node}} eq "switch") {
$text = "node $node switch:1";
} else {
$text = "node $node $nodes{$node}:1 $classes{$nodes{$node}}:1";
$delay_capacity = $nodetypes{$nodes{$node}};
if ($delay_capacity > 0) {
$text .= " delay:$delay_capacity";
}
}
print "$text\n";
}
......@@ -128,7 +128,7 @@ while (($node1,$card1,$port1,$node2,$card2,$port2) =
} else {
$bw = $iface2bw;
}
if ($nodes{$node2} eq "switch") {
if ($classes{$nodes{$node2}} eq "switch") {
$used_switches{$node2} = 1;
}
# !!! - Here we use our knowledge that in the wires table links
......
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