Commit 0fc1f7a2 authored by Robert Ricci's avatar Robert Ricci

Added interswitch bandwidth tracking to ptopgen. This feature looks at

the vlans table to determine how much of the trunk bandwidth is
currently 'reserved', and subtracts that from the trunk bandwidth
reported in the output.

This feature is disabled by default. However, you can enable it by
putting the line
TRACK_INTERSWITCH_BANDWIDTH=1
in your defs file.
parent 3f366559
...@@ -832,6 +832,7 @@ fi ...@@ -832,6 +832,7 @@ fi
# #
# Defaults for for above variables. # Defaults for for above variables.
# #
...@@ -1118,7 +1119,7 @@ fi ...@@ -1118,7 +1119,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh. # ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1122: checking for a BSD compatible install" >&5 echo "configure:1123: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
...@@ -1408,6 +1409,7 @@ s%@OURDOMAIN@%$OURDOMAIN%g ...@@ -1408,6 +1409,7 @@ s%@OURDOMAIN@%$OURDOMAIN%g
s%@FSDIR_PROJ@%$FSDIR_PROJ%g s%@FSDIR_PROJ@%$FSDIR_PROJ%g
s%@FSDIR_GROUPS@%$FSDIR_GROUPS%g s%@FSDIR_GROUPS@%$FSDIR_GROUPS%g
s%@FSDIR_USERS@%$FSDIR_USERS%g s%@FSDIR_USERS@%$FSDIR_USERS%g
s%@TRACK_INTERSWITCH_BANDWIDTH@%$TRACK_INTERSWITCH_BANDWIDTH%g
s%@LEDA@%$LEDA%g s%@LEDA@%$LEDA%g
s%@ASSIGN@%$ASSIGN%g s%@ASSIGN@%$ASSIGN%g
s%@SSH_ARGS@%$SSH_ARGS%g s%@SSH_ARGS@%$SSH_ARGS%g
......
...@@ -36,6 +36,7 @@ AC_SUBST(OURDOMAIN) ...@@ -36,6 +36,7 @@ AC_SUBST(OURDOMAIN)
AC_SUBST(FSDIR_PROJ) AC_SUBST(FSDIR_PROJ)
AC_SUBST(FSDIR_GROUPS) AC_SUBST(FSDIR_GROUPS)
AC_SUBST(FSDIR_USERS) AC_SUBST(FSDIR_USERS)
AC_SUBST(TRACK_INTERSWITCH_BANDWIDTH)
# #
# Defaults for for above variables. # Defaults for for above variables.
......
...@@ -42,6 +42,8 @@ use lib '@prefix@/lib'; ...@@ -42,6 +42,8 @@ use lib '@prefix@/lib';
require exitonwarn; require exitonwarn;
use libdb; use libdb;
my $TRACK_INTERSWITCH_BANDWIDTH = "@TRACK_INTERSWITCH_BANDWIDTH@";
%switches=(); %switches=();
%used_switches=(); %used_switches=();
my $switchtouse; my $switchtouse;
...@@ -155,6 +157,25 @@ while (($type,$speed) = $result->fetchrow_array) { ...@@ -155,6 +157,25 @@ while (($type,$speed) = $result->fetchrow_array) {
} }
$result->finish; $result->finish;
# Read interface switches
$result = DBQueryFatal("SELECT node_id1, iface, node_id2 FROM wires AS w " .
"LEFT JOIN interfaces as i ON w.node_id1=i.node_id AND w.card1=i.card");
while (($node,$iface,$switch) = $result->fetchrow_array) {
if ($node && $iface) {
$interfaceswitches{"$node:$iface"} = $switch;
}
}
$result->finish;
# Read interface cards and ports
$result = DBQueryFatal("SELECT node_id, iface, card, port FROM interfaces");
while (($node,$iface,$card,$port) = $result->fetchrow_array) {
$interfacecardports{"$node:$iface"} = [$card,$port];
}
$result->finish;
$result = DBQueryFatal("SELECT node_id1,card1,port1,node_id2,card2,port2" . $result = DBQueryFatal("SELECT node_id1,card1,port1,node_id2,card2,port2" .
" from wires where type=\"Node\" or type=\"Trunk\""); " from wires where type=\"Node\" or type=\"Trunk\"");
while (($node1,$card1,$port1,$node2,$card2,$port2) = while (($node1,$card1,$port1,$node2,$card2,$port2) =
...@@ -192,6 +213,56 @@ while (($node1,$card1,$port1,$node2,$card2,$port2) = ...@@ -192,6 +213,56 @@ while (($node1,$card1,$port1,$node2,$card2,$port2) =
} }
} }
$result->finish; $result->finish;
#
# If we're supposed to track interswitch bandwidth, subtract out the amount
# that's already in use
#
if ($TRACK_INTERSWITCH_BANDWIDTH) {
#
# Get a list of all VLANs
#
my $result = DBQueryFatal("SELECT virtual, members FROM vlans");
while (my ($virtual, $members) = $result->fetchrow()) {
#
# Split apart the space-separated list of members
#
my @members = split /\s+/, $members;
my %switches = ();
foreach my $member (@members) {
my ($node,$iface) = split /:/, $member;
my $switch = get_ifaceswitch($node,$iface);
my ($card, $port) = get_ifacecardport($node,$iface);
my $bw = get_ifacebw($node,$card,$port);
$switches{$switch} += $bw;
}
#
# Check to see if more than one switch was found among the member
# list, and if so, go through all the pairs
#
my @switches = keys %switches;
if (@switches > 1) {
for (my $i = 0; $i < (@switches -1); $i++) {
my $switch1 = $switches[$i];
my $switch2 = $switches[$i+1];
my $bw = $switches{$switch1};
if ($switches{$switch2} < $bw) {
$bw = $switches{$switch2};
}
#
# The trunk link could be listed in either order
#
if ($interconnects{"$switch1:$switch2"}) {
$interconnects{"$switch1:$switch2"} -= $bw;
} elsif ($interconnects{"$switch2:$switch1"}) {
$interconnects{"$switch2:$switch1"} -= $bw;
}
}
}
}
}
foreach $interconnect (keys(%interconnects)) { foreach $interconnect (keys(%interconnects)) {
($src,$dst) = split(":",$interconnect); ($src,$dst) = split(":",$interconnect);
print "link link-$interconnect $src $dst $interconnects{$interconnect} 1\n"; print "link link-$interconnect $src $dst $interconnects{$interconnect} 1\n";
...@@ -236,3 +307,21 @@ sub get_ifacebw { ...@@ -236,3 +307,21 @@ sub get_ifacebw {
return $default_switchport_speed; return $default_switchport_speed;
} }
} }
sub get_ifaceswitch {
($node,$iface) = @_;
if (defined($interfaceswitches{"$node:$iface"})) {
return $interfaceswitches{"$node:$iface"};
} else {
return undef;
}
}
sub get_ifacecardport {
($node,$iface) = @_;
if (defined($interfacecardports{"$node:$iface"})) {
return @{$interfacecardports{"$node:$iface"}};
} else {
return ();
}
}
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