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

Fixed to use new class/type stuff.

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